Repository navigation
Loads and tests say where they stand: Load<T> for diffs and threads, TestRun, coalesced GitHub syncs - #283
Merged
Conversation
…TestRun, coalesced GitHub syncs - `Load<T>` (HeedCore): idle, loading(token, stale), loaded, failed(why, stale). A result, failure or give-up is applied only when its token is the current load's, so a replaced fetch finishing late changes nothing. - Diff overlay: one `diffLoad`. A cancelled load's `defer` no longer clears "loading" while the next one runs. - Threads: `threads: [key: Load<ThreadConversation>]` replaces the three maps. A retry shows "loading", not the previous error. A summary awaits the reader's fetch in flight instead of polling every 200 ms. - `TestRun<Answer>` (running, passed, failed) for Settings' agent and decision tests; one `runAgentTest` behind both Test buttons, the Model calls one also keeping its result between launches as before. - `SyncQueue`: an ask to sync while one runs is kept and merged (named parts, schedule, force) and runs after it, instead of being dropped by `guard !syncing`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mpdreamz
added a commit
that referenced
this pull request
Nov 16, 2026
…is one question (#285) Part 2 of fix/explicit-states (code-health plan, PR 12). Merges on its own; independent of #283. - **`DialogStack<Kind, Dialog>`** (HeedCore/Keys): the dialogs open over the window, oldest first, at most one of each kind. Setting a kind changes it in place, nil closes only that kind. - **`AppModel.dialogs`** holds one `Modal` per open dialog. It replaces sixteen optionals: startWork, resume, firstRun, nudge, confirmation, importPicker, taskPicker, hostsPicker, hostRootsChooser, linkPicker, runReader, pilotExplain, awaySummary, repoSetup, pathImport and addRepoDialog. Each keeps its accessor with the same access level, so call sites and views did not change. `resume`'s and `startWork`'s `didSet` behaviour moved into their setters. - **It is a stack, not one slot.** The app layers dialogs on purpose: the trust confirmation over Start work, the task and link pickers over Start work. Which open dialog takes a key is still `handleKey`'s fixed order, unchanged. - **The click guards read one answer, `dialogOpen`** (any dialog, or the tutor's picker). `clickedPane` only checked startWork, resume, firstRun and nudge, so a click on a terminal under a y/n confirmation entered INSERT. The same happened under any picker, the run reader or the pilot explainer. `clicksReachLists` also missed taskPicker, hostsPicker, hostRootsChooser, linkPicker, runReader and pilotExplain. - **`StartWorkSession`** (HeedCore/StartWork): `form`, `presentation` (window or standalone) and `phase` (`editing`, `awaitingTrust(id)`, `launching`, `failed(why)`). It replaces `startWorkStandalone`, `startingWork` and `startWorkError`, which are now computed from it. A trust answer for a start that is no longer waiting starts nothing. - **Stuck "Starting…" fixed.** `begin` set `startingWork = true` and waited on the trust confirmation's answer. When another `ask` replaced that confirmation, neither its action nor `onCancel` ran, and Start work stayed on "Starting…" until relaunch. `ask` now counts a replaced confirmation as cancelled and runs its `onCancel`. The other two `onCancel`s (reopen a shell, drop an Attention draft) are clean-ups, which also belong on replacement. - **One small difference:** a new start now clears the previous start's error, where before it stayed on screen during the next start. Not folded in: `goals.form`, `sourceForm` and `swarmForm` stay on `GoalsBrowser`, a separate observable. They are only open in Goals, which has no terminals, and the goal page's own clicks check `clicksReachLists`. `overlay` (help, diff, PR, approvals) stays its own enum, because clicks in the diff overlay must reach it. ## Verification - `mise run fmt` is clean. `mise run lint`: swiftformat is clean. swiftlint's only errors were the two GhosttyRuntime statics, which main fixed in #284 and which this branch is now rebased onto. It was rebuilt after the rebase. - `swift test`: 2577 tests passed. The rebase onto #284 changed only GhosttyRuntime, so the suite was not rerun after it. - `mise run tutor-check`, run as `scripts/bundle.sh debug` plus `scripts/tutor-check.sh` because the release build would not finish in reasonable time on this loaded machine, played every lesson with real keys: `tutor-check: 0 problems`. - New tests in `Tests/HeedCoreTests/DialogStateTests.swift`: one per kind, closing one leaves the others; a trust answer for another start is ignored; a failed start can try again; a second ⌘↩ while waiting does nothing. - Mutations, applied and then reverted, each fail the new tests: `DialogStack.set` appending a duplicate instead of replacing fails 6 expectations; `trustAnswered` without the id check fails 2. ## Not tested - The mouse guards were not clicked through in a running app. `clickedPane` and `clicksReachLists` are one-liners over `dialogOpen`. - The replaced-confirmation path to Start work was not driven end to end. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Mpdreamz
added a commit
that referenced
this pull request
Nov 16, 2026
…ent, resume checks, wizard discard, promotion (#287) Part 3 of fix/explicit-states (code-health plan, PR 12), after #283 and #285. Branched from main with both merged. - **Hunch training:** `HunchTrainingRun` (`idle`, `starting`, `running(fraction)`, `stopping`) replaces `training: Double??`. The `training` getter keeps the pane and `HunchStatus` as they were. - Stop never reached the run before. `stopTraining` cancelled `trainTask`, but the work runs in a `Task.detached` that never sees that cancellation. Stop is now passed on with `withTaskCancellationHandler`. - The runtime checks for cancellation before it adopts a head, and puts the head in use back if it was stopped. - A run asked to stop records nothing and deletes its new head, even when it finishes anyway. - Progress reported late (after a stop, or after the run ended) is ignored. - The app asks `run.isActive` instead of looking at `trainTask`. - **Define with an agent:** `AgentConversation` (HeedCore/ACP) holds `id`, `phase` (`connecting`, `ready(session)`, `turn(session, buffer)`, `failed`), `client`, `root` and `paths`. It replaces five fields each on WizardBrowser and PersonaLibraryBrowser. - The goal's-part flow and the persona flow now share one helper, `AppModel+AgentConversation.swift`, where each had its own copy. - Events, replies and failures are applied only while their conversation id is still the slot's. The goal flow used to check neither the client's identity nor the id. - A conversation closed while it was connecting gets its client closed: either the close does it, or the client finds itself detached and closes itself. - **Resume offer:** `ConversationChecks` (`unknown`, `checking(generation, last)`, `present`, `missing`) replaces `conversationOnDisk: [String: Bool]`. - A check that reports after a newer one began is ignored, so an older answer can no longer overwrite a newer one. - Unknown still means no offer. A recheck keeps the last answer until it reports, as before. - `ResumeBanner.offer(..., conversation:)` takes the check. - Expect a one-line conflict with fix/hook-path in `receive`: `.agentSession` now calls `conversationChecks.forget`. - **Wizard discard:** - The confirmation passes what it said it would do. `GoalOps.discard(goal:expecting:now:)` throws `discardChanged` and changes nothing when the store would now do the other, so a dialog that said Archive never deletes. - `WizardActivity` (`idle`, `thinking(id)`, `discarding`) cancels a running plan turn on discard. A turn whose reply arrives after that writes nothing to the goal, both on arrival and after the plan save it awaits. - **Promotion:** `PromotionFlow` holds the popover's promotion and its handoff ask in one value. - There is no ask without a promotion, and none for another session. - `goalPromotion` and `promotionHandoff` are now accessors on it. - `HandoffAsk` has an `id`. `deliverHandoffAsk` used to match on the session only; a delivery now lands only on the ask it was sent for, not on a newer ask for the same session. ## Verification - `mise run fmt` is clean. `swiftlint` is clean on the changed files; the full lint ran clean before two closure-position warnings were fixed. - `swift test` passed the whole suite (2586 tests) on the branch before its last rebase. After rebasing onto main with #283 and #285 merged, it builds and the targeted suites pass: 90 tests (the new FlowStateTests plus GoalDiscard, ResumeBanner, SessionHandoff, GoalPromotion and Hunch). The full suite was not rerun after that rebase. - New tests in `Tests/HeedCoreTests/FlowStateTests.swift`, plus one in GoalDiscardTests. They cover: - a stopped run that finishes does not adopt; - late progress is ignored; - a reply for a replaced conversation is dropped; - an older check reporting first or last is ignored; - a delivery for an earlier ask is dropped; - a turn ending after discard is dropped; - a discard that would now do the other is refused. - Mutations, applied and then reverted, each fail the tests: ignore `stopping` in `finish`; drop the generation check; drop the ask-id check; `thought` accepting any turn; drop the id check in `AgentConversation.update`; drop the `expecting` check. The generation mutation first survived; the test was strengthened, and it fails now. ## Not tested - The flows were not driven in a running app: Hunch training with real MLX, ACP define sessions with a real agent, resume checks after a relaunch, the handoff ask to a live agent. Each has its decision logic in HeedCore with tests; the app wiring was reviewed but not exercised. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Part 1 of fix/explicit-states (code-health plan, PR 12): explicit states for fetches and tests. Merges on its own.
Load<T>(HeedCore/Domain/Load.swift):idle,loading(token, stale:),loaded,failed(why, stale:).finish,failandabandonact only when the token is the current load's, so a replaced fetch finishing late changes nothing.diffLoad: Load<DiffContent>replacesdiffFiles,diffCommitsanddiffLoading, which are now computed from it. Before, a cancelled load'sdefer { diffLoading = false }cleared "loading" while the next load was still running. With no worktree, a running load is now cancelled instead of landing afterwards.threads: [key: Load<ThreadConversation>]replacesconversations,conversationErrorsandconversationsLoading. A retry now shows "Loading the thread…" instead of the previous error.currentConversation(summaries) awaits the reader's fetch while it runs, kept inthreadFetches. It used to poll every 200 ms, up to 150 times. Eviction (40 kept) is unchanged.TestRun<Answer>(running,passed,failed) withAgentTestAnswerandDecisionTestAnswerreplaces the app'sLLMTestandDecisionTeststructs. A running test with an answer can no longer be represented.testLLMandtestInferenceshare one function,runAgentTest. Only the Model calls test writessetupTests.inference, as before.SyncQueue:syncGitHubdropped any ask made while a sync ran (guard !syncing), including gr and:github.sync. An ask made during a sync is now kept, merged with any others (named parts united, schedule if either asked, force if either was), and runs when that sync ends. A single ask fetches what it fetched before, and teams are refreshed only by a forced scheduled sync, as before.Verification
mise run fmtandmise run lintare clean.mise run test: 2577 tests. The only failures were 5 issues inSettingsLayoutTests, which this PR does not touch; The settings layout tests expect General's new Appearance section #281 on main has since fixed that test.Tests/HeedCoreTests/LoadTests.swift: a stale finish, failure or give-up is ignored; a retry forgets the error but keeps the value; a test cannot start over a running one; a forced ask during a sync runs after it; asks merge.Loadreplaced byisLoadingfails 4 tests;SyncQueue.askdropping the ask fails 2;TestRun.canStartalways true fails 1.Not tested
🤖 Generated with Claude Code