一键导入
vscode-status-bar-coordination
Pattern for coordinating VS Code status bar updates with tree view and data provider refresh cycles
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Pattern for coordinating VS Code status bar updates with tree view and data provider refresh cycles
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Pattern for VS Code tree views that consume optional services with graceful degradation
Patterns for building dashboard webviews with tabs and visualizations
{what this skill teaches agents}
Lightweight YAML frontmatter extraction from markdown files without external dependencies
Pattern for building Node.js API clients with TTL-based caching and no external dependencies
CI pipeline patterns for VS Code extensions using GitHub Actions
| name | vscode-status-bar-coordination |
| description | Pattern for coordinating VS Code status bar updates with tree view and data provider refresh cycles |
| domain | vscode-extensions |
| confidence | low |
| source | earned |
VS Code extensions with tree views often need a companion status bar item to provide at-a-glance information. The status bar should stay synchronized with tree data and update whenever the underlying data changes (file watcher events, user commands, data provider refreshes).
Both the tree provider and status bar should consume the same data provider instance. This ensures consistency and avoids duplicate data fetching.
const dataProvider = new SquadDataProvider(workspaceRoot);
const treeProvider = new SquadTreeProvider(dataProvider);
const statusBar = new SquadStatusBar(dataProvider);
Every code path that triggers a tree refresh should also update the status bar. This includes:
// File watcher coordination
fileWatcher.onFileChange(() => {
treeProvider.refresh();
statusBar?.update();
});
// Command coordination
vscode.commands.registerCommand('myext.refresh', () => {
dataProvider.refresh();
treeProvider.refresh();
statusBar?.update();
});
Status bar items must be disposed when the extension deactivates. Track the instance and include it in the deactivate cleanup.
let statusBar: MyStatusBar | undefined;
export function activate(context: vscode.ExtensionContext) {
statusBar = new MyStatusBar(dataProvider);
context.subscriptions.push(statusBar);
}
export function deactivate() {
statusBar?.dispose();
}
Use vscode.MarkdownString for status bar tooltips to provide structured, multi-line details that complement the compact status bar text.
const tooltip = new vscode.MarkdownString();
tooltip.appendMarkdown(`**Status Summary**\n\n`);
tooltip.appendMarkdown(`Active: ${count}\n\n`);
this.statusBarItem.tooltip = tooltip;
Use emoji or themed icons in status bar text for immediate visual feedback. Emoji work across all themes without custom icon management.
// Health indicator example
private getHealthIcon(activeCount: number, total: number): string {
const ratio = activeCount / total;
if (ratio >= 0.7) return '🟢';
if (ratio >= 0.3) return '🟡';
return '🟠';
}
this.statusBarItem.text = `$(icon) Status: ${count} ${this.getHealthIcon(count, total)}`;