fix: architecture review quick wins (settle-once, hub, config lookup, turn-idle grace) - #66
Merged
Merged
Conversation
This was referenced Aug 20, 2026
Merged
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.
Quick-fix batch from the full-codebase architecture review (plus one pending CORS fix). The bigger candidates (SessionRegistry, turn-loop decomposition) are left for separate design passes.
MED+ — interaction settle-once (
server-requests.ts,session.ts)The interaction forward path (
pending.set→ popup → reply) had no try/finally: any throw left the zcode request unanswered forever, leaked the reannounce-dedup entry (its 30s cleanup only arms inside sendInteractionReply), and every ~1s reannounce refreshed the turn loop's no-progress timer — the 120s timeout never fired and the turn could hang indefinitely. Now the forward degrades to a decline reply (zcode always gets exactly one answer, the entry always resolves), and the turn loop wraps handleServerRequests in best-effort containment instead of dying on a throw. Tests:tests/settle-once.test.ts.Hub fixes (
hub-server.ts)X-Zcode-First-LineviaAccess-Control-Expose-Headers— without it the web file viewer cannot read the line-window header cross-origin at all.Config option lookup by id (
dispatch.ts)dispatchConfigChangedwroteoptions[0]/[1]/[2]relying on buildConfigOptions' push order as a hidden contract; a reorder would silently write the wrong option. Now finds byid(matching emitModeViaConfigOption's existing pattern).Turn-idle lock grace (
extensions.ts)waitForTurnIdle(expectLock=true)could spin the full 300s and report a false__lockTimeoutwhen the lock was never observed — a turn finishing between probes, or backend error-message drift away from "prompt is running". A 30s grace (injectable) bounds the lock-watching phase; past it, a successful probe counts as released. Tests:tests/wait-turn-idle.test.ts.Minor
pendingTurnskeyednumber | string(JSON-RPC ids); prompt/preempt signatures widened.Verification
typecheck / lint / full suite: 44 files, 665 tests pass (+2 files, +7 tests).