Skip to content

Commit 757166d

Browse files
authored
Merge pull request #52 from lumpinif/main
[fix][bump version to 3.1.4]: resolved the extension dysfunctioning when user navigates from `/new` page to `/chat/*` page without refreshing
2 parents f64aad7 + dde6581 commit 757166d

12 files changed

Lines changed: 290 additions & 87 deletions

File tree

.github/workflows/chrome-extension-ci.yml

Lines changed: 150 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,178 @@ jobs:
6161
- name: Build extension
6262
run: bun run build
6363

64-
- name: Zip Extension
65-
run: zip -r chrome-extension.zip dist/
66-
6764
# Automatically increments the patch version (e.g., 1.0.0 -> 1.0.1)
6865
# and creates a release
6966
# Only increment patch version for non-major versions
7067
- name: Check existing tag
7168
id: check_tag
69+
shell: bash
7270
run: |
73-
current_version=$(node -p "require('./package.json').version")
71+
set -euo pipefail # Exit on error, undefined vars, and pipe failures
72+
73+
# Function to validate semver format
74+
# Supports standard versions (x.y.z) and pre-release versions (x.y.z-beta.n)
75+
validate_version() {
76+
local version="$1"
77+
if ! [[ "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
78+
echo "Error: Invalid version format: $version"
79+
echo "Version must be in format: x.y.z or x.y.z-pre.n"
80+
exit 1
81+
fi
82+
}
83+
84+
# Function to update version in JSON files
85+
update_json_version() {
86+
local file="$1"
87+
local cur_ver="$2"
88+
local new_ver="$3"
89+
90+
if [[ ! -f "$file" ]]; then
91+
echo "Error: File $file not found"
92+
exit 1
93+
fi
94+
95+
# Check if version field exists
96+
if ! grep -q "\"version\":" "$file"; then
97+
echo "Error: No version field found in $file"
98+
exit 1
99+
fi
100+
101+
# Backup file before modification
102+
cp "$file" "${file}.bak"
103+
104+
if ! sed -i "s/\"version\": \"$cur_ver\"/\"version\": \"$new_ver\"/" "$file"; then
105+
echo "Error: Failed to update version in $file"
106+
mv "${file}.bak" "$file" # Restore backup
107+
exit 1
108+
fi
109+
110+
rm "${file}.bak" # Remove backup if successful
111+
}
112+
113+
# Function to compare versions
114+
version_gt() {
115+
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
116+
}
117+
118+
# Get current version with error handling
119+
if [[ ! -f "package.json" ]]; then
120+
echo "Error: package.json not found"
121+
exit 1
122+
fi
123+
124+
if ! current_version=$(node -p "try { require('./package.json').version } catch(e) { console.error(e); process.exit(1) }" 2>/dev/null); then
125+
echo "Error: Failed to read version from package.json"
126+
exit 1
127+
fi
128+
129+
# Validate version format
130+
validate_version "$current_version"
131+
132+
# Get highest existing version with error handling
133+
if ! highest_version=$(git ls-remote --tags origin | grep "refs/tags/chrome-extension-v" | sed 's/.*chrome-extension-v//' | sort -V | tail -n 1); then
134+
echo "Warning: Failed to fetch remote tags, proceeding with caution"
135+
fi
136+
137+
# Prevent version downgrade
138+
# Note: To downgrade versions, you need to manually:
139+
# 1. Delete the higher version tag: git push origin :refs/tags/chrome-extension-v<version>
140+
# 2. Delete the corresponding GitHub release
141+
if [ ! -z "$highest_version" ] && version_gt "$highest_version" "$current_version"; then
142+
echo "Error: Version downgrade not allowed. Current: $current_version, Highest: $highest_version"
143+
exit 1
144+
fi
145+
146+
# Handle pre-release versions
147+
if [[ "$current_version" == *"-"* ]]; then
148+
echo "Pre-release version detected: $current_version"
149+
150+
# Extract base version and pre-release parts
151+
base_version=${current_version%%-*}
152+
pre_release=${current_version#*-}
153+
pre_type=${pre_release%%.*}
154+
pre_num=${pre_release#*.}
155+
156+
# Check if same pre-release version exists
157+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
158+
# Increment pre-release number
159+
new_pre_num=$((pre_num + 1))
160+
new_version="${base_version}-${pre_type}.${new_pre_num}"
161+
echo "Incrementing pre-release: $current_version -> $new_version"
162+
echo "version=$new_version" >> $GITHUB_OUTPUT
163+
echo "version_changed=true" >> $GITHUB_OUTPUT
164+
else
165+
echo "Using current pre-release version: $current_version"
166+
echo "version=$current_version" >> $GITHUB_OUTPUT
167+
echo "version_changed=false" >> $GITHUB_OUTPUT
168+
fi
169+
exit 0
170+
fi
171+
172+
# Handle major versions (x.0.0)
74173
if [[ "$current_version" =~ ^[0-9]+\.0\.0$ ]]; then
75-
# Don't increment major versions (x.0.0)
76-
echo "version=$current_version" >> $GITHUB_OUTPUT
77-
echo "version_changed=false" >> $GITHUB_OUTPUT
78-
elif git ls-remote --tags origin | grep -q "refs/tags/v$current_version"; then
79-
# If tag exists and it's not a major version, increment patch
174+
echo "Major version detected: $current_version"
175+
176+
# Check if major version tag exists
177+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
178+
# Increment patch version like normal
179+
new_version="${current_version%.*}.1" # x.0.0 -> x.0.1
180+
echo "Major version exists, incrementing patch: $current_version -> $new_version"
181+
echo "version=$new_version" >> $GITHUB_OUTPUT
182+
echo "version_changed=true" >> $GITHUB_OUTPUT
183+
else
184+
echo "Using new major version: $current_version"
185+
echo "version=$current_version" >> $GITHUB_OUTPUT
186+
echo "version_changed=false" >> $GITHUB_OUTPUT
187+
fi
188+
exit 0
189+
fi
190+
191+
# Check if tag exists
192+
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
193+
echo "Tag exists, incrementing patch version"
194+
195+
# Split version into components
80196
IFS='.' read -r major minor patch <<< "$current_version"
81197
new_version="$major.$minor.$((patch + 1))"
82-
echo "version=$new_version" >> $GITHUB_OUTPUT
83-
echo "version_changed=true" >> $GITHUB_OUTPUT
84-
# Update package.json with new version
85-
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.json
86-
# Update manifest.json with new version
87-
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" public/manifest.json
198+
validate_version "$new_version"
199+
200+
echo "Updating version from $current_version to $new_version"
201+
202+
# Update version in files
203+
update_json_version "package.json" "$current_version" "$new_version"
204+
update_json_version "public/manifest.json" "$current_version" "$new_version"
205+
206+
# Configure git for fork workflow
88207
git config --global user.email "github-actions[bot]@users.noreply.github.com"
89208
git config --global user.name "github-actions[bot]"
209+
210+
# Commit and push changes
90211
git add package.json public/manifest.json
91212
git commit -m "chore: bump version to $new_version [skip ci]"
92-
git push
213+
214+
if ! git push; then
215+
echo "Error: Failed to push changes"
216+
exit 1
217+
fi
218+
echo "version=$new_version" >> $GITHUB_OUTPUT
219+
echo "version_changed=true" >> $GITHUB_OUTPUT
93220
else
221+
echo "Using current version: $current_version"
94222
echo "version=$current_version" >> $GITHUB_OUTPUT
95223
echo "version_changed=false" >> $GITHUB_OUTPUT
96224
fi
225+
226+
- name: Zip Extension
227+
run: zip -r thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip dist/
228+
97229
- name: Create Release
98230
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
99231
uses: softprops/action-gh-release@v1
100232
with:
101233
name: Chrome Extension v${{ steps.check_tag.outputs.version }}
102-
tag_name: v${{ steps.check_tag.outputs.version }}
103-
files: extensions/chrome/chrome-extension.zip
234+
tag_name: chrome-extension-v${{ steps.check_tag.outputs.version }}
235+
files: extensions/chrome/thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip
104236
generate_release_notes: true
105237
token: ${{ secrets.GITHUB_TOKEN }}
106238
fail_on_unmatched_files: true

extensions/changelog.md

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,95 @@
1-
## Changelog of the extensions
1+
<!-- markdownlint-disable MD024 -->
22

3-
### feat/fix/ref: - 11/27/2024 - @lumpinif
3+
# Changelog of the extensions
44

5-
#### Performance & Code Quality
5+
## ci: - 11/30/2024 - @lumpinif
6+
7+
### Chrome Extension CI Improvements
8+
9+
- Enhanced version management in GitHub Actions workflow
10+
- Added robust semver validation supporting x.y.z and pre-release versions
11+
- Implemented automatic patch version increment for existing versions
12+
- Added support for pre-release versions (beta) with auto-increment
13+
- Added version downgrade prevention with clear error messages
14+
- Improved error handling for file operations and git commands
15+
- Added backup mechanism for safe version updates
16+
- Enhanced logging for better debugging and transparency
17+
18+
### File Operations
19+
20+
- Added safe JSON file updates with backup mechanism
21+
- Improved handling of package.json and manifest.json version updates
22+
- Added validation for version field existence in JSON files
23+
24+
## fix: - 11/30/2024 - @lumpinif
25+
26+
### Feature Cleanup & Navigation
27+
28+
- Fixed thinking block toggle not working when navigating between pages
29+
- Improved cleanup and reinitialization of features during page navigation
30+
- Added proper cleanup for mutation observer to prevent memory leaks
31+
- Added background script for better navigation handling between pages
32+
33+
### Code Quality
34+
35+
- Removed debug console logs while keeping error logs for better production monitoring
36+
- Added [TC] prefix to error messages for better identification
37+
- Improved error handling and cleanup process
38+
39+
## feat/fix/ref: - 11/28/2024 - @lumpinif
40+
41+
### Architecture
42+
43+
- Implement feature management architecture for better extensibility
44+
- Add ExtensionManager for high-level orchestration
45+
- Create FeatureManager for feature lifecycle
46+
- Convert TCThinkingBlock to new architecture
47+
- Add configurable MutationObserverService
48+
- Remove singleton pattern usage
49+
- Improve code organization and modularity
50+
- Clear separation of concerns
51+
- Dependency injection pattern
52+
- Standardized feature lifecycle
53+
54+
## feat/fix/ref: - 11/27/2024 - @lumpinif
55+
56+
### Performance & Code Quality
657

758
- Extremely streamline code structure and implementation approach
859
- Much optimized performance
960
- Streamline and organize code for thinking-block implementation
1061

11-
#### Bug Fixes
62+
### Bug Fixes
1263

1364
- Fix flash of unstyled content (FOUC)
1465
- Fix stutter when submitting new replies
1566
- Fix FOUC and streaming issues for thinking-block implementation
1667

17-
#### UI Improvements
68+
### UI Improvements
1869

1970
- Update chevron icon with transition effect
2071

21-
#### Architecture
72+
### Architecture
2273

2374
- Implement ultimate approach with simplest and most effective implementation after experimentation
2475

25-
### fix: - 11/17/2024 - @lumpinif
76+
## fix: - 11/17/2024 - @lumpinif
2677

27-
#### Observer Management and Memory Leak Prevention
78+
### Observer Management and Memory Leak Prevention
2879

2980
- Added observer tracking using Set to manage all MutationObservers
3081
- Added cleanup on element removal to prevent dangling observers
3182
- Added global cleanup on window unload
3283
- Added observer cleanup when observed elements are removed from DOM
3384

34-
#### Code Quality
85+
### Code Quality
3586

3687
- Fixed code formatting and linting issues flagged by Biome
3788

38-
#### Development Setup
89+
### Development Setup
3990

4091
- Added .vscode settings with Biome extension recommendation
4192

42-
#### Platform Updates
93+
### Platform Updates
4394

4495
- Updated code in both Chrome and Firefox extensions

extensions/chrome/CHANGELOG.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

extensions/chrome/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thinking-claude",
3-
"version": "3.1.3",
3+
"version": "3.1.4",
44
"description": "Chrome extension for letting Claude think like a real human",
55
"type": "module",
66
"scripts": {

extensions/chrome/public/manifest.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"manifest_version": 3,
33
"name": "Thinking Claude",
4-
"version": "3.1.3",
4+
"version": "3.1.4",
55
"description": "Chrome extension for letting Claude think like a real human",
6+
"background": {
7+
"service_worker": "background.js"
8+
},
69
"content_scripts": [
710
{
811
"matches": ["https://*.claude.ai/*"],
@@ -23,5 +26,5 @@
2326
},
2427
"default_title": "Thinking Claude"
2528
},
26-
"permissions": ["storage"]
29+
"permissions": ["storage", "webNavigation", "tabs"]
2730
}

0 commit comments

Comments
 (0)