diff --git a/lib/tooling/explain-tool.ts b/lib/tooling/explain-tool.ts index 3afbd9700..5aa198113 100644 --- a/lib/tooling/explain-tool.ts +++ b/lib/tooling/explain-tool.ts @@ -49,6 +49,7 @@ export class ExplainTool extends BaseTool { } // Return a minimal result with the API endpoint as custom data + // TODO stop casting this and do something better. return { id: this.tool.id, name: this.tool.name, diff --git a/static/event-map.ts b/static/event-map.ts index 767d59523..c76811294 100644 --- a/static/event-map.ts +++ b/static/event-map.ts @@ -141,8 +141,6 @@ export type EventMap = { ppViewClosed: (compilerId: number) => void; ppViewOpened: (compilerId: number) => void; ppViewOptionsUpdated: (compilerId: number, options: PPOptions, recompile: boolean) => void; - explainViewClosed: (compilerId: number) => void; - explainViewOpened: (compilerId: number) => void; renamePane: () => void; requestCompilation: (editorId: number | boolean, treeId: boolean | number) => void; requestMotd: () => void; diff --git a/static/panes/explain-html-view.ts b/static/panes/explain-html-view.ts index 107e84af8..7d45d2f62 100644 --- a/static/panes/explain-html-view.ts +++ b/static/panes/explain-html-view.ts @@ -91,8 +91,8 @@ export class ExplainHtmlView extends Pane { this.contentElement.text('Waiting for compilation...'); this.isAwaitingInitialResults = true; - // Emit singleton opened event - this.eventHub.emit('explainViewOpened', this.compilerInfo.compilerId); + // Emit standard tool opened event + this.eventHub.emit('toolOpened', this.compilerInfo.compilerId, this.getCurrentState()); } override getInitialHTML(): string { @@ -275,8 +275,17 @@ export class ExplainHtmlView extends Pane { return 'Claude Explain'; } + override getCurrentState() { + const state = super.getCurrentState(); + return { + ...state, + toolId: 'explain', + selection: undefined, // Required for NewToolSettings type but we don't have a Monaco editor + }; + } + override close(): void { - this.eventHub.emit('explainViewClosed', this.compilerInfo.compilerId); + this.eventHub.emit('toolClosed', this.compilerInfo.compilerId, this.getCurrentState()); this.eventHub.unsubscribe(); } } diff --git a/views/templates/panes/explain.pug b/views/templates/panes/explain.pug index bc2fd3633..e257d7991 100644 --- a/views/templates/panes/explain.pug +++ b/views/templates/panes/explain.pug @@ -1,13 +1,12 @@ -#explain-view - .explain-container.d-flex.flex-column.h-100 - .top-bar.btn-toolbar.options-toolbar.bg-light.flex-shrink-0(role="toolbar") - include ../../font-size - .status.ms-auto.explain-loading.d-none - i.fas.fa-circle-notch.fa-spin.me-2 - span Generating explanation... - .explain-consent.d-none.flex-shrink-0 - p.mb-0 Claude Explain will send your code and compilation output to an external API. Continue? - button.btn.btn-primary.mt-2.consent-btn Yes, explain this code - .explain-content.content.markdown-body.flex-grow-1.overflow-auto - .bottom-bar.bg-light.d-none.explain-bottom-bar.flex-shrink-0.px-3.d-flex - span.explain-stats.ms-auto \ No newline at end of file +#explain + .top-bar.btn-toolbar.options-toolbar.bg-light.flex-shrink-0(role="toolbar") + include ../../font-size + .status.ms-auto.explain-loading.d-none + i.fas.fa-circle-notch.fa-spin.me-2 + span Generating explanation... + .explain-consent.d-none.flex-shrink-0 + p.mb-0 Claude Explain will send your code and compilation output to an external API. Continue? + button.btn.btn-primary.mt-2.consent-btn Yes, explain this code + .explain-content.content.markdown-body.flex-grow-1.overflow-auto + .bottom-bar.bg-light.d-none.explain-bottom-bar.flex-shrink-0.px-3.d-flex + span.explain-stats.ms-auto \ No newline at end of file