Skip to content

refactor: simplify sweep across src/ and electron/ - #22

Open
mxrsv wants to merge 8 commits into
mainfrom
refactor/simplify-sweep
Open

mxrsv wants to merge 8 commits into
mainfrom
refactor/simplify-sweep

Conversation

@mxrsv

@mxrsv mxrsv commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Quality-only sweep from /simplify across src/ and electron/. No bug hunting — that is /code-review's job. Four review agents (reuse, simplification, efficiency, altitude) surveyed the tree; the mechanical, behaviour-preserving findings on files no other session held are applied here. 30 files, +213 −343.

What changed

Commit Why it matters
perf(terminal) OSC progress carry incompleteCarry scanned the whole PTY batch (up to 64 KB), allocating a slice at every ESC byte before testing its length. Both patterns are anchored, so a valid candidate is always in the last 24 chars. Hottest path in the app during a fast agent stream.
refactor(files) path splitter baseName written verbatim 3× and inlined 2× more, parentDirectory 2×. Four copies feed user-visible names — one file could be named two ways in two places.
refactor(open-board) workspace name folderName was a second basename that disagreed with workspaceLabel. Carries the one behaviour change (below).
refactor(resume) scanners Symlink guard on files Deck did not write had 4 copies; every transcript was lstat'ed twice per scan. Plus selectCandidate: restore and the rail's session tail must pick the same file, and session-tail.ts said so in its header while hand-copying the whole algorithm, cutoff literal included.
refactor(lib) journal envelope The tab cap and the drop-invalid rule — the two guarantees the module exists for — were written twice.
perf(repositories) tab bucketing O(worktrees² × tabs) longest-prefix work for a question each tab has one answer to.
refactor(ui) tooltip handlers 3 call sites retyped the same 4 handlers, including the onPointerLeave focus guard whose omission is a silent regression.
chore dead exports + CSS 6 exports with zero references tree-wide; 2 of them documented as live seams.

The one behaviour change

folderNameworkspaceLabel in the open board (recents rows, worktree form, the "is missing" notice):

Input Before After
"" "" Unknown
/foo// /foo/ foo
" /foo/bar " "bar " bar

Everything else is intended-identical. The OSC change is backed by a 700k-input differential fuzz against the old implementation, 0 mismatches — not just green tests.

Verification

Run on this branch in an isolated worktree, not the shared checkout:

  • npm run build ✅ · npm run electron:build ✅ · generate:menu:check
  • tsc renderer ✅ · tsc electron ✅
  • npx vitest run3530 passed, 1 failed

The one failure (scripts/ipc-contract.test.ts) plus two .mjs files that fail to load are pre-existing: reproduced identically on a pristine worktree at HEAD. No failure originates here.

Not run: no electron:dev / tauri dev host pass, no owner eye review. Every change is internal — no UI shape, no IPC payload, no R4 seam, no DL rule moved.

npm run lint could not run at alloxlint: command not found in this checkout. Flagging rather than claiming a clean lint.

Reviewer notes

  1. electron/resume/head.ts renders as "Binary file not shown." Pre-existing, not introduced here: fileCacheKey embeds 2 literal NUL bytes as separators, deliberately — "NUL-separated so no path can forge another path's key by ending in digits." It is unfortunately the file with the largest change. Reading it locally is the workaround; switching the literals to a \u0000 escape sequence (behaviour-identical) or adding a .gitattributes entry would fix it, both out of scope here.
  2. refreshExternalApps was deliberately kept despite having no callers — its doc names a call site that was never wired. That is either a missing wire (installing an app mid-session is currently never noticed) or dead code, and it is a product decision rather than a cleanup.
  3. One finding was applied and then reverted: consolidating the __deckHost presence check into bridge.ts broke 3 tests, because each facade computing it independently is what lets worktree-host.test.ts exercise presence-detection while mocking bridge. That duplication is load-bearing for testability.

Further findings the agents raised but this PR does not touch — files held by concurrent sessions, R4 seams, or fork-listed areas — are recorded in the session below.

https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K

mxrsv added 8 commits August 22, 2026 14:14
`incompleteCarry` scanned the whole PTY batch — up to 64 KB — allocating a
`slice` at every ESC byte before testing its length. Both patterns are
anchored `^...$`, so a candidate is always a suffix, and one longer than
`OSC_CARRY_LENGTH` is rejected anyway: a match cannot start before the last
24 characters. Scanning from there is output-identical.

