chendefine/dsh-sidebar-vscode0

dsh-sidebar-vscode

DSH web plugin: a better-sidebar tab that embeds the VS Code web workbench opened at the current session workspace, behind the gateway's /vscode subpath or any configured editor base URL. Editor selections land as atomic reference chips whose canonical mentions the host half expands into <text-selection> context at agent/pre-step; explorer files/folders land as path-only resource chips expanded into content-less <file-selection>/<folder-selection> markers.

包名
dsh-sidebar-vscode
版本
0.1.2
许可证
MIT
最近更新
2026年8月27日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:chendefine/dsh-sidebar-vscode

Usage

Opening the tab

Pick VSCode from the sidebar「+」menu; or turn on the openAsDefault setting so brand-new sessions open it by default (a collapsed panel stays collapsed — the tab is simply what the next expansion shows). The toolbar shows the workspace path;「⧉ open in new window」pops a standalone one.

Sending a selection

  1. Select code in the embedded editor (multi-cursor = one chip each);
  2. Right-click → "DSH: Send Selection to Session", or press Ctrl/Cmd+Alt+C;
  3. The atomic chip @src/main.ts L10-L12 appears in the composer — success is silent (the chip is the feedback); only degradations/failures flash an amber notice in the toolbar;
  4. Type and submit as usual. The chip is rewritten to the readable @path L10-L12, and the `` context is injected right after the message.

Selection reference details:

  • Dedup: within one step by (path, start, end) — sending the same selection twice injects one context; the same range with different content (file changed) keeps the newest capture;
  • Freshness: at submit the disk range is re-read confined to the session cwd and hash-compared — a mismatch marks stale="true"; a truncated snapshot instead verifies its kept head/tail halves (truncation alone never marks stale); an unsaved buffer marks dirty="true"; the snapshot text is always injected (no filesystem dependency), and the leading comment tells the model to re-read before editing;
  • Truncation: beyond maxLines (default 200) / maxBytes (default 20000, guards minified single-line files) the head and tail halves are kept with the middle omitted inline as ... (N lines omitted, L51-L150) ..., the tag carries truncated="true", and the real line range is preserved;
  • The context message source is { kind: 'vscode-mention', form: 'notice', version: 1, path, startLine, endLine, language?, contentHash, bytes, truncated, dirty, stale }.

Sending files / folders

Select files/folders in the explorer (multi- and mixed-select work), right-click → Send File/Folder to Session (the entry sits near "Copy Path"). One chip per item: @src/main.ts (file icon) or @src (folder icon); the kind comes from the extension's workspace.fs.stat (symlinks classify by target). On submit each expands to / with source { kind: 'vscode-resource', form: 'notice', version: 1, path, type }. Resource references do no freshness check and ignore the truncation caps; within one step they dedupe by (path, kind), and a selection reference and a resource reference on the same path stay independent.

Managing references

  • The rail above the composer lists every VS Code reference (truncated badge, folder icon, ×N count); a tag's × removes all chips of that reference at once;
  • One backspace deletes a whole chip; once no mention of a reference remains in the draft, submit injects nothing for it;
  • Copying a (rendered) chip and pasting it back rebuilds atomic chips.

Settings

Settings live under "side card → VSCode → 功能设置" (the tab card's gear popup); all five rows render through this plugin's own panel and persist in better-sidebar's pluginSettings['dsh-sidebar-vscode:vscode']not in cordis.patch.yml:

KeyDefaultDescription
openAsDefaultfalseBrand-new sessions open this tab by default (replacing the seeded Files tab); used sessions keep their layouts. The switch also gates the chat file-click takeover and the settings「打开配置文件」takeover
serverUrl/vscodeServer base URL: same-origin gateway subpath, or a full address (e.g. http://127.0.0.1:8000/vscode to bypass the gateway locally; keep the /vscode base path)
pathMap/data/workspace=/data/workspace;/opt=/optDSH prefix → VS Code container prefix as src=dst pairs joined by ;; longest source prefix wins; a path already under a destination passes through unchanged. Rules are prefix rewriters, not a whitelist: chat-side file opens of absolute paths no rule matches pass through as-is (VS Code itself reports a genuinely missing file); only an unmappable session cwd opens the default view with a notice
maxLines200 (range 1–2000)Max rendered code lines per reference; overflow keeps head+tail halves and marks the omitted middle inline
maxBytes20000 (range 1000–200000)UTF-8 byte cap per reference (guards minified single-line files)

(Selection injection itself is always on — no switch.) Number rows enforce their range as you type (red field + inline hint; out-of-range edits snap to the nearest bound on commit); text rows stack description-over-input.

Troubleshooting

SymptomFix
The tab stays blank / the loading hint never clearsCheck serverUrl reachability; diagnose via "open in new window"; with a cross-origin URL the bridge is off by design (paste fallback still works)
"The current workspace path cannot be mapped…" noticeThe session cwd is outside the pathMap roots (e.g. /tmp); add a rule in the settings
No DSH command in the context menu / paletteExtension not installed, serve-web not restarted (the manifest is scanned at startup only), or the workspace is untrusted (restricted mode) — see the FAQ in scripts/install-extension.md
No chip after sending; a code snippet appears on the clipboardLanding failed and the readable fallback reached the clipboard (no composer / cross-origin); paste it into the composer to recover chips
"Injected as a text reference…" noticeThe composer was mid-submit so the chip degraded to a plain-text mention — submitting works the same