Skip to content

Present the new-session sheet instantly; load branches behind it - #450

Merged
jamesrochabrun merged 1 commit into
mainfrom
fix-slow-new-session-sheet
Aug 13, 2026
Merged

Present the new-session sheet instantly; load branches behind it#450
jamesrochabrun merged 1 commit into
mainfrom
fix-slow-new-session-sheet

Conversation

@jamesrochabrun

Copy link
Copy Markdown
Owner

Problem

Users reported the start-thread sheet (sidebar pencil button) taking seconds to appear. Presentation was blocked on await loadBranches(), whose fetchAndGetDefaultRemoteBaseBranch runs a network git fetch --all — multi-second on slow networks and worst-case a DNS/connect timeout per unreachable remote. The Fork flow had the same await-before-present pattern.

Fix

  • preselectRepository is now synchronous (repository match only). The pencil flow presents the sheet immediately and calls the new beginBranchLoad(), which sets isLoadingBranches/isLoadingCurrentBranch synchronously (no empty-picker flash on the first frame) and runs loadBranches() behind the sheet's existing loading state.
  • configureForFork is synchronous too, seeding the form first and loading branches with the new applyDefaultBaseBranch: false mode — the late fetch fills the picker but can no longer overwrite fork's deliberate baseBranch = nil (base = current HEAD) or the seeded branch name.
  • loadBranches is generation-guarded: if the user switches repositories while a slow fetch is in flight, the superseded load discards its results instead of stomping the newer repo's state.

Note: in worktree mode, launching before the fetch settles now bases the worktree on current HEAD (the picker shows "Loading…" during that window). Previously that window was spent staring at a frozen click before the sheet appeared.

Test-infra repairs (found while validating)

The app-target test bundle (app/AgentHubTests) had rotted unnoticed — nothing gates it headless:

  • The shared AgentHub scheme had no testables, so xcodebuild … -scheme AgentHub test (the command in CLAUDE.md) errored. Added the AgentHubTests testable reference.
  • Restored missing AgentHubSessionGraph / AgentHubCLIKit imports in five test files that no longer compiled.
  • Heads-up: running these app-hosted tests headless additionally needs ad-hoc signing overrides (CODE_SIGN_IDENTITY=- CODE_SIGN_STYLE=Manual DEVELOPMENT_TEAM=) because the homebrew libgit2 dylib's Team ID doesn't match a dev-signed test host.

Testing

  • New MultiSessionLaunchBranchLoadTests (headless core gate) pin the contract: fork seeds synchronously, the load preserves the seeded base, and the default flow still applies a base branch. 2/2 passed.
  • Targeted package suites (preselection/resolver/context/prompt): 23/23 passed.
  • App-target suites (fork, manual naming, AI naming, reset) with the signing override: 21/21 passed.
  • Full gate ./scripts/test.sh: all fast packages ✓; the AgentHubCore suite reported failures only in the documented timing-flaky families (DiffAvailabilityService, SessionNameRequestMonitor, WorktreeDeletionRequestMonitor, WorktreeLaunchRequestMonitor, GitHubCIFailureNotifier, workspace-attach suites — see TestQuarantine.md/Re-enable 18 quarantined AgentHubCore tests (headless failures + hangs) #380), none intersecting this diff.

🤖 Generated with Claude Code

The sidebar pencil button (and Fork) blocked sheet presentation on
loadBranches(), whose fetchAndGetDefaultRemoteBaseBranch runs a network
git fetch --all — multi-second on slow networks or unreachable remotes.

- preselectRepository is now synchronous (repo match only); the sheet
  presents immediately and beginBranchLoad() runs git behind the
  sheet's existing isLoadingBranches spinner, setting the loading flags
  synchronously so the first frame never flashes an empty picker.
- configureForFork is synchronous too, and loads branches with
  applyDefaultBaseBranch: false so the late fetch fills the picker but
  cannot overwrite fork's deliberate baseBranch = nil (current HEAD).
- loadBranches is generation-guarded: switching repositories while a
  slow fetch is in flight discards the superseded load's results.
- New MultiSessionLaunchBranchLoadTests pin the contract in the
  headless core gate.

Also repairs the app-target test bundle, which had rotted unnoticed
(nothing gates it): adds the AgentHubTests testable to the shared
AgentHub scheme so xcodebuild test works headless, and restores
missing AgentHubSessionGraph/AgentHubCLIKit imports in five test files.
@jamesrochabrun
jamesrochabrun merged commit a815d3e into main Aug 13, 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.

1 participant