Skip to content

Commit 56b7736

Browse files
committed
fix: resolve comments
1 parent 88e4281 commit 56b7736

File tree

11 files changed

+84
-303
lines changed

11 files changed

+84
-303
lines changed

packages/schema/build/bundle.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ require('esbuild')
1616
.then(() => {
1717
fs.cpSync('./src/res', 'bundle/res', { force: true, recursive: true });
1818
fs.cpSync('../language/syntaxes', 'bundle/syntaxes', { force: true, recursive: true });
19-
20-
// Copy release notes HTML file
21-
if (fs.existsSync('src/release-notes.html')) {
22-
fs.copyFileSync('src/release-notes.html', 'bundle/release-notes.html');
23-
console.log('Copied release notes HTML file to bundle');
24-
}
2519
})
2620
.then(() => console.log(success))
2721
.catch((err) => {

packages/schema/build/post-build.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,3 @@ console.log('Updating file: dist/cli/index.js');
2727
fs.writeFileSync('dist/cli/index.js', cliContent, {
2828
encoding: 'utf-8',
2929
});
30-
31-
// Copy release notes HTML file to dist
32-
const releaseNotesSource = 'src/release-notes.html';
33-
const releaseNotesDest = 'dist/release-notes.html';
34-
35-
if (fs.existsSync(releaseNotesSource)) {
36-
console.log('Copying release notes HTML file to dist');
37-
fs.copyFileSync(releaseNotesSource, releaseNotesDest);
38-
} else {
39-
console.warn('Release notes HTML file not found at:', releaseNotesSource);
40-
}

packages/schema/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"linkDirectory": true
2828
},
2929
"engines": {
30-
"vscode": "^1.90.0"
30+
"vscode": "^1.102.0"
3131
},
3232
"categories": [
3333
"Programming Languages"
@@ -184,7 +184,6 @@
184184
"@types/tmp": "^0.2.3",
185185
"@types/uuid": "^8.3.4",
186186
"@types/vscode": "^1.102.0",
187-
"@vscode/chat-extension-utils": "0.0.0-alpha.5",
188187
"@vscode/vsce": "^3.5.0",
189188
"@zenstackhq/runtime": "workspace:*",
190189
"dotenv": "^16.0.3",

packages/schema/src/documentation-cache.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import crypto from 'crypto';
2+
import { createHash } from 'crypto';
33

44
// Cache entry interface
55
interface CacheEntry {
@@ -13,7 +13,7 @@ interface CacheEntry {
1313
* using VS Code's globalState for cross-session persistence
1414
*/
1515
export class DocumentationCache implements vscode.Disposable {
16-
private static readonly CACHE_DURATION_MS = 5 * 60 * 1000; // 5 minutes cache duration
16+
private static readonly CACHE_DURATION_MS = 7 * 24 * 60 * 60 * 1000; // 7 days cache duration
1717
private static readonly CACHE_PREFIX = 'doc-cache.';
1818

1919
private extensionContext: vscode.ExtensionContext;
@@ -56,9 +56,8 @@ export class DocumentationCache implements vscode.Disposable {
5656
private generateCacheKey(requestBody: { models: string[] }): string {
5757
// Remove ALL whitespace characters from each model string for cache key generation
5858
// This ensures identical content with different formatting uses the same cache
59-
const normalizedModels = requestBody.models.map((model) => model.replace(/\s/g, ''));
60-
const hash = crypto
61-
.createHash('sha512')
59+
const normalizedModels = requestBody.models.map((model) => model.replace(/\s/g, '')).sort();
60+
const hash = createHash('sha512')
6261
.update(JSON.stringify({ models: normalizedModels }))
6362
.digest('hex');
6463
return `${DocumentationCache.CACHE_PREFIX}${hash}`;

packages/schema/src/extension.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ export async function requireAuth(): Promise<vscode.AuthenticationSession | unde
2323
try {
2424
session = await vscode.authentication.getSession(AUTH_PROVIDER_ID, [], { createIfNone: true });
2525
if (session) {
26-
vscode.window.showInformationMessage('ZenStack sign in successful!');
26+
vscode.window.showInformationMessage('ZenStack sign-in successful!');
2727
}
28-
} catch (e) {
29-
vscode.window.showErrorMessage('ZenStack sign in failed: ' + String(e));
28+
} catch (e: unknown) {
29+
vscode.window.showErrorMessage(
30+
'ZenStack sign-in failed: ' + (e instanceof Error ? e.message : String(e))
31+
);
3032
}
3133
}
3234
}

packages/schema/src/mermaid-generator.ts

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

packages/schema/src/release-notes-manager.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import * as vscode from 'vscode';
55
*/
66
export class ReleaseNotesManager implements vscode.Disposable {
77
private extensionContext: vscode.ExtensionContext;
8-
private releaseNoteVersionKey: string;
8+
private readonly zmodelPreviewReleaseNoteKey = 'zmodel-preview-release-note-shown';
99

1010
constructor(context: vscode.ExtensionContext) {
1111
this.extensionContext = context;
12-
this.releaseNoteVersionKey = `release-notes-shown:${this.extensionContext.extension.packageJSON.version}`;
1312
this.initialize();
1413
}
1514

@@ -25,12 +24,12 @@ export class ReleaseNotesManager implements vscode.Disposable {
2524
*/
2625
async showReleaseNotesIfFirstTime(): Promise<void> {
2726
// Show release notes if this is the first time activating this version
28-
if (!this.extensionContext.globalState.get(this.releaseNoteVersionKey)) {
27+
if (!this.extensionContext.globalState.get(this.zmodelPreviewReleaseNoteKey)) {
2928
await this.showReleaseNotes();
3029
// Update the stored version to prevent showing again
31-
await this.extensionContext.globalState.update(this.releaseNoteVersionKey, true);
30+
await this.extensionContext.globalState.update(this.zmodelPreviewReleaseNoteKey, true);
3231
// Add this key to sync keys for cross-machine synchronization
33-
this.extensionContext.globalState.setKeysForSync([this.releaseNoteVersionKey]);
32+
this.extensionContext.globalState.setKeysForSync([this.zmodelPreviewReleaseNoteKey]);
3433
}
3534
}
3635

@@ -39,9 +38,17 @@ export class ReleaseNotesManager implements vscode.Disposable {
3938
*/
4039
async showReleaseNotes(): Promise<void> {
4140
try {
41+
// Read the release notes HTML file
42+
const releaseNotesPath = vscode.Uri.joinPath(
43+
this.extensionContext.extensionUri,
44+
'bundle/res/zmodel-preview-release-notes.html'
45+
);
46+
47+
const htmlBytes = await vscode.workspace.fs.readFile(releaseNotesPath);
48+
const htmlContent = Buffer.from(htmlBytes).toString('utf8');
4249
// Create and show the release notes webview
4350
const panel = vscode.window.createWebviewPanel(
44-
'zenstackReleaseNotes',
51+
'ZenstackReleaseNotes',
4552
'ZenStack - New Feature Announcement!',
4653
vscode.ViewColumn.One,
4754
{
@@ -50,12 +57,6 @@ export class ReleaseNotesManager implements vscode.Disposable {
5057
}
5158
);
5259

53-
// Read the release notes HTML file
54-
const releaseNotesPath = vscode.Uri.joinPath(this.extensionContext.extensionUri, 'src/release-notes.html');
55-
56-
const htmlBytes = await vscode.workspace.fs.readFile(releaseNotesPath);
57-
const htmlContent = Buffer.from(htmlBytes).toString('utf8');
58-
5960
panel.webview.html = htmlContent;
6061

6162
// Optional: Close the panel when user clicks outside or after some time

packages/schema/src/release-notes.html renamed to packages/schema/src/res/zmodel-preview-release-notes.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ <h1>🎉 Introducing ZModel Documentation Preview</h1>
5353
<div class="feature">
5454
<h3>📖 What's New</h3>
5555
<p>
56-
You can now preview comprehensive documentation for your ZModel files, just like you would previewing a
56+
You can now preview comprehensive documentation for your ZModel files, just like you would preview a
5757
markdown file.
5858
</p>
5959
</div>
@@ -64,7 +64,8 @@ <h3>🚀 How to Use</h3>
6464
<li>Open your <code>.zmodel</code> file</li>
6565
<li>
6666
Click (<span class="codicon codicon-preview"></span>) in the editor toolbar, or simply press
67-
<code>Cmd+Shift+V</code>
67+
<code>Cmd&nbsp;+&nbsp;Shift&nbsp;+&nbsp;V</code> (Mac) or
68+
<code>Ctrl&nbsp;+&nbsp;Shift&nbsp;+&nbsp;V</code> (Windows)
6869
</li>
6970
<li>Sign in with ZenStack (one-time setup)</li>
7071
<li>Enjoy your AI-generated documentation</li>
@@ -74,8 +75,8 @@ <h3>🚀 How to Use</h3>
7475
<div class="steps">
7576
<h3>💡 Tips</h3>
7677
<ul>
77-
<li>Ensure your zmodel is error-free before generating</li>
78-
<li>Use your main zmodel file, it will include all imported models for a complete documentation</li>
78+
<li>Ensure your zmodel is error-free before generating.</li>
79+
<li>Use your main zmodel file, which will include all imported models, for complete documentation.</li>
7980
<li>
8081
Add clear, descriptive comments in your ZModel. The more context you provide, the better the
8182
results.

0 commit comments

Comments
 (0)