dev already caps stdout bytes (GIT_OUTPUT_MAX_BYTES) and NUL fields, but
three gaps remain, all proven by the 2026-10-13 host crashes (twice:
RangeError: Invalid string length at the stdout accumulator, a junction-
forest workspace driving 'git status -uall' to gigabytes):
1. no latch after a byte-cap reject — later chunks kept ACCUMULATING on
the retained strings. On Windows spawn('git') resolves to the cmd
shim, whose grandchild survives child.kill() and keeps feeding the
dead accumulator (measured: the orphan outlived kill() by 20+s). The
fieldCapped guard covered only the row cap; the byte cap had none.
2. kill() reaches only the wrapper — the orphaned grandchild needs its
pipes destroyed (EPIPE) to actually stop. killTree() destroys both
streams and is now used by every kill path (timeout, byte cap, field
cap).
3. stderr was uncapped — a command whose DIAGNOSTICS stream past the
budget is as able to kill the host via string length as its answer;
stderr now shares the same maxBytes budget.
Worst case in a pathological workspace is now one failed SCM refresh,
never a dead host.
Port PR #434's two Git-panel features onto the current dev structure. The
PR's third commit (file-tree context-menu rename) is dropped: dev already
has it (#550, e39ea92) with a different `fs.rename` payload contract
(`name`, not `newName`) and its own i18n keys, so keeping it would break the
route and duplicate dictionary keys (TS1117).
Why this is a rewrite rather than the PR's diff applied:
- The client carrier moved. `src/client/GitView.tsx` was deleted by 24a3813
(the unified "changes" tab), so the client half lands in
`src/client/changes/GitLens.tsx` and follows that file's conventions: the
bar's single `actionError` status line instead of a second `remoteError`
channel, `runAction` for the git mutations, the kit's `IconButton`, and the
host's own `IconSparkleRegular` rather than a new react-icons import.
- The host route could not read `Session.events` at all: it was renamed to
`snapshotEvents()` in DSH 0.1.2-alpha.4, and 0.2.0-rc.1 marks it `new calls
are prohibited`. `git.suggest-message` resolves its provider/model from the
incrementally folded `Session.requestHeader()` — the same `request/header`
record the PR was after, but O(new events) instead of a full reverse scan.
`SidebarSessionStore` gains that face; `snapshotEvents()` is marked
deprecated there.
- Message source is the plugin's own producer kind
(`plugin:dsh-better-sidebar`, the existing `MessageSourceMap` augmentation):
a bare `plugin` kind is rejected outright in session format v4.
- The commit row stays where dev put it. PR moved it to the top of the panel
because it was buried between the two file lists; dev's commit bar is
already a `position: sticky` footer, so that problem is gone — and
`changes-tab.spec.tsx` pins the bar's status line to the message row.
Beyond the port, the route reads `assembler.finish` so a provider-side failure
is reported with the provider's own reason instead of "the model returned an
empty message", bounds the call with a 30s deadline, and truncates the diff at
12K characters.
Refs #434
Co-authored-by: Ahdong&Shouey <131278957+LiuStar656@users.noreply.github.com>
Port PR #434's two Git-panel features onto the current dev structure. The
PR's third commit (file-tree context-menu rename) is dropped: dev already
has it (#550, e39ea92) with a different `fs.rename` payload contract
(`name`, not `newName`) and its own i18n keys, so keeping it would break the
route and duplicate dictionary keys (TS1117).
Why this is a rewrite rather than the PR's diff applied:
- The client carrier moved. `src/client/GitView.tsx` was deleted by 24a3813
(the unified "changes" tab), so the client half lands in
`src/client/changes/GitLens.tsx` and follows that file's conventions: the
bar's single `actionError` status line instead of a second `remoteError`
channel, `runAction` for the git mutations, the kit's `IconButton`, and the
host's own `IconSparkleRegular` rather than a new react-icons import.
- The host route could not read `Session.events` at all: it was renamed to
`snapshotEvents()` in DSH 0.1.2-alpha.4, and 0.2.0-rc.1 marks it `new calls
are prohibited`. `git.suggest-message` resolves its provider/model from the
incrementally folded `Session.requestHeader()` — the same `request/header`
record the PR was after, but O(new events) instead of a full reverse scan.
`SidebarSessionStore` gains that face; `snapshotEvents()` is marked
deprecated there.
- Message source is the plugin's own producer kind
(`plugin:dsh-better-sidebar`, the existing `MessageSourceMap` augmentation):
a bare `plugin` kind is rejected outright in session format v4.
- The commit row stays where dev put it. PR moved it to the top of the panel
because it was buried between the two file lists; dev's commit bar is
already a `position: sticky` footer, so that problem is gone — and
`changes-tab.spec.tsx` pins the bar's status line to the message row.
Beyond the port, the route reads `assembler.finish` so a provider-side failure
is reported with the provider's own reason instead of "the model returned an
empty message", bounds the call with a 30s deadline, and truncates the diff at
12K characters.
Refs #434
Three small hardening fixes on the host half, all in the same request path.
1) git revisions were spliced into argv as bare operands, so a value beginning
with `-` was consumed by git's OPTION parser instead of being treated as a
revision. `git.show` with rev `--stat` (or `--output=…`) returned empty
instead of failing, which silently blanked the Changes tab's diff/blame
panes; `git.commit-diff`/`revert`/`cherry-pick` took the same shape. Adding
`--end-of-options` before the operand ends option parsing.
Chosen over a regex allowlist on purpose: the UI legitimately sends `:0`
(git's index selector, used for the worktree side of a diff) and `<hash>^`,
and users have branch names this code cannot enumerate. A whitelist would
have to keep growing and would still reject valid refs; the sentinel is
exact and needs no enumeration.
2) `GitCommandError` had no branch in `writeError`, so every ordinary git
failure — unknown ref, path outside the repository, not a repository —
surfaced as 500 `internal`. That reads as a plugin crash and meant the
`not-repo` code (already defined in git.ts) and its localized copy were
unreachable from every route. Non-repository now answers 409 `not-repo`;
other git failures answer 400 `git-error`.
3) the `/sidebar/api` dispatch table is an object literal, so a bare lookup
resolved `Object.prototype` members as handlers:
POST /sidebar/api/constructor -> 200 {}
POST /sidebar/api/toString -> 200 "[object Undefined]"
POST /sidebar/api/valueOf -> 500 internal
POST /sidebar/api/hasOwnProperty -> 500 internal
Switched to `Object.hasOwn` plus a `typeof === 'function'` guard, so every
one of those is the documented 404.
Verified:
- `tests/smoke.spec.ts` gains four cases. Three are red on the pre-change
source (operand guard: `show(dir,'--stat',…)` returned content instead of
null; dispatch: `constructor` answered 200; git status: 500 instead of 409)
and green after.
- the fourth pins the `:0` index selector as a NON-regression, so a future
tightening of the operand handling cannot silently break the diff UI.
- the repo's own `harden` regression is covered: `git.revert(dir, '--abort')`
and `cherryPick(dir, '--abort')` now reject rather than being honoured.
- empirically re-verified against git 2.53.0 that every legitimate revision
form still resolves (`HEAD`, `:0`, `<hash>`, `<hash>^`, `HEAD~1`) while
`--stat` / `--output=nul` / `-n` are refused.
- the wire.ts -> git.ts import introduces no cycle (git.ts imports only node
builtins) and both bundles build clean; typecheck / lint / build /
check:consumer-types clean.
- `pnpm test:windows` 1351 passed, 4 failed — byte-identical to the clean-main
baseline for those two files (pre-existing Windows environment failures).
git emits no ---/+++ for a binary file, a pure rename and a mode-only
change, and parseUnifiedDiff only ever read paths from those two lines.
The section therefore kept oldPath/newPath === '', so DiffFiles drew a
header carrying just the binary badge and no file name (sandwiched
between two .md rows, which is exactly how it reads as if those .md files
were the binary ones), and a pure rename / mode-only change collapsed to
an empty disabled button (no path, and fileTag cannot see a rename).
Recover the paths in order of authority: ---/+++ when present, else the
section's own `rename from|to`, `Binary files A and B differ`, or the
`diff --git` header. Only the mode-only shape needs the last one: it takes
the ` b/` whose two sides name the same file, and leaves the path empty
rather than guessing. ---/+++ values also lose the TAB git appends to a
spaced path, and decodeGitPath undoes git's C-quoting so diff text from a
default-quotePath source still renders the real file name.
runGit gains `-c core.quotePath=false` for the same reason at the source:
git's default turns a space/CJK path into an octal-escaped quoted string,
which every diff surface then renders as the file name. The `-z`-framed
porcelain callers are unaffected (git never quotes NUL-framed output).
Verified against taktop_redo 8b4b933, the commit whose three .jpg rows
rendered as bare badges: all three now carry their full path, and real git
output for space/CJK paths parses with no escapes and no trailing TAB.
New tests: tests/diff-binary-row.spec.tsx (rendered rows) and the path
matrix in tests/diff-rows.spec.ts; tests/git-spawn.spec.ts now derives the
subcommand from runGit's prefix instead of counting its flags.
tests/git.spec.ts had pinned the empty path (`oldPath === ''`) as the known
behaviour of a mode/rename-only section; it now asserts the recovered paths
instead, and the binary section there asserts its own name too.
3s was tight for cold caches on large home directories; 5s still bounds a
stalled mount well below the 30s command budget while cutting false
negatives on slow-but-healthy checkouts.
Opening the source-control panel could freeze the whole sidebar, and the
frozen layout restored itself after every reload, leaving no way out
(issue #369). Three unbounded layers compounded:
- `git status --porcelain -z --untracked-files=all` shipped every row of a
pathological untracked set into one response; the browser main thread
froze on response.json() plus the unvirtualized change list, and the 2s
poll replayed the freeze. status() now caps entries at 2000 and reports
`truncated` (the panel shows a notice, mirroring fs.read's truncation
semantics); worktree change counts inherit the bound for free.
- repoRoots() probed every visible child directory of a non-repo cwd
(e.g. ~) serially, once per git.* call, each with the full 30s command
budget. Discovery now uses a 3s probe timeout, caps probes at 200
directories, and shares one in-flight scan plus a 60s TTL cache per cwd.
- A hung layout persisted `panelOpen: true` with the git tab active, so a
reload remounted straight back into the freeze with no escape hatch.
Loading with `?dsh-sidebar-reset` now drops the persisted layout (and
the shared width) and starts from the default.
statusTruncated copy synced across all 19 shipped dictionaries.
#1 GitView: hide/disable 'open in editor' for external linked worktrees
(path outside session workspace is rejected by the fence); add
isWithinWorkspace client helper for the gate.
#2 DiffTab: untracked diff read resolves against diff.repoRoot (child-repo
paths are repo-root-relative, not cwd-relative); fs.read route threads
selectedRepoOf into resolveGitPath so the host resolves the right base.
#3 GitView: chooseRepo handler mirrors chooseWorktree — clears status/
history/log and bumps generation before async refresh, preventing stale
rows from acting on the newly selected repository.
#4 git.ts: repoRoots/repoRoot compare roots via pathIdentity() (platform-
aware) instead of raw includes(), fixing win32 forward/backslash
mismatch that silently fell back to roots[0].
#5 markdown-images: mask fenced code blocks and inline code spans before
rewriting; only rewrite reference definitions whose label is actually
referenced by image syntax (not plain links). +3 tests.
#6 package.json: downgrade unrun ^0.3.1 → ^0.2.39 (0.3.x requires Node
^22.13, incompatible with declared engines >=20).
#7 market-manifest.spec: shell:true on win32 so execFileSync resolves the
pnpm .cmd shim.
#8 smoke.spec: build html-route URL via encodeHtmlUrl() (production
encoder) so the Windows drive separator is correct.
#9 index.ts git.worktrees route: thread selectedRepoOf so a workspace
container's selected child repo's linked worktrees appear.
The Git panel only ran git status against the session's own worktree,
so when DSH (or any coding agent) created a linked worktree via
'git worktree add' and modified files there, the sidebar's Git panel
stayed empty - no changed files, no diff, nothing to commit.
Enumerate all linked checkouts of the session repository and let the
user select which one the panel targets. Auto-select the dirty linked
worktree when the primary checkout is clean and exactly one linked
worktree has changes (the common DSH agent pattern). Poll status every
2s while the panel is visible so model-authored edits appear without
a manual refresh.
Security: resolveWorktree validates the client-supplied worktree path
against 'git worktree list' before using it as a git -C cwd. Uses -z
porcelain framing, which disables core.quotePath C-style quoting so
non-ASCII checkout paths round-trip losslessly.
Host half (src/index.ts): /sidebar/api JSON API (session cwd, fs tree/read/
write, git status/diff/stage/commit/branch/log/show), /sidebar/file media
route, /sidebar/ws/terminal WebSocket over node-pty; routes share the /api
trust fence (Host-header loopback or connection.trustedHosts).
Client half (src/client): portal-mounted right panel with a per-session
split-pane workbench (recursive row/col splits, draggable dividers, tab
drag-move), tab bar with max-width 160px + plus-menu (explorer/git/terminal
multi-open rules), lazy file explorer rooted at the session cwd, editable
text editor (dirty dot, Ctrl/Cmd+S), image + Markdown preview, xterm
terminal with reconnect, and a VSCode-style git panel. Per-session state
persists to localStorage (dsh-sidebar:v1:<sessionId>). Intercepts the chat
turn-tail produced-files row (priority -1 chain entry) to open files in the
sidebar. UI styled with the dsh --dsw-* theme tokens and ui-primitives.
Build: tsdown emits the host lib plus the __ModuleLoader__ client bundle
(externals = module table words; xterm/css inlined). Tests: 19 unit + smoke
specs (pure state/tree/git parsers + real git/fs integration).