refactor: optimize core engine and retrieval logic for v2.80.43
This commit is contained in:
@@ -123,45 +123,23 @@ export class SettingsPanelProvider implements vscode.WebviewViewProvider {
|
||||
}
|
||||
|
||||
public async focus(): Promise<void> {
|
||||
// Reveal the Astra activity-bar container so a focus() doesn't silently
|
||||
// no-op against a collapsed sidebar.
|
||||
try {
|
||||
await vscode.commands.executeCommand('workbench.view.extension.g1nation-sidebar');
|
||||
} catch {
|
||||
// Older VS Code versions may not expose this command.
|
||||
}
|
||||
try {
|
||||
await vscode.commands.executeCommand(`${SettingsPanelProvider.viewType}.focus`);
|
||||
} catch (e: any) {
|
||||
// The view-focus command is auto-generated only when VS Code parsed
|
||||
// the package.json `views` entry. If a stale .vsix is installed
|
||||
// (or the user hasn't reloaded after a fresh install) the command
|
||||
// is missing and we hit `command not found`. Fall back to a
|
||||
// floating panel so the user still gets the same UI.
|
||||
if (this._isCommandNotFound(e)) {
|
||||
logInfo('Settings view command missing — opening as floating panel.');
|
||||
await this.openAsPanel();
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
await this.openAsPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the same settings UI as a stand-alone editor panel. Used when the
|
||||
* sidebar `WebviewView` isn't registered yet (e.g. user installed a fresh
|
||||
* .vsix without reloading) — keeps the feature reachable without forcing
|
||||
* the user back through `vsce package` cycles.
|
||||
* Open the settings UI as a stand-alone editor panel (Column 3 by default).
|
||||
* Astra's sidebar view container was removed in 2.81 — all three webviews
|
||||
* (Chat, Approvals, Settings) now live in the editor area.
|
||||
*/
|
||||
public async openAsPanel(): Promise<void> {
|
||||
public async openAsPanel(column: vscode.ViewColumn = vscode.ViewColumn.Three): Promise<vscode.WebviewPanel> {
|
||||
if (this._panel) {
|
||||
this._panel.reveal(vscode.ViewColumn.Active);
|
||||
return;
|
||||
this._panel.reveal(column);
|
||||
return this._panel;
|
||||
}
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
'g1nation-settings-panel-floating',
|
||||
SettingsPanelProvider.viewType,
|
||||
'Astra Settings',
|
||||
vscode.ViewColumn.Active,
|
||||
column,
|
||||
{ enableScripts: true, localResourceRoots: [this._deps.extensionUri], retainContextWhenHidden: true }
|
||||
);
|
||||
this._panel = panel;
|
||||
@@ -169,11 +147,7 @@ export class SettingsPanelProvider implements vscode.WebviewViewProvider {
|
||||
panel.onDidDispose(() => { this._panel = undefined; });
|
||||
await this._refreshState();
|
||||
void this._fetchModelsAndRefresh();
|
||||
}
|
||||
|
||||
private _isCommandNotFound(e: unknown): boolean {
|
||||
const msg = (e as any)?.message ?? String(e ?? '');
|
||||
return /command\s+'.+'\s+not found/i.test(msg);
|
||||
return panel;
|
||||
}
|
||||
|
||||
/** Re-pull state from sources of truth and broadcast to the webview. */
|
||||
|
||||
Reference in New Issue
Block a user