Skip to content

Commit cc73fa7

Browse files
authored
🎨 Palette: Fix VS Code concurrent loading states clearing errors (#143)
1 parent 093815d commit cc73fa7

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

‎.Jules/palette.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
## $(date +%Y-%m-%d) - VS Code Concurrent Loading States
22
**Learning:** Overlapping background operations (like file saves and chat responses) can prematurely clear loading indicators if a simple boolean flag is used for state tracking. This causes screen readers to announce incorrect idle states while work is still ongoing.
33
**Action:** Always use a reference counter (`busyCount`) instead of a boolean for shared UI loading states that map to concurrent async operations.
4+
## 2026-04-19 - VS Code Persistent Error States
5+
**Learning:** Persistent error states in VS Code status bars should not be implicitly cleared by concurrent async completion handlers. When overlapping background tasks share UI loading indicators, decoupling the error boolean from the loading counter is necessary to ensure screen readers do not incorrectly announce error resolution when background tasks complete.
6+
**Action:** Always decouple persistent error state booleans from async reference counters, and require explicit user interaction (e.g. clicking the status bar) to dismiss the error.

‎src/ledgermind/vscode/src/extension.ts‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,46 +25,47 @@ export function activate(context: vscode.ExtensionContext) {
2525
statusBarItem.command = showOutputCommandId;
2626

2727
let busyCount = 0;
28+
let isError = false;
2829

29-
const setError = (hasError: boolean) => {
30-
if (hasError) {
30+
const updateStatusBar = () => {
31+
if (isError) {
3132
statusBarItem.text = '$(error) LedgerMind';
3233
statusBarItem.tooltip = 'LedgerMind: Sync Error (Click to view logs)';
3334
statusBarItem.accessibilityInformation = { label: 'LedgerMind Sync Error, click to view logs', role: 'button' };
3435
statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
36+
} else if (busyCount > 0) {
37+
statusBarItem.backgroundColor = undefined;
38+
statusBarItem.text = '$(sync~spin) LedgerMind';
39+
statusBarItem.tooltip = 'LedgerMind: Syncing Context... (Click to view logs)';
40+
statusBarItem.accessibilityInformation = { label: 'LedgerMind Syncing Context, click to view logs', role: 'button' };
3541
} else {
3642
statusBarItem.backgroundColor = undefined;
37-
if (busyCount > 0) {
38-
statusBarItem.text = '$(sync~spin) LedgerMind';
39-
statusBarItem.tooltip = 'LedgerMind: Syncing Context... (Click to view logs)';
40-
statusBarItem.accessibilityInformation = { label: 'LedgerMind Syncing Context, click to view logs', role: 'button' };
41-
} else {
42-
statusBarItem.text = '$(database) LedgerMind';
43-
statusBarItem.tooltip = 'LedgerMind Dual-Hook Bridge Active (Click to view logs)';
44-
statusBarItem.accessibilityInformation = { label: 'LedgerMind Dual-Hook Bridge Active, click to view logs', role: 'button' };
45-
}
43+
statusBarItem.text = '$(database) LedgerMind';
44+
statusBarItem.tooltip = 'LedgerMind Dual-Hook Bridge Active (Click to view logs)';
45+
statusBarItem.accessibilityInformation = { label: 'LedgerMind Dual-Hook Bridge Active, click to view logs', role: 'button' };
4646
}
4747
};
4848

49+
const setError = (hasError: boolean) => {
50+
isError = hasError;
51+
updateStatusBar();
52+
};
53+
4954
const setBusy = (busy: boolean) => {
5055
if (busy) {
5156
busyCount++;
52-
if (busyCount === 1) {
53-
setError(false);
54-
}
5557
} else {
5658
if (busyCount > 0) {
5759
busyCount--;
58-
if (busyCount === 0) {
59-
setError(false);
60-
}
6160
}
6261
}
62+
updateStatusBar();
6363
};
6464

6565
context.subscriptions.push(vscode.commands.registerCommand(showOutputCommandId, () => {
6666
outputChannel.show();
67-
setError(false); // Clear error state when logs are opened
67+
isError = false; // Clear error state when logs are opened
68+
updateStatusBar();
6869
}));
6970

7071
// ==========================================

0 commit comments

Comments
 (0)