Skip to content

fix(web): always run a repo-backed editor on a thread (#6667 follow-up) - #6680

Merged
guitavano merged 1 commit into
mainfrom
guitavano/no-branch-selected
Aug 28, 2026
Merged

fix(web): always run a repo-backed editor on a thread (#6667 follow-up)#6680
guitavano merged 1 commit into
mainfrom
guitavano/no-branch-selected

Conversation

@guitavano

@guitavano guitavano commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

After #6667 started addressing destinations by path, a repo-backed agent editor could open with no thread in the URL (?thread= absent — a deep link, choose-editor, or any navigation that didn't carry it, since the shell deliberately doesn't retain thread across navigations).

The branch is a thread field (activeTask.branch), so a threadless editor left the branch picker stranded on "Select branch…", with both selecting a branch and New silently doing nothing (setCurrentTaskBranch is gated on an active thread), and the adopt / auto-fresh-stale effects never firing.

AgentInsetProvider now guarantees a thread for repo-backed agents: when the URL names none it mints one into ?thread= before mounting, reusing the user's idle empty "New chat" for that agent when one exists — exactly what useNavigateToAgent does (findReusableNewChat ?? fresh id). This restores the pre-#6667 behavior where the client minted the thread id and the ensure-fallback created the row on landing.

Scoped to repo-backed agents on purpose — the Super Agent (no repo, no branch pill) keeps its lazy threadless empty composer that #6667 designed.

Why it happens

  • resolveRouteThreadId returns null on a destination with no ?thread=currentBranch = activeTask?.branch ?? null → picker falls back to "Select branch…".
  • setCurrentTaskBranch is if (effectiveTaskId) … → no-op without a thread → selecting/New do nothing.
  • VmEventsBridge's adopt-branch and auto-fresh-stale both require activeTask, so neither runs.

Relationship to #6639

Complementary, not conflicting (same file, different function — AgentInsetProvider vs VmEventsBridge; #6639 is already an ancestor). With a thread guaranteed, adopt mints a fresh unmaterialized (non-stale) branch and #6639's auto-fresh-stale check evaluates correctly instead of sitting dead on a threadless entry. No double-switch: isBranchStale(null) is false and both effects are one-shot per thread/tab.

Testing

  • bun run --cwd=apps/web check
  • bun run lint
  • bun run fmt
  • unit: thread-route.test.ts + use-layout-state.test.ts → 57 pass / 0 fail

Not yet added: an e2e that enters a repo-backed destination without ?thread= and asserts the URL gains ?thread= + a real branch (reusing an idle empty chat when present). Happy to add if wanted.

🤖 Generated with Claude Code


Summary by cubic

Fixes repo-backed agent editors opening without a thread in the URL, which stranded the branch picker on “Select branch…” and made selecting a branch or New silently do nothing. AgentInsetProvider now guarantees a thread before mounting by minting ?thread= into the URL, reusing the user’s idle empty chat for that agent when one exists. Scoped to repo-backed agents, the Super Agent keeps its lazy threadless composer.

Written for commit 50380be. Summary will update on new commits.

Review in cubic

After #6667 started addressing destinations by path, a repo-backed agent
editor could open with no thread in the URL (`?thread=` absent — a deep
link, choose-editor, or any navigation that didn't carry it, since the
shell deliberately doesn't retain `thread`). The branch is a thread field,
so a threadless editor stranded the branch picker on "Select branch…" with
selecting and "New" both silently no-op (setCurrentTaskBranch is gated on
an active thread), and the adopt/auto-fresh effects never fired.

AgentInsetProvider now guarantees a thread for repo-backed agents: when the
URL names none it mints one into `?thread=` before mounting, reusing the
user's idle empty "New chat" for that agent when one exists — exactly what
useNavigateToAgent does (findReusableNewChat ?? fresh id). This restores the
pre-#6667 behavior where the client minted the thread id and the ensure
fallback created the row on landing. Scoped to repo-backed agents; the Super
Agent keeps its lazy threadless composer.

Complements #6639: with a thread guaranteed, adopt-branch mints a fresh
(unmaterialized, non-stale) branch and the auto-fresh-stale check evaluates
correctly instead of sitting dead on a threadless entry.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the claude PR authored by a coding agent label Aug 28, 2026
@guitavano
guitavano merged commit dd65cc8 into main Aug 28, 2026
34 checks passed
@guitavano
guitavano deleted the guitavano/no-branch-selected branch August 28, 2026 13:52
decocms Bot pushed a commit that referenced this pull request Aug 28, 2026
PR: #6680 fix(web): always run a repo-backed editor on a thread (#6667 follow-up)
Bump type: patch

- decocms (apps/api/package.json): 4.291.3 -> 4.291.4
- @decocms/native (apps/native/package.json): 4.291.3 -> 4.291.4

Deploy-Scope: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant