Skip to content

feat: add setting to disable changelog popup on update #57

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to the "cursor-stats" extension will be documented in this f
- δΈ­ζ–‡ (Chinese)
- ν•œκ΅­μ–΄ (Korean)
- πŸ”§ **Language Selection**: New command "Cursor Stats: Select Language" for easy language switching
- βš™οΈ **Changelog Popup Control**: New setting `cursorStats.showChangelogOnUpdate` to disable automatic changelog popup and update notifications on extension updates (disabled by default for less distraction)

### Changed
- 🌐 All UI elements, notifications, and messages are now translatable
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
| `cursorStats.excludeWeekends` | Exclude weekends from period progress and daily calculations | `false` |
| `cursorStats.showDailyRemaining` | Show estimated fast requests remaining per day | `false` |
| `cursorStats.language` | Language for extension interface and messages | `en` |
| `cursorStats.showChangelogOnUpdate` | Show changelog popup and update notifications when extension updates | `false` |

</details>

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@
"ν•œκ΅­μ–΄ (Korean)"
],
"description": "Language for the extension interface and messages."
},
"cursorStats.showChangelogOnUpdate": {
"type": "boolean",
"default": false,
"description": "Show changelog popup and update notifications when the extension is updated to a new version.",
"scope": "window"
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,18 @@ export async function activate(context: vscode.ExtensionContext) {
log(`[Initialization] Current version: ${currentVersion}, Last installed: ${lastInstalledVersion || 'not set'}`);

if (lastInstalledVersion && lastInstalledVersion !== currentVersion) {
// Show changelog for the current version (we've updated)
log(`[Update] Extension updated from ${lastInstalledVersion} to ${currentVersion}, showing changelog`);
setTimeout(() => {
checkForUpdates(0, 0, currentVersion);
}, 3000); // Slight delay to let extension finish activating
// Check if changelog should be shown on update
const showChangelogOnUpdate = vscode.workspace.getConfiguration('cursorStats').get('showChangelogOnUpdate', false);

if (showChangelogOnUpdate) {
// Show changelog for the current version (we've updated)
log(`[Update] Extension updated from ${lastInstalledVersion} to ${currentVersion}, showing changelog`);
setTimeout(() => {
checkForUpdates(0, 0, currentVersion);
}, 3000); // Slight delay to let extension finish activating
} else {
log(`[Update] Extension updated from ${lastInstalledVersion} to ${currentVersion}, changelog disabled by user setting`);
}
}

// Update the stored version
Expand Down
69 changes: 42 additions & 27 deletions src/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export async function checkForUpdates(lastReleaseCheck: number, RELEASE_CHECK_IN
const context = getExtensionContext();

if (specificVersion) {
// Check if changelog should be shown when explicitly requested on update
const showChangelogOnUpdate = vscode.workspace.getConfiguration('cursorStats').get('showChangelogOnUpdate', false);

if (!showChangelogOnUpdate) {
log(`[GitHub] Changelog for specific version ${specificVersion} disabled by user setting`);
return;
}

// Show changelog for specific version
log(`[GitHub] Showing changelog for specific version: ${specificVersion}`);
const versionQuery = specificVersion.startsWith('v') ? specificVersion : `v${specificVersion}`;
Expand Down Expand Up @@ -99,41 +107,48 @@ export async function checkForUpdates(lastReleaseCheck: number, RELEASE_CHECK_IN
const releaseInfo = await checkGitHubRelease();

if (releaseInfo?.hasUpdate) {
// Check if changelog should be shown on update
const showChangelogOnUpdate = vscode.workspace.getConfiguration('cursorStats').get('showChangelogOnUpdate', false);

// Get previously shown changelogs
const shownChangelogs: string[] = context.globalState.get(SHOWN_CHANGELOGS_KEY, []);

// Check if this version's changelog has been shown before
if (!shownChangelogs.includes(releaseInfo.latestVersion)) {
const releaseType = releaseInfo.isPrerelease ? t('github.preRelease') : t('github.stableRelease');
const message = t('github.updateAvailable', {
releaseType: releaseType,
releaseName: releaseInfo.releaseName,
currentVersion: releaseInfo.currentVersion
});
const releaseType = releaseInfo.isPrerelease ? t('github.preRelease') : t('github.stableRelease');
const message = t('github.updateAvailable', {
releaseType: releaseType,
releaseName: releaseInfo.releaseName,
currentVersion: releaseInfo.currentVersion
});
log(`[GitHub] Showing update notification: ${message}`);

// Show changelog directly without asking
log('[GitHub] Showing changelog webview...');

// Create the GitHub release object from releaseInfo
const release: GitHubRelease = {
tag_name: `v${releaseInfo.latestVersion}`,
name: releaseInfo.releaseName,
body: releaseInfo.releaseNotes,
html_url: releaseInfo.releaseUrl,
prerelease: releaseInfo.isPrerelease,
zipball_url: releaseInfo.zipballUrl,
tarball_url: releaseInfo.tarballUrl,
assets: releaseInfo.assets.map(asset => ({
name: asset.name,
browser_download_url: asset.downloadUrl
}))
};

showChangelogWebview(release, releaseInfo.latestVersion);
if (showChangelogOnUpdate) {
// Show changelog directly without asking
log('[GitHub] Showing changelog webview...');

// Create the GitHub release object from releaseInfo
const release: GitHubRelease = {
tag_name: `v${releaseInfo.latestVersion}`,
name: releaseInfo.releaseName,
body: releaseInfo.releaseNotes,
html_url: releaseInfo.releaseUrl,
prerelease: releaseInfo.isPrerelease,
zipball_url: releaseInfo.zipballUrl,
tarball_url: releaseInfo.tarballUrl,
assets: releaseInfo.assets.map(asset => ({
name: asset.name,
browser_download_url: asset.downloadUrl
}))
};

showChangelogWebview(release, releaseInfo.latestVersion);

// Show a small notification that there's an update, but don't ask for action
vscode.window.showInformationMessage(message);
// Show a small notification that there's an update, but don't ask for action
vscode.window.showInformationMessage(message);
} else {
log('[GitHub] Update notifications disabled by user setting, skipping changelog and notification');
}
} else {
log(`[GitHub] Changelog for version ${releaseInfo.latestVersion} has already been shown`);
}
Expand Down