fix(session): reject ambiguous navigate targets - #900
Conversation
|
PR author is not in the allowed authors list. |
|
@rascal-sl is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
hunk session navigate accepted two selectors at once. A direction such as --next-comment combined with --file, --hunk, or a line silently won, and the absolute target was dropped without a word. The daemon also accepted a hunk or line target with no filePath, which the live terminal cannot resolve. Reject both combinations in the CLI parser and at the broker boundary. Keep the documented precedence where exact line coordinates win over a hunk number on a raw API request, and cover it with a test so the precedence stays explicit. Closes modem-dev#897
0ebb6fb to
c22dd0e
Compare
|
Rebased onto That refactor extracted What remains is only the two gaps issue #897 lists as outstanding:
The documented exact-line precedence is unchanged and still has a test. The diff is down to 5 files and 119 lines. Verification on macOS, bun 1.3.14: Two failures elsewhere are not from this branch.
|
Problem
hunk session navigateaccepted two selectors at once and silently picked one.--next-comment --file src/app.ts --hunk 2, let the direction win and dropped the file and hunk without a word.filePath. It dispatched the command, but the live terminal cannot resolve an absolute target without the file that owns it.Approach
Reject both combinations where each surface already validates, rather than adding a new validation layer.
src/app/cli.ts: the existing conflicting-selector guard now also covers a direction combined with--file,--hunk,--old-line, or--new-line, and reuses the existing error text.src/session/broker/brokerServer.ts: the existingnavigateguard now rejects a direction combined with an absolute target, and requiresfilePathfor a hunk or line target.Non-goals. The terminal bridge stays a pass-through adapter and is untouched. I left
protocolSchemas.tsalone on purpose: the schema validates wire shape, and the acceptance criteria ask for CLI and broker validation. I did try the cross-field check in the schema first, and moved it out because it duplicated a guard the broker already owned.Exact-line precedence is preserved. A raw API request carrying
filePath,hunkNumber,sideandlinestill prefers the line, and there is now a test pinning that.Tests
Added regression tests for accepted and rejected combinations:
src/app/cli.test.ts: both directions against five absolute-target combinationssrc/session/broker/brokerServer.helpers.test.ts: direction plus target, hunk and line withoutfilePath, and the exact-line precedence caseEach new rejection test was confirmed to fail without its fix:
Commands run
One note on honesty. An earlier full run showed
filesystem watch observer > observes an ordinary file write after readinessfailing at about 3s. It passed on the next run with no change in between, so it looks timing dependent on this machine. It touches no navigation code.Platform: macOS, Node 24, bun 1.3.14. Not tested on Linux or Windows.
bun installneeded--ignore-scriptshere because thesimple-git-hookspostinstall exits 1 on this machine. No lockfile change is included.Changeset
patchtargetinghunkdiff.