Invalidate ACP session when opencode.json has changed - #71
Open
strk-ai-agent wants to merge 2 commits into
Open
Conversation
Previously the bridge copied opencode.json into each per-chat session directory only when the source mtime was strictly newer than the target's. This breaks for git checkouts, restores, and edits that preserve timestamps, leaving the cached snapshot and the running opencode acp child out of sync with the project's opencode.json. Replace the mtime-based copyIfNewer helper with copyIfChanged, which compares SHA-256 of the file contents and refreshes when they differ (or when no snapshot exists yet). copyOpenCodeConfig now returns whether anything was refreshed so callers can react. Also export hasOpenCodeConfigChanged(sessionDir) for callers that need to decide whether to invalidate an existing session before the next message is processed. Assisted-By: MiniMax-M3
A running opencode acp child loads its session-local opencode.json once at startup and never reloads it. After a config change the bridge must therefore drop the existing in-memory client and the persisted ACP session mapping so the next message spawns a fresh child that reads the new file. In BaseConnector.getOrCreateSession, compare the source opencode.json content against the snapshot in the session directory via the new hasOpenCodeConfigChanged helper. On a mismatch, call invalidateACPSession before falling through to the existing create / resume path. The session directory itself is preserved so uploads and user-owned files are not touched. Assisted-By: MiniMax-M3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A running
opencode acpchild loads its session-localopencode.jsononce at startup and never reloads it. After a config change the bridge must therefore drop the existing in-memory client and the persisted ACP session mapping so the next message spawns a fresh child that reads the new file.In
BaseConnector.getOrCreateSession, compare the sourceopencode.jsoncontent against the snapshot in the session directory via the newhasOpenCodeConfigChangedhelper introduced in #PR1. On a mismatch, callinvalidateACPSessionbefore falling through to the existing create / resume path. The session directory itself is preserved so uploads and user-owned files are not touched.Behaviour:
opencode acpchild is spawned with the new config.Depends on #PR1 (the content-hash snapshot helper).
Tests:
bun test tests/unit/connector-base.test.ts tests/unit/session-utils.test.ts— 106 pass, 0 fail.