Skip to content

Fail fast when a walkthrough file has unresolved hunk ids - #187

Merged
cpojer merged 4 commits into
nkzw-tech:mainfrom
matchai:validate-walkthrough-file
Oct 26, 2026
Merged

cpojer merged 4 commits into
nkzw-tech:mainfrom
matchai:validate-walkthrough-file

Conversation

@matchai

@matchai matchai commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

codiff -w --walkthrough-file exits 0 even when the app can't apply the walkthrough, because the app opens detached. The app also silently drops any stop with an unresolved hunk id, so a single bad id loses that stop with no error. Agents then report the walkthrough as open when it isn't. A common cause is zsh, where an unbraced "$sha:h1" applies the :h modifier and produces .1.

The app now checks a CLI launch's walkthrough file against the diff before opening a window. A file that can't be applied opens nothing, and the CLI exits 1 with the reason:

$ codiff -w --walkthrough-file walkthrough.json HEAD
Walkthrough file could not be applied to this diff: Unresolved hunk ids: src/app.ts:.1. This diff's hunk ids: src/app.ts:f784…:h1, …
$ echo $?
1
 bin/codiff-app / bin/codiff.js
+  --walkthrough-result-file <tmp>
   open Codiff (detached)
+  wait for ready | unavailable (reason)            # exit 1 on unavailable
 app ready / second-instance
+  openLaunchWindow
+    read repository state
+    assertWalkthroughHunkIdsResolve()             # write ready | unavailable + reason
+    focusOrCreateWindow(…, state)                 # only when it can be applied

The window reuses the state the check read for its first diff view. --share runs the same id check before uploading. The skill no longer claims Codiff repairs drifted anchors, and the guide documents the exit code and the zsh trap.

Merge danger: two-way door, CLI launches with -w --walkthrough-file. A file that used to open with stops missing now opens nothing and fails the command.

This PR was written primarily with fx, a coding agent. I reviewed the change; the agent diagnosed the failure, wrote the fix and tests, and verified it against real walkthrough files.

banana banana banana

codiff -w --walkthrough-file exited 0 even when the app could not apply the walkthrough, and the app silently dropped any stop with an unresolved hunk id. The app now checks a CLI launch's walkthrough file against the diff before opening a window, opens nothing when it cannot be applied, and reports the outcome through a result file that both launchers wait on. --share runs the same check, and the skill and guide describe the new behavior.
The packaged launcher read the JSON result with plutil, which only exists on macOS, so the reason was lost on Linux CI. A status line followed by the reason needs only head and tail.
The app checks the walkthrough file at launch whether or not -w is set, so the launchers wait whenever a walkthrough file is given.
codiff-app runs with set -e, so reading the result file before the app wrote it ended the launcher with exit 1 and no message. Check that the file has content first, as the plan loop does, and test a result that arrives after the launcher starts waiting.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'll take it from here.

@cpojer
cpojer marked this pull request as ready for review October 26, 2026 05:03
@cpojer
cpojer merged commit 17d2f87 into nkzw-tech:main Oct 26, 2026
1 check passed
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.

2 participants