Skip to content

fix(band): start the definitions grep without holding session.start - #1404

Open
trevjonez wants to merge 1 commit into
DietrichGebert:mainfrom
trevjonez:fix/band-session-start-git-grep
Open

trevjonez wants to merge 1 commit into
DietrichGebert:mainfrom
trevjonez:fix/band-session-start-git-grep

Conversation

@trevjonez

Copy link
Copy Markdown

Problem

The band's session.start handler awaited a repo-wide git grep --untracked -nE <defs> before it called next(). session.start holds the SDK's initialize reply until it settles, so in a large repo every session start waited for the grep. ACP clients such as JetBrains Air drop a launch that has not answered within 5 s, so new sessions failed or came close.

Measured in a large Android repo (~540 KB of git grep output):

initialize reply ponytail session.start
main 4.8 s 3027 ms
this branch 2.0 s 23 ms

The grep still completes in the background (exit 0, about 2.9 s after start).

Change

Only the Edit/Write reuse metric reads those definitions. start() no longer runs the grep. A new defs() does, and known holds its promise: session.start (and /clear, /resume, /branch) starts it without waiting, and the edit handler awaits it before it counts reused calls.

Test

tests/band.test.tsx gets one test: the grep mock is held until after session.start returns and an Edit is under way. The start must settle, and the edit must still count the reused call once the grep lands. Against the previous register.tsx the start stays held and the test fails.

Checks

  • claude plugin test .: 31 pass, 2 fail. The 2 failures (bodyColumns only in the terminal, details view ... off the terminal) also fail on main here.
  • npm test: 142 pass, 2 fail, both also failing on main here: csv: correct pandas one-liner passes (no pandas installed) and SessionStart preserves instructions when the optional map is blocked (timed out).
  • node scripts/check-rule-copies.js and node scripts/check-versions.js pass.

session.start awaited a repo-wide `git grep --untracked` before it called
next(). In a large repo that grep takes about 3 s, and session.start holds
the SDK's initialize reply until it settles. ACP clients such as JetBrains
Air drop a launch that has not answered within 5 s, so new sessions failed
or came close to it.

Only the Edit/Write reuse metric reads those definitions. `known` is now a
promise: session.start (and /clear, /resume, /branch) starts the grep and
does not wait for it, and the edit handler awaits it before it counts
reused calls.

Measured in a large Android repo (~540 KB of git grep output):
- initialize reply: 4.8 s -> 2.0 s
- ponytail session.start: 3027 ms -> 23 ms
- the grep still completes in the background (exit 0, about 2.9 s later)

A band test holds the grep past session.start and checks that the start
settles and that an edit made meanwhile still counts the reused call once
the grep lands. Against the previous register.tsx the start stays held and
the test fails.
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