fix(vscode): keep agent view metadata on snapshot errors

This commit is contained in:
Hunter Bown
2026-06-06 01:49:32 -07:00
committed by GitHub
parent cd9a044387
commit 23a188e8fd
5 changed files with 63 additions and 45 deletions
+26 -21
View File
@@ -59,6 +59,30 @@ function activate(context) {
statusView.updateSnapshots(snapshots, "Showing recent restore points.");
output.appendLine(`Loaded ${snapshots.length} runtime restore points.`);
};
const refreshAgentViewDetails = async (showWarning) => {
try {
await refreshAgentView();
}
catch (error) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
output.appendLine(`Runtime thread summaries unavailable: ${detail}`);
if (showWarning) {
void vscode.window.showWarningMessage(detail);
}
}
try {
await refreshSnapshots();
}
catch (error) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime restore points unavailable: ${detail}`);
if (showWarning) {
void vscode.window.showWarningMessage(detail);
}
}
};
const updateStatus = (text, tooltip) => {
status.text = text;
status.tooltip = tooltip;
@@ -74,16 +98,7 @@ function activate(context) {
switch (state.kind) {
case "connected":
updateStatus("$(check) CodeWhale", state.detail);
try {
await refreshAgentView();
await refreshSnapshots();
}
catch (error) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime Agent View details unavailable: ${detail}`);
}
await refreshAgentViewDetails(false);
break;
case "auth-required":
updateStatus("$(lock) CodeWhale", state.detail);
@@ -157,17 +172,7 @@ function activate(context) {
return await checkAndRefreshRuntime(true, true);
}));
context.subscriptions.push(vscode.commands.registerCommand("codewhale.refreshAgentView", async () => {
try {
await refreshAgentView();
await refreshSnapshots();
}
catch (error) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime Agent View details unavailable: ${detail}`);
void vscode.window.showWarningMessage(detail);
}
await refreshAgentViewDetails(true);
}));
context.subscriptions.push(vscode.commands.registerCommand("codewhale.refreshSnapshots", async () => {
try {
File diff suppressed because one or more lines are too long
+26 -19
View File
@@ -38,6 +38,30 @@ export function activate(context: vscode.ExtensionContext): void {
output.appendLine(`Loaded ${snapshots.length} runtime restore points.`);
};
const refreshAgentViewDetails = async (showWarning: boolean): Promise<void> => {
try {
await refreshAgentView();
} catch (error: unknown) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
output.appendLine(`Runtime thread summaries unavailable: ${detail}`);
if (showWarning) {
void vscode.window.showWarningMessage(detail);
}
}
try {
await refreshSnapshots();
} catch (error: unknown) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime restore points unavailable: ${detail}`);
if (showWarning) {
void vscode.window.showWarningMessage(detail);
}
}
};
const updateStatus = (text: string, tooltip: string): void => {
status.text = text;
status.tooltip = tooltip;
@@ -59,15 +83,7 @@ export function activate(context: vscode.ExtensionContext): void {
switch (state.kind) {
case "connected":
updateStatus("$(check) CodeWhale", state.detail);
try {
await refreshAgentView();
await refreshSnapshots();
} catch (error: unknown) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime Agent View details unavailable: ${detail}`);
}
await refreshAgentViewDetails(false);
break;
case "auth-required":
updateStatus("$(lock) CodeWhale", state.detail);
@@ -161,16 +177,7 @@ export function activate(context: vscode.ExtensionContext): void {
context.subscriptions.push(
vscode.commands.registerCommand("codewhale.refreshAgentView", async () => {
try {
await refreshAgentView();
await refreshSnapshots();
} catch (error: unknown) {
const detail = error instanceof Error ? error.message : String(error);
statusView.updateThreads([], "Runtime thread summaries unavailable.");
statusView.updateSnapshots([], detail);
output.appendLine(`Runtime Agent View details unavailable: ${detail}`);
void vscode.window.showWarningMessage(detail);
}
await refreshAgentViewDetails(true);
}),
);