Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][bump version to 3.1.4]: resolved the extension dysfunctioning when user navigates from /new page to /chat/* page without refreshing #52

Merged
merged 22 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
78bd584
docs: Update changelog for feature management architecture
lumpinif Nov 28, 2024
6c39aac
Merge branches 'main' and 'main' of https://github.com/lumpinif/Think…
lumpinif Nov 28, 2024
1b977e5
Merge branch 'richards199999:main' into main
lumpinif Nov 30, 2024
be3f525
fix: properly cleanup and reinitialize features and observers during …
lumpinif Nov 30, 2024
db73579
chore: bump version to 3.1.4 [skip ci]
github-actions[bot] Nov 30, 2024
743de88
chore: update changelog and disable duplicate heading rule
lumpinif Nov 30, 2024
4647a37
Merge branch 'main' of https://github.com/lumpinif/Thinking-Claude
lumpinif Nov 30, 2024
1592f0b
chore: bump version to 3.1.5 [skip ci]
github-actions[bot] Nov 30, 2024
61ea8ec
ci: enhance version management in GitHub Actions workflow
lumpinif Nov 30, 2024
9fb1236
chore: update the CHANGELOG for github action CI
lumpinif Nov 30, 2024
2320fa4
ci: fix the syntax error
lumpinif Nov 30, 2024
c815def
fix: syntax errors in chrome extension CI workflow
lumpinif Nov 30, 2024
1bf63f3
chore: version bumping test
lumpinif Nov 30, 2024
c2024a3
chore: version bumping test
lumpinif Nov 30, 2024
036ee0e
chore: bump version to 3.1.5 [skip ci]
github-actions[bot] Nov 30, 2024
6773ce3
chore: version bumping testing
lumpinif Nov 30, 2024
e5b6ccb
Merge branch 'main' of https://github.com/lumpinif/Thinking-Claude
lumpinif Nov 30, 2024
55b4c5d
chore: bump version to 3.1.6 [skip ci]
github-actions[bot] Nov 30, 2024
907789d
chore: version downgrade to v3.1.4 for latest after testing
lumpinif Nov 30, 2024
c6c5321
Merge branch 'richards199999:main' into main
lumpinif Nov 30, 2024
f649767
Merge branch 'main' of https://github.com/lumpinif/Thinking-Claude
lumpinif Nov 30, 2024
dde6581
Merge branch 'main' of https://github.com/lumpinif/Thinking-Claude
lumpinif Nov 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 150 additions & 18 deletions .github/workflows/chrome-extension-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,46 +61,178 @@ jobs:
- name: Build extension
run: bun run build

- name: Zip Extension
run: zip -r chrome-extension.zip dist/

# Automatically increments the patch version (e.g., 1.0.0 -> 1.0.1)
# and creates a release
# Only increment patch version for non-major versions
- name: Check existing tag
id: check_tag
shell: bash
run: |
current_version=$(node -p "require('./package.json').version")
set -euo pipefail # Exit on error, undefined vars, and pipe failures

# Function to validate semver format
# Supports standard versions (x.y.z) and pre-release versions (x.y.z-beta.n)
validate_version() {
local version="$1"
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
echo "Error: Invalid version format: $version"
echo "Version must be in format: x.y.z or x.y.z-pre.n"
exit 1
fi
}

# Function to update version in JSON files
update_json_version() {
local file="$1"
local cur_ver="$2"
local new_ver="$3"

if [[ ! -f "$file" ]]; then
echo "Error: File $file not found"
exit 1
fi

# Check if version field exists
if ! grep -q "\"version\":" "$file"; then
echo "Error: No version field found in $file"
exit 1
fi

# Backup file before modification
cp "$file" "${file}.bak"

if ! sed -i "s/\"version\": \"$cur_ver\"/\"version\": \"$new_ver\"/" "$file"; then
echo "Error: Failed to update version in $file"
mv "${file}.bak" "$file" # Restore backup
exit 1
fi

rm "${file}.bak" # Remove backup if successful
}

# Function to compare versions
version_gt() {
test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
}

# Get current version with error handling
if [[ ! -f "package.json" ]]; then
echo "Error: package.json not found"
exit 1
fi

if ! current_version=$(node -p "try { require('./package.json').version } catch(e) { console.error(e); process.exit(1) }" 2>/dev/null); then
echo "Error: Failed to read version from package.json"
exit 1
fi

# Validate version format
validate_version "$current_version"

# Get highest existing version with error handling
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
echo "Warning: Failed to fetch remote tags, proceeding with caution"
fi

# Prevent version downgrade
# Note: To downgrade versions, you need to manually:
# 1. Delete the higher version tag: git push origin :refs/tags/chrome-extension-v<version>
# 2. Delete the corresponding GitHub release
if [ ! -z "$highest_version" ] && version_gt "$highest_version" "$current_version"; then
echo "Error: Version downgrade not allowed. Current: $current_version, Highest: $highest_version"
exit 1
fi

# Handle pre-release versions
if [[ "$current_version" == *"-"* ]]; then
echo "Pre-release version detected: $current_version"

# Extract base version and pre-release parts
base_version=${current_version%%-*}
pre_release=${current_version#*-}
pre_type=${pre_release%%.*}
pre_num=${pre_release#*.}

# Check if same pre-release version exists
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
# Increment pre-release number
new_pre_num=$((pre_num + 1))
new_version="${base_version}-${pre_type}.${new_pre_num}"
echo "Incrementing pre-release: $current_version -> $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "Using current pre-release version: $current_version"
echo "version=$current_version" >> $GITHUB_OUTPUT
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
exit 0
fi

# Handle major versions (x.0.0)
if [[ "$current_version" =~ ^[0-9]+\.0\.0$ ]]; then
# Don't increment major versions (x.0.0)
echo "version=$current_version" >> $GITHUB_OUTPUT
echo "version_changed=false" >> $GITHUB_OUTPUT
elif git ls-remote --tags origin | grep -q "refs/tags/v$current_version"; then
# If tag exists and it's not a major version, increment patch
echo "Major version detected: $current_version"

# Check if major version tag exists
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
# Increment patch version like normal
new_version="${current_version%.*}.1" # x.0.0 -> x.0.1
echo "Major version exists, incrementing patch: $current_version -> $new_version"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "Using new major version: $current_version"
echo "version=$current_version" >> $GITHUB_OUTPUT
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
exit 0
fi

# Check if tag exists
if git ls-remote --tags origin | grep -q "refs/tags/chrome-extension-v$current_version"; then
echo "Tag exists, incrementing patch version"

# Split version into components
IFS='.' read -r major minor patch <<< "$current_version"
new_version="$major.$minor.$((patch + 1))"
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "version_changed=true" >> $GITHUB_OUTPUT
# Update package.json with new version
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.json
# Update manifest.json with new version
sed -i "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" public/manifest.json
validate_version "$new_version"

echo "Updating version from $current_version to $new_version"

# Update version in files
update_json_version "package.json" "$current_version" "$new_version"
update_json_version "public/manifest.json" "$current_version" "$new_version"

# Configure git for fork workflow
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

# Commit and push changes
git add package.json public/manifest.json
git commit -m "chore: bump version to $new_version [skip ci]"
git push

if ! git push; then
echo "Error: Failed to push changes"
exit 1
fi
echo "version=$new_version" >> $GITHUB_OUTPUT
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "Using current version: $current_version"
echo "version=$current_version" >> $GITHUB_OUTPUT
echo "version_changed=false" >> $GITHUB_OUTPUT
fi

- name: Zip Extension
run: zip -r thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip dist/

- name: Create Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
name: Chrome Extension v${{ steps.check_tag.outputs.version }}
tag_name: v${{ steps.check_tag.outputs.version }}
files: extensions/chrome/chrome-extension.zip
tag_name: chrome-extension-v${{ steps.check_tag.outputs.version }}
files: extensions/chrome/thinking-claude-chrome-extension-v${{ steps.check_tag.outputs.version }}.zip
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true
73 changes: 62 additions & 11 deletions extensions/changelog.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,95 @@
## Changelog of the extensions
<!-- markdownlint-disable MD024 -->

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

#### Performance & Code Quality
## ci: - 11/30/2024 - @lumpinif

### Chrome Extension CI Improvements

- Enhanced version management in GitHub Actions workflow
- Added robust semver validation supporting x.y.z and pre-release versions
- Implemented automatic patch version increment for existing versions
- Added support for pre-release versions (beta) with auto-increment
- Added version downgrade prevention with clear error messages
- Improved error handling for file operations and git commands
- Added backup mechanism for safe version updates
- Enhanced logging for better debugging and transparency

### File Operations

- Added safe JSON file updates with backup mechanism
- Improved handling of package.json and manifest.json version updates
- Added validation for version field existence in JSON files

## fix: - 11/30/2024 - @lumpinif

### Feature Cleanup & Navigation

- Fixed thinking block toggle not working when navigating between pages
- Improved cleanup and reinitialization of features during page navigation
- Added proper cleanup for mutation observer to prevent memory leaks
- Added background script for better navigation handling between pages

### Code Quality

- Removed debug console logs while keeping error logs for better production monitoring
- Added [TC] prefix to error messages for better identification
- Improved error handling and cleanup process

## feat/fix/ref: - 11/28/2024 - @lumpinif

### Architecture

- Implement feature management architecture for better extensibility
- Add ExtensionManager for high-level orchestration
- Create FeatureManager for feature lifecycle
- Convert TCThinkingBlock to new architecture
- Add configurable MutationObserverService
- Remove singleton pattern usage
- Improve code organization and modularity
- Clear separation of concerns
- Dependency injection pattern
- Standardized feature lifecycle

## feat/fix/ref: - 11/27/2024 - @lumpinif

### Performance & Code Quality

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

#### Bug Fixes
### Bug Fixes

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

#### UI Improvements
### UI Improvements

- Update chevron icon with transition effect

#### Architecture
### Architecture

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

### fix: - 11/17/2024 - @lumpinif
## fix: - 11/17/2024 - @lumpinif

#### Observer Management and Memory Leak Prevention
### Observer Management and Memory Leak Prevention

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

#### Code Quality
### Code Quality

- Fixed code formatting and linting issues flagged by Biome

#### Development Setup
### Development Setup

- Added .vscode settings with Biome extension recommendation

#### Platform Updates
### Platform Updates

- Updated code in both Chrome and Firefox extensions
35 changes: 0 additions & 35 deletions extensions/chrome/CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion extensions/chrome/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thinking-claude",
"version": "3.1.3",
"version": "3.1.4",
"description": "Chrome extension for letting Claude think like a real human",
"type": "module",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions extensions/chrome/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"manifest_version": 3,
"name": "Thinking Claude",
"version": "3.1.3",
"version": "3.1.4",
"description": "Chrome extension for letting Claude think like a real human",
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://*.claude.ai/*"],
Expand All @@ -23,5 +26,5 @@
},
"default_title": "Thinking Claude"
},
"permissions": ["storage"]
"permissions": ["storage", "webNavigation", "tabs"]
}
Loading