This runs once per PTY batch per pane, and agent TUIs emit hundreds of ESC
bytes per KB, so it is the hottest path in the app during a fast stream.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
`baseName` was written verbatim three times and inlined twice more, and
`parentDirectory` twice. Four of those copies feed user-visible names — the
unsaved-file confirmation, the file-tab chips, the editor header — so a
divergence shows one file under two names in two places.

`src/lib/path-name.ts` is deliberately NOT `workspaceLabel`: that one is
POSIX-only and names a workspace for display; these answer the raw segments
of a file path, honouring both separators.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
`folderName` was a second basename for the paths `workspaceLabel` already
names, and the two disagreed: it neither trimmed nor folded repeated trailing
slashes, so the open board and the agent rail printed different names for the
same folder.

Behaviour change, stated on purpose: an empty path now reads `Unknown` rather
than an empty string — which is the better string for the "is missing" line
that prints it. `/foo//` reads `foo`, and a padded path loses its spaces.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
…lection

Two consolidations into `head.ts`, the module already declared as the home of
the scanners' bounded, symlink-safe reads.

`isRegularFile` was declared in three scanners and `isDirectory` in two, so
the symlink guard on files Deck did not write had four copies. `childDirs`
and `datedFilesIn` replace them, and close a double `lstat`: every transcript
was stat'ed once to prove it was a regular file and again for its mtime and
size. Directory walks now read `d_type` through `withFileTypes`, with an
`lstat` fallback for filesystems that cannot answer it — same refusal of
symlinks, fewer syscalls per scan.

`selectCandidate` is the second: session restore and the rail's session tail
MUST pick the same file — same 30-day cutoff, same cwd predicate, same
recency ranking, same greedy dedup — and `session-tail.ts` said so in its own
header while hand-copying all of it, cutoff literal included. A correctness
invariant held together by a comment is now one function.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
`validateWindowRecord` and `validateArchiveEntry` repeated the same fourteen
lines: reject a non-object, reject a non-finite `savedAt`, reject a non-array
`tabs`, then cap at `MAX_JOURNAL_TABS` and drop invalid tabs one by one. The
cap and the drop rule are the two guarantees this module exists for, so two
copies is two places for them to diverge invisibly.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
Every worktree re-filtered the whole tab list, and `worktreeForPath` scans
all worktree paths per call — O(worktrees^2 x tabs) longest-prefix work to
answer a question each tab has exactly one answer to. One pass now resolves
each tab's owner once and buckets by it; order within a worktree is
unchanged.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
DL-23.10 widened §23's tooltip to any icon-only chrome control with an
action, and three call sites had each retyped the same four handlers. The
`onPointerLeave` guard is the one that matters: focus outlives the pointer,
so tabbing to a control and then moving the mouse across it must not take
away the description the focus asked for. Dropping it is a silent regression,
which is why it should not be retyped per call site.

`tooltipTriggerProps` spreads after `feature-toolbar`'s own `expansion`
bundle, which carries only ARIA attributes — no handler is overridden.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
Six exports had no reference anywhere in src/, electron/, scripts/,
src-tauri/, marketing/, the tests or the gallery. Two of them actively
misled: `stripFileTabsFor" was documented as "used by both chrome layouts so
a single-layout change cannot half-land" and is a pass-through with no
callers, and `resetMonacoLoaderForTests` is documented "Tests only" while no
test calls it — a seam a future test author would have trusted.

Gone: `expandDirectory`, `collapseDirectory`, `stripFileTabsFor`,
`isMonacoLoaded`, `resetMonacoLoaderForTests`, `resetExternalApps`. Kept on
purpose: `refreshExternalApps`, whose doc names a call site that was never
wired — that is a missing wire or dead code, and the answer is a decision,
not a cleanup.

`.metric-table__scroll`'s scrollbar size and track were byte-identical to the
base layer in `01-tokens.css`, whose own comment asks not to be re-declared.
The thumb stays: an always-visible bar on a horizontally scrolling table is a
legitimate override of the base layer's reveal-on-hover.

Claude-Session: https://claude.ai/code/session_01CotP5z7c3zry3YLbyjYE5K
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spacevibe-deck Ready Ready Preview Aug 22, 2026 7:24am

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 53634820-9f82-486d-851e-02f1b965c45b


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant