Skip to content

standalone - #11

Merged
tlgimenes merged 3 commits into
mainfrom
feat/stand-iframe
Apr 9, 2025
Merged

tlgimenes merged 3 commits into
mainfrom
feat/stand-iframe

Conversation

@tlgimenes

Copy link
Copy Markdown
Contributor

No description provided.

@viktormarinho viktormarinho changed the title iframe standalone Apr 8, 2025
@tlgimenes
tlgimenes force-pushed the feat/stand-iframe branch 2 times, most recently from a6330a7 to 1f974e1 Compare April 9, 2025 02:21
@tlgimenes
tlgimenes force-pushed the feat/stand-iframe branch from 1f974e1 to a62219b Compare April 9, 2025 03:06
@tlgimenes
tlgimenes merged commit ceb1cd8 into main Apr 9, 2025
tlgimenes added a commit that referenced this pull request Apr 22, 2026
Two fixes to branch-status computation that surfaced during E2E testing:

1. Setup previously did `git fetch origin BRANCH:BRANCH` which creates a
   local branch but not the refs/remotes/origin/<branch> remote-tracking ref.
   Without that ref, `git rev-list origin/base...origin/branch` fails and
   aheadOfBase/behindBase silently stay at 0 — so the selector never
   transitions to Create PR / Merge / etc.

   Adds a `+refs/heads/BRANCH:refs/remotes/origin/BRANCH` fetch before the
   existing one, so the remote-tracking ref is always present when the
   branch exists on origin.

2. computeBranchStatus() now falls back to HEAD on the "branch" side when
   origin/<branch> is missing (new local-only branch), and skips the
   rev-list when origin/<base> is absent. Guards the branch-status event
   against ever emitting nonsense.

Verified end-to-end on deco/misty-spruce + PR #11: branch-status now
reports { workingTreeDirty:false, unpushed:0, aheadOfBase:1, behindBase:0 }
and the header renders "Squash & merge".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
tlgimenes added a commit that referenced this pull request Apr 23, 2026
Two fixes to branch-status computation that surfaced during E2E testing:

1. Setup previously did `git fetch origin BRANCH:BRANCH` which creates a
   local branch but not the refs/remotes/origin/<branch> remote-tracking ref.
   Without that ref, `git rev-list origin/base...origin/branch` fails and
   aheadOfBase/behindBase silently stay at 0 — so the selector never
   transitions to Create PR / Merge / etc.

   Adds a `+refs/heads/BRANCH:refs/remotes/origin/BRANCH` fetch before the
   existing one, so the remote-tracking ref is always present when the
   branch exists on origin.

2. computeBranchStatus() now falls back to HEAD on the "branch" side when
   origin/<branch> is missing (new local-only branch), and skips the
   rev-list when origin/<base> is absent. Guards the branch-status event
   against ever emitting nonsense.

Verified end-to-end on deco/misty-spruce + PR #11: branch-status now
reports { workingTreeDirty:false, unpushed:0, aheadOfBase:1, behindBase:0 }
and the header renders "Squash & merge".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
tlgimenes added a commit that referenced this pull request Apr 23, 2026
github-mcp-server consolidated several per-action tools into a single
`pull_request_read` dispatched by a `method` arg. The old tool names
(`get_pull_request_files`, `list_check_runs`, `get_pull_request`,
`get_issue_comments`) are no longer exposed — calls return
`MCP error -32602: Tool not found` and our select() fell back to empty
results, silently hiding real data.

Observable fallout:
- PR sub-tabs showed "Changes 0" even when files existed.
- HeaderActions saw empty check/review data and always fell through to
  "Publish" regardless of actual CI/draft/approval state.

Changes:
- usePrFiles, useChecks, usePrComments → pull_request_read with the
  matching method ("get_files"/"get_check_runs"/"get_comments").
- usePrReviews → pull_request_read with method:"get".
- All args switched to camelCase (pullNumber, perPage).
- useChecks signature: headSha → prNumber (the new tool takes the PR
  number, not the commit SHA). ChecksTab and HeaderActions updated.
- usePrFiles derives `deletions` from `changes - additions` since the
  new response shape only includes `changes`.

Verified in-browser: "Changes 1" shown for PR #11 with the single
bun.lock file.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
tlgimenes added a commit that referenced this pull request Apr 23, 2026
…ast a merged PR

Previous fix short-circuited merged PRs to null regardless of whether
new commits had been pushed after the merge — too blunt. Now:

1. Daemon adds `headSha` (current HEAD sha of origin/<branch>) to the
   branch-status SSE payload.
2. BranchStatus type + parser carry it through.
3. Selector compares branchStatus.headSha against pr.headSha when
   pr.merged is true:
   - Same sha → null (branch is exactly where it was merged — done)
   - Different sha → "Submit for review" (branch advanced post-merge;
     propose a new PR for the new work)

This covers the flow: user merges PR #11, then pushes a new commit to
the same branch to make a follow-up change — the button now re-appears
as expected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
tlgimenes added a commit that referenced this pull request Apr 23, 2026
…3138)

* feat(db): add nullable branch column to threads

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): add branch field to Thread type and storage

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): accept branch in create/update tool schemas

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(sdk): add vmMap to virtualmcp metadata schema

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): vmMap read/write helpers + tests

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): VM_START accepts branch and wires daemon + vmMap

- Adds optional branch input to VM_START
- Daemon receives injectedBranch, attaches to origin/<branch> if it exists
  on the remote; otherwise creates a new local branch
- Domain key includes branch (when provided) so different branches for the
  same user get distinct preview domains
- After vm creation, writes vmMap[userId][branch] = vmId
- Lookup prefers vmMap[userId][branch] when branch is injected, falling back
  to activeVms for branch-unaware callers

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(stream): plumb branch through decopilot stream endpoint

StreamRequestSchema accepts optional branch. Routes pass it to streamCore.
createMemory persists it on the thread when the thread is created for the
first time; existing threads keep their branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): BranchPicker in virtualmcp header for github-linked vms

Reads available branches from vmMap (yours) + github-mcp-server.list_branches
(others). "+ New branch" sub-form invokes create_branch synchronously.
Selected branch is stored in ?branch=... URL param, injected into message
metadata on sendMessage so the server persists it on first-message thread
creation and forwards to VM_START.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): parse list_branches content[0].text fallback

github-mcp-server returns branches as a stringified JSON in content[0].text
rather than structuredContent. Accept both shapes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): git tab replaces Instructions for github-linked vms (MVP)

- New "git" tab with git-branch icon when metadata.githubRepo is set
- GitTab renders 3 states: no branch, no PR yet, PR open, PR merged/closed
- Primary actions (Create PR / Squash & merge / Rebase / Close) call
  sendMessage with natural-language templates; LLM executes via its
  github tools
- PR data fetched via useMCPToolCallQuery (list_pull_requests, 60s poll)
- Parses both structuredContent and content[0].text tool-result shapes
- Instructions tab preserved for non-github vms — zero regression

Scoped MVP: single view, no sub-tabs (Changes/Checks/Comments deferred),
no header action buttons (buttons render inside the tab for now).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): git tab uses ChatBridgeCtx (not ActiveTaskProvider-scoped context)

MainPanelContent renders as a SIBLING of ActiveTaskProvider inside
ChatMainPanelGroup, so useChatStream/useOptionalChatStream return null
there. Switch GitTab to useChatBridge and extend ChatBridgeValue to
expose isStreaming so action buttons still disable during a turn.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): include owner/repo in button message templates

Agent was asking clarifying questions because prompts didn't specify the
repo. Each template now leads with "On repo `owner/repo`, …" so the
agent can act immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): route history-rewriting ops through BASH + git CLI in templates

GitHub MCP tools like update_pull_request_branch perform merge-of-base
rather than true rebase, so rebase/resolve-conflicts/create-PR templates
now instruct the agent to use the BASH tool with git in the vm's working
tree. PR-level ops (close, reopen, merge) keep using GitHub MCP tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): preserve branch + main tab on task switch and new-task

Creating a new task from the tasks panel previously dropped ?branch and
?main URL params, forcing the user to re-select the branch and re-open
the git tab. Preserve both so the new thread inherits the prior state.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): ChatBridgeCtx stores the ref, not its snapshot

useChatBridge previously returned bridgeRef.current captured at
ChatContextProvider's first render — always BRIDGE_NOOP when a consumer
rendered before ActiveTaskProvider registered the real sendMessage.

Now the context holds the RefObject and useChatBridge returns wrappers
that read .current at call time. Consumers get the latest sendMessage /
isStreaming even when the bridge is registered later.

Fixes GitTab buttons silently no-op'ing on a fresh task page load.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): decode-html-entities util for PR title/body rendering

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): render PR title/body as markdown with entity decode

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): panel-state derivation helper for PR panel

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): MergeSplitButton with dropdown of merge strategies

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): HeaderActions state-dependent thread-header buttons

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): mount HeaderActions in thread header

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): remove inline PR action buttons (moved to header)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): extract tool-json helper for shared use across PR hooks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrFiles hook for PR Changes sub-tab

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): useChecks hook + headSha on PrSummary

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrComments hook for issue-level PR comments

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): CommentsAccordion component

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): DescriptionTab component with comments accordion

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChangesTab component with file list

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChecksTab component with per-check Re-run

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): PrSubTabs wrapper for Description/Changes/Checks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): GitTab State C renders Description / Changes / Checks sub-tabs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(decopilot): inject repo-environment system prompt when virtual MCP has a GitHub repo

Add buildRepoEnvironmentPrompt that hints the model it is running inside a
checked-out repository, so it prefers the filesystem/shell tools over guessing
when the user asks about code. Gated on virtualMcp.metadata.githubRepo — the
same signal that wires up the bash/read/grep/glob tool suite — so prompt and
tool availability stay in sync. Re-export GithubRepo from @decocms/mesh-sdk
root so the decopilot route can type the metadata cast.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(knip): remove unused exports

Drop removeVmMapEntry, resolveConflicts, fixErrors, and rerunChecks —
flagged by knip and with no call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm): clone injected branch directly with -b

A plain --single-branch clone only fetches the remote default branch,
so origin/<injected> did not exist and the subsequent checkout silently
resolved to HEAD of the default branch — the wrong commit. Pass
-b <branch> so the clone targets the intended ref, and validate the
branch name before interpolating it into the shell command.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): coerce main=instructions to git for github-linked vmcps

The header swaps the Instructions tab for a Git tab when the virtual
MCP has an active GitHub repo. Thread hasActiveGithubRepo through tab
resolution so default fallbacks and explicit ?main=instructions URLs
land on "git" instead of a stale Instructions panel, keeping the tab
bar and panel body in sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(mesh-sdk): vmMap entries carry { vmId, previewUrl }

Preparatory change for the VirtualMCP metadata refactor — activeVms is
being folded into vmMap. Breaks downstream callers; subsequent commits
update the mesh app.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): add generateBranchName helper returning decopilot/<adj>-<noun>

Lifts the adjective/noun word lists out of daemon.ts so the orchestrator
decides the branch name and can persist it to vmMap before the daemon
sees it. Prefixes all generated branches with decopilot/ for visual
distinguishability in git listings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): vmMap entries become VmMapEntry { vmId, previewUrl }

Drops the VmMetadata import — types.ts is being removed in a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm): vm-map tests use VmMapEntry fixtures

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): requireVmEntry reads from vmMap[userId][branch]

Takes branch as input; returns VmMapEntry | null from the vmMap helper.
Drops the VmMetadata type dependency ahead of types.ts removal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/daemon): require branch: string, drop generator

Branch is now mandatory and validated at buildDaemonScript() entry. The
adjective/noun generator moved to branch-name.ts one layer up so the
orchestrator — not the sandbox — decides the name and persists it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/start): single-tier vmMap lookup; generate branch on demand

Branch input becomes optional; handler calls generateBranchName() when
absent and returns the resolved value so callers can persist. Drops the
activeVms legacy fallback, the patchActiveVms writes, and terminalUrl
from the output shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/start): rewrite against vmMap + branch generator

Drops activeVms-based fixtures and the terminalUrl-in-output assertions.
Adds a test that asserts generateBranchName() fallback when branch is
omitted.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/stop): require branch; remove from vmMap

VM_DELETE now targets a specific (user, branch) vm via vmMap. Drops the
activeVms legacy path and the patchActiveVms call.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/stop): rewrite against vmMap + branch input

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): delete types.ts; migrate last consumers to vmMap

- stream-core.ts now reads from vmMap[userId][branch] instead of
  activeVms[userId]. When no branch is pinned on the thread there is no
  vm, and the built-in VM tools fall back to QuickJS.
- helpers.test.ts replaces the VmMetadata import with a local alias
  since the type no longer exists.
- types.ts (VmEntry, VmMetadata, patchActiveVms) is gone — all replaced
  by the vmMap helpers + VmMapEntry from mesh-sdk.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/preview): read VM from vmMap[userId][branch]

Uses useChatNavigation().branch as the key. When no branch is pinned on
the thread, previewUrl is null and the empty state renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): read vmMap[userId][branch]; pass branch to VM_START/DELETE

VM_START is called with the current thread branch when known; if the
server generates one (because caller passed no branch) the returned
value is written to the ?branch= URL param so subsequent renders find
the vm via vmMap. VM_DELETE now carries the branch so it targets the
right entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(ui): drop activeVms: {} from virtual-mcp create payload

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-generate decopilot/* branch on thread mount

When a thread opens against a virtualMCP with a GitHub repo connected,
AgentInsetProvider now auto-fills the ?branch= URL param with a fresh
decopilot/<adjective>-<noun> name when one is not already set. This
closes the "Select branch…" gap: every github-linked thread now has a
branch before any VM is started, matching the refactor's intent that we
"always have a branch."

generateBranchName moves from apps/mesh/src/tools/vm/ to apps/mesh/src/shared/
so both the server-side VM_START handler and the client-side shell layout
can import it without the UI pulling in server-only tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): reuse first vmMap branch for user before generating

On thread mount, if ?branch= is missing and the vMCP has a GitHub repo,
prefer the first branch from vmMap[userId] over generating a fresh one.
Only generate when the user has no entries yet. This keeps users on
their existing branch across revisits instead of minting a new name
every time.

Edge case: if the user opened the vMCP, got a generated branch, and
never started a VM (so vmMap stays empty), the next visit will
regenerate. This is accepted — once any VM is started, the branch
sticks for all future visits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-start VM on thread mount for github-linked vMCPs

Fires VM_START as soon as a thread opens on a github-linked vMCP and
the branch has no vmMap entry yet. Closes the "fresh branch on every
visit" loop: once the auto-start registers the vm, the sticky-branch
effect reuses it on subsequent mounts instead of minting a new name.

A ref guard dedupes concurrent effect runs; errors are logged but
non-fatal so the existing "Start Server" button remains a manual
fallback if auto-start fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): derive status from vmMap; transient override for actions

Replaces the useState(existingVm ? "running" : "idle") snapshot with a
derived status computed from vmMap on every render. Auto-start (in the
layout) and manual start/stop now both converge on the same code path:
invalidate vmMap query → refetch → env.tsx re-renders → derivedStatus
reflects the new truth.

User-initiated transitions ("creating", "stopping", "error") ride on a
separate override state that a sync-effect clears once derivedStatus
catches up. The previous "suspended" useEffect becomes redundant —
suspended is now derived from the SSE signal inside the same expression.

vmData is derived too; dropped vmDataRef. The SSE subscription no longer
gates on status === "running" — we subscribe whenever vmData is known,
which keeps suspended detection working without a separate transition.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/daemon): clone default, then fetch-or-create branch locally

The previous `git clone --depth 1 --single-branch -b <branch>` always
failed for newly-generated `decopilot/*` names — the remote has no such
ref. Switch to: plain `git clone --depth 1` (always works, gets default
branch) → `git fetch origin <branch>:<branch>` (silently no-ops when
remote lacks the ref) → `git checkout <branch>` or `git checkout -b
<branch>` depending on whether the fetch populated a local ref.

Now a brand-new thread with an auto-generated branch clones the default
branch, creates `decopilot/<adj>-<noun>` locally off its HEAD, and hands
off to `bun install` / `dev` without any "Remote branch not found"
error. Threads that reopen an existing branch still pick up the remote
commits via fetch.

Drops `--single-branch` because the second fetch may bring in a second
ref. One extra commit of data at most — negligible at --depth 1.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/toolbar): add Toolbar.RightSlot portal for right-aligned actions

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/toolbar): reorder header — toggles after nav, right slot for actions

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): move HeaderActions to right slot, drop BranchPicker from topbar

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): render BranchPicker in SidebarEmptyState for github-linked vMCPs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): add separator before PR actions, drop "..." menu from Create PR state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui/topbar): use matching data-attr specificity so h-5 overrides h-full on vertical separator

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui/topbar): match toolbar separator to Create-PR separator height (data-attr specificity)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/tasks): expose branch on web Task type

* feat(ui/tasks): show task branch in row subtitle, repo as fallback

* feat(ui/tasks): include branch in optimistic task record

* refactor(vm): rename generated branch prefix decopilot/ -> deco/

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/branch-picker): drop New-branch form; picker-only popover

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): add New branch button next to BranchPicker in empty state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/branch-picker): move New button into popover, next to the search input

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): drop vMCP title from top bar — already shown in empty state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): render vMCP avatar+title header above messages in middle panel

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(ui/toolbar): add gap between nav buttons and toggle cluster

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/chat): center agent icon+title in middle-panel header

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/toolbar): tighten gap between nav buttons and toggles (ml-2 → ml-1)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/toolbar): match inter-cluster gap to within-cluster gap (ml-1 → ml-0.5)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/toolbar): use 3-column grid with centered vMCP header

Restructure the toolbar header as a 3-column grid so the center slot stays
screen-centered regardless of left/right content widths. Move the vMCP
icon+title from the chat middle-panel header into the toolbar center slot,
and drop the now-redundant ChatAgentHeader.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add commitAndPush/fixChecks/markReadyForReview/resolveReviewComments templates

New chat-prompt templates for the upcoming single-button HeaderActions.
rerunCheck and closePr stay for now — removed in the HeaderActions rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm/daemon): emit branch-status SSE event on setup/file-change/connect

Computes the VM's git state (working-tree dirty, unpushed, ahead/behind base)
via short exec() calls. Emits after setup completes, debounces 250ms on any
.git/ change (via fs.watch recursive, polling fallback), and replays the last
cached value to each new SSE client on connect.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm/events): expose branch-status on useVmEvents

Registers the branch-status SSE event type, parses the payload into a
typed BranchStatus, and exposes it on the hook return alongside the
existing status/scripts/processes fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add useBranchStatus hook

Thin wrapper around useVmEvents that resolves previewUrl from the vMCP's
vmMap metadata and returns the latest BranchStatus snapshot from the VM
daemon SSE stream.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add usePrReviews hook for draft/mergeable/conversations

Polls github-mcp-server's get_pull_request for an open PR and extracts the
signals the state-machine selector needs: draft flag, mergeable_state enum,
unresolved conversations count (heuristic), and missing-approvals flag.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add selectHeaderButton selector + unit tests

Pure-function selector that derives the next-action button from
{ branchStatus, pr, checks, reviews } per the priority list in the spec.
17 table-driven tests cover every row and priority edge case.

The deprecated PanelState / derivePanelState exports stay temporarily for
header-actions.tsx compatibility; removed in the HeaderActions rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): single-button HeaderActions driven by selectHeaderButton

Replaces the multi-state HeaderActions with a selector-driven renderer:
- Plain Button for actionable states (Commit & Push, Create PR, Reopen PR,
  Rebase on base, Fix checks, Mark ready for review, Resolve review comments)
- MergeSplitButton for the Merge state (squash default + chevron popover)
- Disabled status Button for "Waiting for checks" / "Waiting for review"

During chat streaming, whatever button is showing becomes disabled with a
"Chat is running" tooltip. closePr template dropped; rerunCheck kept (still
used by checks-tab.tsx for per-check reruns).

Removes the deprecated derivePanelState / PanelState compatibility shim.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/daemon): create origin/<branch> ref; make branch-status resilient

Two fixes to branch-status computation that surfaced during E2E testing:

1. Setup previously did `git fetch origin BRANCH:BRANCH` which creates a
   local branch but not the refs/remotes/origin/<branch> remote-tracking ref.
   Without that ref, `git rev-list origin/base...origin/branch` fails and
   aheadOfBase/behindBase silently stay at 0 — so the selector never
   transitions to Create PR / Merge / etc.

   Adds a `+refs/heads/BRANCH:refs/remotes/origin/BRANCH` fetch before the
   existing one, so the remote-tracking ref is always present when the
   branch exists on origin.

2. computeBranchStatus() now falls back to HEAD on the "branch" side when
   origin/<branch> is missing (new local-only branch), and skips the
   rev-list when origin/<base> is absent. Guards the branch-status event
   against ever emitting nonsense.

Verified end-to-end on deco/misty-spruce + PR #11: branch-status now
reports { workingTreeDirty:false, unpushed:0, aheadOfBase:1, behindBase:0 }
and the header renders "Squash & merge".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(merge-split): add divider between primary button and chevron

Uses border-r with primary-foreground/20 so there's a subtle vertical
divider inside the split button, matching the pattern in the screenshot.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(merge-split): add Review PR option; drop duplicate Squash entry

- Adds a reviewPr() message template that prompts the agent to read the
  PR diff, post line-level review comments, and submit an overall
  approve/request-changes/comment review — a read-only pass.
- Removes the "Squash and merge" item from the dropdown since the
  primary split-button click already triggers it.

Dropdown is now: Rebase and merge / Merge commit / Review PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(merge-split): simplify to Merge + Review PR

- Primary button label: "Squash & merge" → "Merge" (still squash-merge
  under the hood)
- Drop "Rebase and merge" and "Merge commit" dropdown items plus their
  unused mergeRebase / mergeCommit templates
- Dropdown now contains only "Review PR"

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(thread/github): rename action labels to product-style language

Drops git-jargon labels in favor of outcome-focused ones:

- Commit & Push          → Save changes
- Reopen PR              → Reopen
- Create PR              → Submit for review
- Rebase on {base}       → Sync with {base}
- Fix checks             → Fix tests
- Waiting for checks     → Running tests…
- Mark ready for review  → Mark ready
- Resolve review comments → Address feedback
- Waiting for review     → Awaiting review
- Merge                  → Publish
- Review PR (dropdown)   → Review

Action identifiers in the selector stay the same; only the display
strings change. Unit tests updated (17/17 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(thread/github): migrate PR hooks to unified pull_request_read tool

github-mcp-server consolidated several per-action tools into a single
`pull_request_read` dispatched by a `method` arg. The old tool names
(`get_pull_request_files`, `list_check_runs`, `get_pull_request`,
`get_issue_comments`) are no longer exposed — calls return
`MCP error -32602: Tool not found` and our select() fell back to empty
results, silently hiding real data.

Observable fallout:
- PR sub-tabs showed "Changes 0" even when files existed.
- HeaderActions saw empty check/review data and always fell through to
  "Publish" regardless of actual CI/draft/approval state.

Changes:
- usePrFiles, useChecks, usePrComments → pull_request_read with the
  matching method ("get_files"/"get_check_runs"/"get_comments").
- usePrReviews → pull_request_read with method:"get".
- All args switched to camelCase (pullNumber, perPage).
- useChecks signature: headSha → prNumber (the new tool takes the PR
  number, not the commit SHA). ChecksTab and HeaderActions updated.
- usePrFiles derives `deletions` from `changes - additions` since the
  new response shape only includes `changes`.

Verified in-browser: "Changes 1" shown for PR #11 with the single
bun.lock file.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(changes-tab): vertically center +/-counts and external-link icon

Wraps the right-side cluster in inline-flex + items-center so the
LinkExternal01 icon aligns with the numeric counts instead of sitting on
the text baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(thread/github): move branch + PR# from git-tab topbar to main header

The branch and PR number now ride alongside the vMCP title in the main
Toolbar's center column, visible across every main-panel tab instead of
only on the Git tab's sub-view.

- VirtualMcpHeaderInfo extends the center cluster with a branch chip
  (links to GitHub branch page) and a PR chip (#N + external-link,
  single click-target to pr.htmlUrl). Both are gated on the github-linked
  branch state; the PR chip hides when the PR is merged to stay
  consistent with the next-action selector treating merged as "no PR".
- git-tab.tsx drops the topbar above PrSubTabs (state C) and the
  mini-header above the "no PR" explanation (state B). Closed/merged
  summary (state D) unchanged — its body already carries the status.
- Copy tweak: state B mentions the new "Submit for review" button label.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(header-info): plain-text branch; drop middle-dot separators

The branch name is now a non-interactive span; only the PR #N chip is
still a link (opens the PR on GitHub). Middle-dot separators are
replaced by plain flex `gap-3` spacing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(panels): align git sub-tabs + dev-panel headers to h-10 (40px)

PR sub-tabs (TabsList underline) was 52px; dev-panel header row was
implicit 31px. Both now explicit 40px, matching the main app Toolbar
height for visual cohesion across the three header rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(env): align dev-panel tab buttons to PR sub-tabs styling

Matches the TabsTrigger[variant=underline] styling exactly:
- text-sm (was text-xs), drop font-medium
- h-full px-3 (was px-3 py-1.5) so the row controls vertical alignment
- border-b-2 mb-[-1px] so the active-tab underline overlaps the
  container's border-b (matching PR sub-tabs). Previously the 2px
  underline sat above the 1px container border, producing a visible
  double line.

Also aligns the `+` add-script button to the same h-full vertical
rhythm. `capitalize` stays since the tab labels come from lowercase
data keys ("setup", "dev", "daemon").

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(panels): bump git + dev header rows to h-12 (48px)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(preview): bump address-bar row to h-12 to match git + dev headers

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(thread/github): redesign action-button prompts

Three shifts:

1. Decisive tone. Imperative one-liners. No more "You may call..." or
   "For each, do X: ...". Templates go from ~300 chars → ~60-100.

2. Drop environmental boilerplate. Owner, repo, branch, base are
   already in the agent's env (system prompt, VM cwd); stop restating
   them in every prompt. Most templates become zero-arg.

3. Don't ask, execute. The new <repo-environment> paragraphs tell the
   agent that short imperative git/PR actions from the user are a
   button click — authenticated intent, not a question. Skip
   user_ask. This overrides the default <safety> rule for this
   context, so merges/rebases/force-pushes don't get second-guessed.

Also moves the "git CLI for code ops, GitHub MCP for PR ops" rule
(and the `update_pull_request_branch` caveat) from the per-template
GIT_CLI_PREAMBLE into buildRepoEnvironmentPrompt, where it's stated
once and applies universally.

Template signatures simplify:
- commitAndPush, createPr, reopenPr, rebaseOnBase, markReadyForReview,
  resolveReviewComments, reviewPr, mergeSquash → ()
- fixChecks({ failingChecks }), rerunCheck({ checkName })

Callers (HeaderActions, MergeSplitButton, ChecksTab) drop now-unused
args. Tests updated (10/10 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(thread/github): pass PR# + branch into prompts; reinforce click intent

Templates now include the specific PR number (for PR-level actions) and
branch name (for git ops) where the UI has them. This saves the agent
the discovery round-trip it would otherwise need — PR# normally requires
a `list_pull_requests` call; branch can be derived from the VM but
including it removes any ambiguity.

Every template also carries a short per-prompt reinforcement: "The user
clicked this action deliberately — execute directly. Do not call
user_ask unless you hit an actual problem outside the scope of this
intent (missing auth, unresolvable conflict, a check with multiple
plausible fixes)." This is belt-and-suspenders alongside the
<repo-environment> override already in the system prompt.

Signatures tightened: all templates take exactly the ctx they need
(prNumber, branch, or checkName + prNumber, etc.). HeaderActions,
MergeSplitButton, and ChecksTab updated. 11 tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(thread/github): merged PR is terminal → null, not Submit for review

Squash-merging into main doesn't reset origin/<branch> — its pre-merge
commits stay put, while main gets a single new squash commit. So git's
rev-list --left-right sees the branches as divergent and the daemon
reports aheadOfBase > 0 even though the work shipped.

Before: selector saw `aheadOfBase > 0 && pr.merged`, fell into
`!pr || pr.merged` branch, and offered "Submit for review" — as if the
user should open a second PR for the same work.

Now: short-circuit to null as soon as `pr.merged` is true. The work is
done; user starts a new branch to do more. If someone really does push
new commits to a merged branch and wants a new PR for them, they can
type it in the chat — not a common enough flow to warrant a UI path.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): surface Submit for review when branch advances past a merged PR

Previous fix short-circuited merged PRs to null regardless of whether
new commits had been pushed after the merge — too blunt. Now:

1. Daemon adds `headSha` (current HEAD sha of origin/<branch>) to the
   branch-status SSE payload.
2. BranchStatus type + parser carry it through.
3. Selector compares branchStatus.headSha against pr.headSha when
   pr.merged is true:
   - Same sha → null (branch is exactly where it was merged — done)
   - Different sha → "Submit for review" (branch advanced post-merge;
     propose a new PR for the new work)

This covers the flow: user merges PR #11, then pushes a new commit to
the same branch to make a follow-up change — the button now re-appears
as expected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(main-panel-tabs): move git tab after Preview

GitHub-linked vMCPs: Connections → Automations → Layout → Terminal →
Preview → git. Previously git led the list.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(thread/github): show branch in git-tab label; PR# at the panel top

Three coordinated moves to make the git context feel minimal:

1. The git tab's label is now the current branch name (falls back to
   "git" when no branch is selected). Clicking the tab was already the
   user's way to see branch detail; making the label the branch makes
   the breadcrumb self-evident.

2. The main header center drops the branch chip and the PR# chip. Only
   the vMCP icon+title remain there. The center column gets its
   breathing room back.

3. Inside the git panel, a new PrHeader row (h-12, border-b) renders
   "PR #N ↗" prominently above the sub-tabs / merged summary. Single
   link — click to open the PR on GitHub. The older "Open PR #N on
   GitHub" button in the merged state is removed (the new header
   supersedes it).

No PR → no PrHeader; the existing "No pull request yet" body stands on
its own.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm/events): add VmEventsProvider context for single-SSE multiplexing

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/events): multiplex one SSE across preview/env/header-actions

Previously preview.tsx, env.tsx, and use-branch-status.ts each opened
their own EventSource to /_decopilot_vm/events. On reloads the old
connections didn't always release before new ones opened, backing up
against the daemon's MAX_SSE_CLIENTS cap and leaving branchStatus stuck
at null — which made the selector hide the Publish button until a
manual VM restart.

Now:
- VmEventsProvider (added in a prior commit) owns exactly one
  EventSource per previewUrl and fans out to all consumers via React
  context. Chunk subscribers register through a Set-backed registry.
- useVmEvents() is argless and just reads the context.
- useVmChunkHandler(handler) registers per-consumer PTY chunk
  subscriptions with stale-closure safety via a ref.
- useBranchStatus() collapses to `useVmEvents().branchStatus`.
- HeaderActions drops its direct session/userId plumbing (the provider
  does the vmMap → previewUrl derivation once, at the layout level).

The provider mounts inside Chat.Provider in agent-shell-layout for
both desktop and mobile, so all VM-event consumers are always inside
one shared scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(oauth): extract token refresh helpers from list-user-orgs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/start): refresh GitHub token before embedding clone URL

Splits refreshAccessToken into its own file so mock.module can intercept
calls made from inside refreshAndStore, and adds proactive refresh to
buildCloneInfo so the daemon's git clone no longer fails when the stored
token has expired between VM_START calls.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(oauth): request offline_access scope so refresh tokens are issued

Without this scope the MCP SDK's authorize request omits both `scope` and
`prompt=consent`, and downstream OAuth servers (e.g. sites-github-mcp)
don't issue a refresh_token. The resulting token row in downstream_tokens
has null refresh_token / null expires_at and can never be proactively
refreshed — forcing users to reconnect whenever the token goes stale.

Applied at every authenticateMcp call site in apps/mesh/src/web.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(chat): add PendingMessageProvider for cross-remount message queue

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(chat): hoist pendingMessage state to dedicated provider

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(chat): merge providers into single Chat.Provider with suspense

Merges ChatContextProvider + ActiveTaskProvider into one Chat.Provider
that takes virtualMcpId + taskId as props. Hoists Suspense + ErrorBoundary
above the provider so the full content area (header portals, chat, main
panel) skeletons together on task switch. key={taskId} forces full
remount, rebuilding DefaultChatTransport per task.

Drops chatContent indirection in ChatMainPanelGroup; ChatCenterPanel
renders directly inside. Deletes ActiveTaskBoundary helper (suspense
duties migrated up).

Bridge ref retained for compatibility until consumers migrate
(see next commit).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(chat): migrate bridge consumers to useChatStream

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(chat): delete unused bridge ref and useChatBridge

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(chat): drop unused exports flagged by knip

- useChatTask re-export in chat/index.tsx was redundant; all consumers
  import from ./context directly.
- PENDING_MESSAGE_TTL_MS is only used inside pending-message-context.tsx.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
pedrofrxncx added a commit that referenced this pull request Apr 23, 2026
* feat(db): add nullable branch column to threads

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): add branch field to Thread type and storage

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): accept branch in create/update tool schemas

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(sdk): add vmMap to virtualmcp metadata schema

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): vmMap read/write helpers + tests

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): VM_START accepts branch and wires daemon + vmMap

- Adds optional branch input to VM_START
- Daemon receives injectedBranch, attaches to origin/<branch> if it exists
  on the remote; otherwise creates a new local branch
- Domain key includes branch (when provided) so different branches for the
  same user get distinct preview domains
- After vm creation, writes vmMap[userId][branch] = vmId
- Lookup prefers vmMap[userId][branch] when branch is injected, falling back
  to activeVms for branch-unaware callers

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(stream): plumb branch through decopilot stream endpoint

StreamRequestSchema accepts optional branch. Routes pass it to streamCore.
createMemory persists it on the thread when the thread is created for the
first time; existing threads keep their branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): BranchPicker in virtualmcp header for github-linked vms

Reads available branches from vmMap (yours) + github-mcp-server.list_branches
(others). "+ New branch" sub-form invokes create_branch synchronously.
Selected branch is stored in ?branch=... URL param, injected into message
metadata on sendMessage so the server persists it on first-message thread
creation and forwards to VM_START.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): parse list_branches content[0].text fallback

github-mcp-server returns branches as a stringified JSON in content[0].text
rather than structuredContent. Accept both shapes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): git tab replaces Instructions for github-linked vms (MVP)

- New "git" tab with git-branch icon when metadata.githubRepo is set
- GitTab renders 3 states: no branch, no PR yet, PR open, PR merged/closed
- Primary actions (Create PR / Squash & merge / Rebase / Close) call
  sendMessage with natural-language templates; LLM executes via its
  github tools
- PR data fetched via useMCPToolCallQuery (list_pull_requests, 60s poll)
- Parses both structuredContent and content[0].text tool-result shapes
- Instructions tab preserved for non-github vms — zero regression

Scoped MVP: single view, no sub-tabs (Changes/Checks/Comments deferred),
no header action buttons (buttons render inside the tab for now).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): git tab uses ChatBridgeCtx (not ActiveTaskProvider-scoped context)

MainPanelContent renders as a SIBLING of ActiveTaskProvider inside
ChatMainPanelGroup, so useChatStream/useOptionalChatStream return null
there. Switch GitTab to useChatBridge and extend ChatBridgeValue to
expose isStreaming so action buttons still disable during a turn.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): include owner/repo in button message templates

Agent was asking clarifying questions because prompts didn't specify the
repo. Each template now leads with "On repo `owner/repo`, …" so the
agent can act immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): route history-rewriting ops through BASH + git CLI in templates

GitHub MCP tools like update_pull_request_branch perform merge-of-base
rather than true rebase, so rebase/resolve-conflicts/create-PR templates
now instruct the agent to use the BASH tool with git in the vm's working
tree. PR-level ops (close, reopen, merge) keep using GitHub MCP tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): preserve branch + main tab on task switch and new-task

Creating a new task from the tasks panel previously dropped ?branch and
?main URL params, forcing the user to re-select the branch and re-open
the git tab. Preserve both so the new thread inherits the prior state.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): ChatBridgeCtx stores the ref, not its snapshot

useChatBridge previously returned bridgeRef.current captured at
ChatContextProvider's first render — always BRIDGE_NOOP when a consumer
rendered before ActiveTaskProvider registered the real sendMessage.

Now the context holds the RefObject and useChatBridge returns wrappers
that read .current at call time. Consumers get the latest sendMessage /
isStreaming even when the bridge is registered later.

Fixes GitTab buttons silently no-op'ing on a fresh task page load.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): decode-html-entities util for PR title/body rendering

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): render PR title/body as markdown with entity decode

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): panel-state derivation helper for PR panel

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): MergeSplitButton with dropdown of merge strategies

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): HeaderActions state-dependent thread-header buttons

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): mount HeaderActions in thread header

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): remove inline PR action buttons (moved to header)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): extract tool-json helper for shared use across PR hooks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrFiles hook for PR Changes sub-tab

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): useChecks hook + headSha on PrSummary

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrComments hook for issue-level PR comments

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): CommentsAccordion component

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): DescriptionTab component with comments accordion

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChangesTab component with file list

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChecksTab component with per-check Re-run

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): PrSubTabs wrapper for Description/Changes/Checks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): GitTab State C renders Description / Changes / Checks sub-tabs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(decopilot): inject repo-environment system prompt when virtual MCP has a GitHub repo

Add buildRepoEnvironmentPrompt that hints the model it is running inside a
checked-out repository, so it prefers the filesystem/shell tools over guessing
when the user asks about code. Gated on virtualMcp.metadata.githubRepo — the
same signal that wires up the bash/read/grep/glob tool suite — so prompt and
tool availability stay in sync. Re-export GithubRepo from @decocms/mesh-sdk
root so the decopilot route can type the metadata cast.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(knip): remove unused exports

Drop removeVmMapEntry, resolveConflicts, fixErrors, and rerunChecks —
flagged by knip and with no call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm): clone injected branch directly with -b

A plain --single-branch clone only fetches the remote default branch,
so origin/<injected> did not exist and the subsequent checkout silently
resolved to HEAD of the default branch — the wrong commit. Pass
-b <branch> so the clone targets the intended ref, and validate the
branch name before interpolating it into the shell command.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): coerce main=instructions to git for github-linked vmcps

The header swaps the Instructions tab for a Git tab when the virtual
MCP has an active GitHub repo. Thread hasActiveGithubRepo through tab
resolution so default fallbacks and explicit ?main=instructions URLs
land on "git" instead of a stale Instructions panel, keeping the tab
bar and panel body in sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(mesh-sdk): vmMap entries carry { vmId, previewUrl }

Preparatory change for the VirtualMCP metadata refactor — activeVms is
being folded into vmMap. Breaks downstream callers; subsequent commits
update the mesh app.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): add generateBranchName helper returning decopilot/<adj>-<noun>

Lifts the adjective/noun word lists out of daemon.ts so the orchestrator
decides the branch name and can persist it to vmMap before the daemon
sees it. Prefixes all generated branches with decopilot/ for visual
distinguishability in git listings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): vmMap entries become VmMapEntry { vmId, previewUrl }

Drops the VmMetadata import — types.ts is being removed in a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm): vm-map tests use VmMapEntry fixtures

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): requireVmEntry reads from vmMap[userId][branch]

Takes branch as input; returns VmMapEntry | null from the vmMap helper.
Drops the VmMetadata type dependency ahead of types.ts removal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/daemon): require branch: string, drop generator

Branch is now mandatory and validated at buildDaemonScript() entry. The
adjective/noun generator moved to branch-name.ts one layer up so the
orchestrator — not the sandbox — decides the name and persists it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/start): single-tier vmMap lookup; generate branch on demand

Branch input becomes optional; handler calls generateBranchName() when
absent and returns the resolved value so callers can persist. Drops the
activeVms legacy fallback, the patchActiveVms writes, and terminalUrl
from the output shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/start): rewrite against vmMap + branch generator

Drops activeVms-based fixtures and the terminalUrl-in-output assertions.
Adds a test that asserts generateBranchName() fallback when branch is
omitted.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/stop): require branch; remove from vmMap

VM_DELETE now targets a specific (user, branch) vm via vmMap. Drops the
activeVms legacy path and the patchActiveVms call.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/stop): rewrite against vmMap + branch input

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): delete types.ts; migrate last consumers to vmMap

- stream-core.ts now reads from vmMap[userId][branch] instead of
  activeVms[userId]. When no branch is pinned on the thread there is no
  vm, and the built-in VM tools fall back to QuickJS.
- helpers.test.ts replaces the VmMetadata import with a local alias
  since the type no longer exists.
- types.ts (VmEntry, VmMetadata, patchActiveVms) is gone — all replaced
  by the vmMap helpers + VmMapEntry from mesh-sdk.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/preview): read VM from vmMap[userId][branch]

Uses useChatNavigation().branch as the key. When no branch is pinned on
the thread, previewUrl is null and the empty state renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): read vmMap[userId][branch]; pass branch to VM_START/DELETE

VM_START is called with the current thread branch when known; if the
server generates one (because caller passed no branch) the returned
value is written to the ?branch= URL param so subsequent renders find
the vm via vmMap. VM_DELETE now carries the branch so it targets the
right entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(ui): drop activeVms: {} from virtual-mcp create payload

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-generate decopilot/* branch on thread mount

When a thread opens against a virtualMCP with a GitHub repo connected,
AgentInsetProvider now auto-fills the ?branch= URL param with a fresh
decopilot/<adjective>-<noun> name when one is not already set. This
closes the "Select branch…" gap: every github-linked thread now has a
branch before any VM is started, matching the refactor's intent that we
"always have a branch."

generateBranchName moves from apps/mesh/src/tools/vm/ to apps/mesh/src/shared/
so both the server-side VM_START handler and the client-side shell layout
can import it without the UI pulling in server-only tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): reuse first vmMap branch for user before generating

On thread mount, if ?branch= is missing and the vMCP has a GitHub repo,
prefer the first branch from vmMap[userId] over generating a fresh one.
Only generate when the user has no entries yet. This keeps users on
their existing branch across revisits instead of minting a new name
every time.

Edge case: if the user opened the vMCP, got a generated branch, and
never started a VM (so vmMap stays empty), the next visit will
regenerate. This is accepted — once any VM is started, the branch
sticks for all future visits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-start VM on thread mount for github-linked vMCPs

Fires VM_START as soon as a thread opens on a github-linked vMCP and
the branch has no vmMap entry yet. Closes the "fresh branch on every
visit" loop: once the auto-start registers the vm, the sticky-branch
effect reuses it on subsequent mounts instead of minting a new name.

A ref guard dedupes concurrent effect runs; errors are logged but
non-fatal so the existing "Start Server" button remains a manual
fallback if auto-start fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): derive status from vmMap; transient override for actions

Replaces the useState(existingVm ? "running" : "idle") snapshot with a
derived status computed from vmMap on every render. Auto-start (in the
layout) and manual start/stop now both converge on the same code path:
invalidate vmMap query → refetch → env.tsx re-renders → derivedStatus
reflects the new truth.

User-initiated transitions ("creating", "stopping", "error") ride on a
separate override state that a sync-effect clears once derivedStatus
catches up. The previous "suspended" useEffect becomes redundant —
suspended is now derived from the SSE signal inside the same expression.

vmData is derived too; dropped vmDataRef. The SSE subscription no longer
gates on status === "running" — we subscribe whenever vmData is known,
which keeps suspended detection working without a separate transition.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/daemon): clone default, then fetch-or-create branch locally

The previous `git clone --depth 1 --single-branch -b <branch>` always
failed for newly-generated `decopilot/*` names — the remote has no such
ref. Switch to: plain `git clone --depth 1` (always works, gets default
branch) → `git fetch origin <branch>:<branch>` (silently no-ops when
remote lacks the ref) → `git checkout <branch>` or `git checkout -b
<branch>` depending on whether the fetch populated a local ref.

Now a brand-new thread with an auto-generated branch clones the default
branch, creates `decopilot/<adj>-<noun>` locally off its HEAD, and hands
off to `bun install` / `dev` without any "Remote branch not found"
error. Threads that reopen an existing branch still pick up the remote
commits via fetch.

Drops `--single-branch` because the second fetch may bring in a second
ref. One extra commit of data at most — negligible at --depth 1.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* wip dump

* feat(prep): implement remote HEAD SHA revalidation for prep images

- Introduced a new module `prep-head-check.ts` to fetch the current HEAD SHA of the remote repository.
- Enhanced the `resolvePrepImage` function to check for SHA drift before serving cached images, ensuring that stale images are re-enqueued for freshness.
- Added throttling to the remote check to minimize latency and prevent unnecessary network calls, while ensuring that network errors do not invalidate working images.
- Updated documentation to reflect the new freshness check mechanism.

* feat(preview): enhance sandbox loading experience and improve error handling

- Updated the loading HTML response to provide a spinner and status messages while the dev server is starting.
- Improved the handling of thread existence checks in the decopilot routes, ensuring consistent responses for active and dormant threads.
- Refactored the VM start process to support repo-less spins and added error handling for missing GitHub repositories.
- Enhanced the useVmEvents hook to better manage connection states and improve user experience during VM events.
- Updated the preview component to handle auto-starting VMs and improved the visibility of the terminal and logs.

* [[[WIP]]]
feat(claude-code): enhance sandbox integration and error handling

- Introduced `probeClaudeImageOnBoot` to verify the presence of the Claude binary in the sandbox image, preventing misconfigurations at startup.
- Added `creds-source.ts` to determine the default location for Claude Code OAuth credentials based on the environment.
- Implemented `mcp-urls.ts` for rewriting localhost-bound URLs in MCP server maps for container access.
- Created `remote-spawn.ts` to manage remote process spawning for Claude Code, ensuring proper handling of inline credentials and file arguments.
- Developed `sandbox-model.ts` to facilitate the creation of Claude Code models within the sandbox environment, supporting both local and remote execution paths.
- Enhanced the `decopilot` routes to support thread-scoped operations, improving the handling of thread IDs in requests and responses.
- Updated various components to ensure compatibility with the new sandbox features and improve overall error handling.

* [[[WIP]]]
feat(daemon): enhance sandbox daemon with new file operation endpoints and configuration

- Introduced new file operation endpoints for reading, writing, editing, and searching files within the sandbox environment.
- Added a configuration module to manage environment variables and constants for the daemon.
- Implemented a lazy installation mechanism for required runtimes and tools, ensuring efficient resource management.
- Enhanced the daemon's logging and event handling capabilities for better process tracking and error reporting.
- Refactored existing code to improve modularity and maintainability, including the separation of concerns for HTTP handling and file operations.

* fix(threads): ensure metadata is properly updated in SqlThreadStorage

- Added a check to update the metadata field in the SqlThreadStorage class, ensuring that it is correctly serialized to JSON when provided in the data input.

* feat(knip): add entry point for mesh-plugin-user-sandbox and refactor Claude Code exports

- Introduced an entry point for the `mesh-plugin-user-sandbox` in `knip.jsonc` to ensure proper graph usage.
- Refactored exports in `claude-code.ts` and `index.ts` to streamline the code structure.
- Updated various functions in the sandbox and daemon modules to improve consistency and maintainability.

* feat(daemon-client): implement HTTP API helpers for sandbox daemon

- Added a new file `daemon-client.ts` containing pure functions for interacting with the sandbox daemon's HTTP API, including health checks, command execution, and repository bootstrapping.
- Refactored existing Docker runner methods to utilize the new daemon client functions, improving code modularity and maintainability.
- Enhanced error handling and timeout management for daemon interactions.

* feat(security): enhance sandbox security and credential handling

- Implemented strict referer validation to ensure only same-origin requests are processed, preventing potential cross-origin attacks.
- Added explicit checks for environment variables to control the use of host credentials in Docker sandbox environments, enhancing security in multi-tenant setups.
- Updated file operation endpoints to prevent unauthorized access to the host's filesystem and ensure proper path resolution within the sandbox.
- Improved header management in proxy requests to strip sensitive information, including cookies and session tokens, from flowing into user sandboxes.

* [[[WIP]]] feat(streaming): enhance remote process handling and error reporting

- Improved the handling of streaming responses in `remote-spawn.ts`, ensuring that the absence of a terminal result frame is treated as an error, promoting better error reporting in the AI SDK.
- Updated the NDJSON parsing logic to capture per-call usage metrics, allowing for accurate reconstruction of context fill.
- Enhanced the `useStreamManager` hook to support thread status, improving the auto-resume functionality for streaming tasks.
- Added a universal bootstrap script for iframe HTML responses to ensure proper WebSocket URL rewriting across various frameworks.
- Introduced a crash test script to observe sandbox behavior when a container dies mid-run, aiding in error handling improvements.

* feat(sandbox): enhance thread-sandbox endpoint and response handling

- Added `signal` support in proxy requests to manage abort signals for long-lived streams, improving resource management.
- Introduced a new `ThreadSandboxResponse` type to standardize responses from the thread-sandbox endpoint, ensuring consistent handling of Docker and Freestyle sandboxes.
- Updated the `createDecopilotRoutes` function to utilize the new response structure, enhancing clarity and maintainability.
- Refactored frontend components to leverage the new response type, improving the handling of sandbox states and lifecycle management.
- Enhanced query keys for the thread-sandbox endpoint to include versioning, ensuring future compatibility and clarity in API usage.

* refactor(http-helpers): change readFirstLine function to a private scope

- Updated the `readFirstLine` function to be private, encapsulating its functionality within the module and improving code organization.

* refactor(claude-code): streamline Claude Code integration and remove unused components

- Removed the `creds-source.ts`, `mcp-urls.ts`, `remote-spawn.ts`, and `sandbox-model.ts` files to simplify the codebase and eliminate redundancy.
- Updated the `index.ts` and `claude-code.ts` files to reflect the removal of these components, ensuring a cleaner structure.
- Adjusted the `stream-core.ts` and `sandbox-bash.ts` files to remove references to the deleted files, enhancing maintainability.
- Consolidated the import statements and refactored related logic to improve clarity and performance.

* refactor(http-helpers): remove unused readFirstLine function and clean up comments

- Deleted the `readFirstLine` function as it was no longer needed, streamlining the codebase.
- Updated comments in the `http-helpers.mjs` file for clarity, ensuring they accurately reflect the current functionality.

* refactor(daemon): streamline dev server configuration and state management

- Removed the `BOOTSTRAP` configuration and related injection logic from the daemon, simplifying the HTML response handling.
- Introduced a new `DEV_PORT` constant to specify the development server port, ensuring clarity in port management.
- Consolidated the dev server state management by transitioning to a single state container, eliminating the per-thread state structure.
- Updated event handling and logging to reflect the new state management approach, enhancing maintainability and performance.
- Removed the `port-discovery` module as its functionality is no longer needed, further cleaning up the codebase.

* feat(sandbox): introduce local sandbox ingress and daemon control routes

- Added a local sandbox ingress feature for development, allowing requests to be routed to the appropriate container ports based on the request path.
- Implemented new daemon control routes for Docker-backed sandboxes, replacing the previous sandbox preview proxy.
- Updated the application to utilize the new sandbox daemon routes, enhancing the control and management of sandbox lifecycles.
- Removed the deprecated sandbox preview proxy routes, streamlining the codebase and improving clarity in routing logic.
- Enhanced the sandbox reference generation to ensure unique identifiers for each thread, improving isolation and management of sandbox instances.

* refactor(sandbox): consolidate docker container helpers

Extract startContainer/execInContainer + DEFAULT_WORKDIR into
server/docker-helpers.ts so prep (bake pipeline) and runner (live
thread containers) share one spawn-and-parse wrapper instead of
three near-identical copies. Each caller still owns its own run/exec
flag payload — the helper only unifies the plumbing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): consolidate sleep() into shared module

Three identical sleep(ms) definitions across the runner folder;
move to shared.ts so there's one canonical copy.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): group prep timeout constants

Factor probes' repeated { timeoutMs: 30_000, tolerateExit: true }
into a module-scope PROBE_OPTS, and collapse bake.ts's separate
CLONE/INSTALL constants into a TIMEOUTS object with named keys.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): parse deno.json in probeDenoTask

Replace the shell grep with a cat + JSON.parse in Node (with a
small JSONC comment stripper as fallback). The probe now actually
looks at the tasks object instead of regex-matching a colon that
could appear anywhere in the file.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): inline single-call helpers

Inline shEnvName (freestyle wrapCommand), parsePortMapping (readPort),
and the defaultDockerExec alias — each had exactly one caller, so the
named-helper hop was adding indirection without abstraction.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): trim narration-style comments

Compress the STRIP_REQUEST_HEADERS rationale and HostAccessMode
type header; the decision-making narrative already lives in
getHostAccessMode() where it's load-bearing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(sandbox): rewrite prep/bake.ts onboarding comment

Reshape the top-of-file block so a cold reader can answer "what is
this file, how does it relate to server/runner/, why is everything
tolerateExit'd, and where do I add a runtime" in under a minute.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): trim probeDenoTask jsonc handling

Swap the character-walk comment stripper for a regex pass that
handles the common deno.jsonc cases, and fall back to the grep
approach when parsing fails. Keeps the intent of 54b354f42 while
saving ~30 lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(sandbox): tighten prep/bake.ts onboarding comment

Rewritten 8a53eea5f around to hit the ~15-line target — same
four beats (what, relationship to runner, tolerateExit, extension
point) in prose instead of sectioned headings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* wip

* feat(sandbox): update local sandbox ingress port and enhance graceful shutdown

- Changed default local sandbox ingress port from 7000 to 7070 to avoid conflicts with macOS AirPlay.
- Enhanced graceful shutdown process to close ingress servers immediately, ensuring ports are freed without delay.
- Updated documentation and comments to reflect changes in local development setup and DNS requirements.
- Introduced handling for orphaned processes in local development to prevent zombie processes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(sandbox): enhance Docker and Freestyle VM tool integration

- Introduced Docker and Freestyle transport implementations for VM tools, allowing seamless interaction with the sandbox daemon for file operations.
- Added shared schemas and common functionality for VM tools to ensure consistent behavior across different runner types.
- Implemented a mechanism to verify the liveness of Docker containers, purging stale state when necessary.
- Enhanced the event handling in the VM component to support reload events triggered by changes in the project's .deco directory.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): replace readJson with parsedBody in file operations

- Updated file operation handlers to utilize the new parsedBody function for improved request body handling.
- Removed the redundant parsedBody function from daemon.mjs to streamline the codebase.
- Enhanced http-helpers.mjs with a new parsedBody function to prevent issues with drained streams in JSON route handlers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): streamline Docker VM tool integration and remove sandbox-bash

- Removed the sandbox-bash tool and its associated logic to simplify the codebase.
- Introduced a new Docker handle resolver to manage Docker sandbox provisioning and handle retrieval more efficiently.
- Updated VM tool parameters to utilize the lazy handle resolver, ensuring consistent behavior across Docker tools.
- Enhanced documentation and comments to clarify the new structure and functionality of Docker VM tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(migrations): update migration files and remove unused sandbox environment and prep tables

- Updated migration file numbers for consistency and clarity.
- Removed unused migration files related to sandbox environment variables and prep caching, streamlining the migration process.
- Cleaned up references to the removed sandbox environment and prep storage in the codebase, ensuring no lingering dependencies remain.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(chat): enhance branch management in chat context and VM integration

- Added support for managing the current branch within the chat context, allowing threads to reflect the correct branch state.
- Introduced new methods for setting and locking branches, ensuring that branch changes are accurately reflected in the URL and task management.
- Updated the branch picker component to indicate when a branch is locked, preventing users from switching branches mid-thread.
- Enhanced VM booting state handling to provide better user feedback during the initialization process.
- Implemented logic to ensure that the correct branch is used when starting VMs, improving the overall user experience in branch-specific workflows.

* feat(db): add nullable branch column to threads

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): add branch field to Thread type and storage

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(threads): accept branch in create/update tool schemas

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(sdk): add vmMap to virtualmcp metadata schema

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): vmMap read/write helpers + tests

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): VM_START accepts branch and wires daemon + vmMap

- Adds optional branch input to VM_START
- Daemon receives injectedBranch, attaches to origin/<branch> if it exists
  on the remote; otherwise creates a new local branch
- Domain key includes branch (when provided) so different branches for the
  same user get distinct preview domains
- After vm creation, writes vmMap[userId][branch] = vmId
- Lookup prefers vmMap[userId][branch] when branch is injected, falling back
  to activeVms for branch-unaware callers

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(stream): plumb branch through decopilot stream endpoint

StreamRequestSchema accepts optional branch. Routes pass it to streamCore.
createMemory persists it on the thread when the thread is created for the
first time; existing threads keep their branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): BranchPicker in virtualmcp header for github-linked vms

Reads available branches from vmMap (yours) + github-mcp-server.list_branches
(others). "+ New branch" sub-form invokes create_branch synchronously.
Selected branch is stored in ?branch=... URL param, injected into message
metadata on sendMessage so the server persists it on first-message thread
creation and forwards to VM_START.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): parse list_branches content[0].text fallback

github-mcp-server returns branches as a stringified JSON in content[0].text
rather than structuredContent. Accept both shapes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): git tab replaces Instructions for github-linked vms (MVP)

- New "git" tab with git-branch icon when metadata.githubRepo is set
- GitTab renders 3 states: no branch, no PR yet, PR open, PR merged/closed
- Primary actions (Create PR / Squash & merge / Rebase / Close) call
  sendMessage with natural-language templates; LLM executes via its
  github tools
- PR data fetched via useMCPToolCallQuery (list_pull_requests, 60s poll)
- Parses both structuredContent and content[0].text tool-result shapes
- Instructions tab preserved for non-github vms — zero regression

Scoped MVP: single view, no sub-tabs (Changes/Checks/Comments deferred),
no header action buttons (buttons render inside the tab for now).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): git tab uses ChatBridgeCtx (not ActiveTaskProvider-scoped context)

MainPanelContent renders as a SIBLING of ActiveTaskProvider inside
ChatMainPanelGroup, so useChatStream/useOptionalChatStream return null
there. Switch GitTab to useChatBridge and extend ChatBridgeValue to
expose isStreaming so action buttons still disable during a turn.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): include owner/repo in button message templates

Agent was asking clarifying questions because prompts didn't specify the
repo. Each template now leads with "On repo `owner/repo`, …" so the
agent can act immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): route history-rewriting ops through BASH + git CLI in templates

GitHub MCP tools like update_pull_request_branch perform merge-of-base
rather than true rebase, so rebase/resolve-conflicts/create-PR templates
now instruct the agent to use the BASH tool with git in the vm's working
tree. PR-level ops (close, reopen, merge) keep using GitHub MCP tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): preserve branch + main tab on task switch and new-task

Creating a new task from the tasks panel previously dropped ?branch and
?main URL params, forcing the user to re-select the branch and re-open
the git tab. Preserve both so the new thread inherits the prior state.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui): ChatBridgeCtx stores the ref, not its snapshot

useChatBridge previously returned bridgeRef.current captured at
ChatContextProvider's first render — always BRIDGE_NOOP when a consumer
rendered before ActiveTaskProvider registered the real sendMessage.

Now the context holds the RefObject and useChatBridge returns wrappers
that read .current at call time. Consumers get the latest sendMessage /
isStreaming even when the bridge is registered later.

Fixes GitTab buttons silently no-op'ing on a fresh task page load.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): decode-html-entities util for PR title/body rendering

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): render PR title/body as markdown with entity decode

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): panel-state derivation helper for PR panel

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): MergeSplitButton with dropdown of merge strategies

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): HeaderActions state-dependent thread-header buttons

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): mount HeaderActions in thread header

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): remove inline PR action buttons (moved to header)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui): extract tool-json helper for shared use across PR hooks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrFiles hook for PR Changes sub-tab

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): useChecks hook + headSha on PrSummary

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): usePrComments hook for issue-level PR comments

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): CommentsAccordion component

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): DescriptionTab component with comments accordion

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChangesTab component with file list

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): ChecksTab component with per-check Re-run

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): PrSubTabs wrapper for Description/Changes/Checks

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): GitTab State C renders Description / Changes / Checks sub-tabs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(decopilot): inject repo-environment system prompt when virtual MCP has a GitHub repo

Add buildRepoEnvironmentPrompt that hints the model it is running inside a
checked-out repository, so it prefers the filesystem/shell tools over guessing
when the user asks about code. Gated on virtualMcp.metadata.githubRepo — the
same signal that wires up the bash/read/grep/glob tool suite — so prompt and
tool availability stay in sync. Re-export GithubRepo from @decocms/mesh-sdk
root so the decopilot route can type the metadata cast.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(knip): remove unused exports

Drop removeVmMapEntry, resolveConflicts, fixErrors, and rerunChecks —
flagged by knip and with no call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm): clone injected branch directly with -b

A plain --single-branch clone only fetches the remote default branch,
so origin/<injected> did not exist and the subsequent checkout silently
resolved to HEAD of the default branch — the wrong commit. Pass
-b <branch> so the clone targets the intended ref, and validate the
branch name before interpolating it into the shell command.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): coerce main=instructions to git for github-linked vmcps

The header swaps the Instructions tab for a Git tab when the virtual
MCP has an active GitHub repo. Thread hasActiveGithubRepo through tab
resolution so default fallbacks and explicit ?main=instructions URLs
land on "git" instead of a stale Instructions panel, keeping the tab
bar and panel body in sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(mesh-sdk): vmMap entries carry { vmId, previewUrl }

Preparatory change for the VirtualMCP metadata refactor — activeVms is
being folded into vmMap. Breaks downstream callers; subsequent commits
update the mesh app.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm): add generateBranchName helper returning decopilot/<adj>-<noun>

Lifts the adjective/noun word lists out of daemon.ts so the orchestrator
decides the branch name and can persist it to vmMap before the daemon
sees it. Prefixes all generated branches with decopilot/ for visual
distinguishability in git listings.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): vmMap entries become VmMapEntry { vmId, previewUrl }

Drops the VmMetadata import — types.ts is being removed in a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm): vm-map tests use VmMapEntry fixtures

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): requireVmEntry reads from vmMap[userId][branch]

Takes branch as input; returns VmMapEntry | null from the vmMap helper.
Drops the VmMetadata type dependency ahead of types.ts removal.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/daemon): require branch: string, drop generator

Branch is now mandatory and validated at buildDaemonScript() entry. The
adjective/noun generator moved to branch-name.ts one layer up so the
orchestrator — not the sandbox — decides the name and persists it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/start): single-tier vmMap lookup; generate branch on demand

Branch input becomes optional; handler calls generateBranchName() when
absent and returns the resolved value so callers can persist. Drops the
activeVms legacy fallback, the patchActiveVms writes, and terminalUrl
from the output shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/start): rewrite against vmMap + branch generator

Drops activeVms-based fixtures and the terminalUrl-in-output assertions.
Adds a test that asserts generateBranchName() fallback when branch is
omitted.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm/stop): require branch; remove from vmMap

VM_DELETE now targets a specific (user, branch) vm via vmMap. Drops the
activeVms legacy path and the patchActiveVms call.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(vm/stop): rewrite against vmMap + branch input

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(vm): delete types.ts; migrate last consumers to vmMap

- stream-core.ts now reads from vmMap[userId][branch] instead of
  activeVms[userId]. When no branch is pinned on the thread there is no
  vm, and the built-in VM tools fall back to QuickJS.
- helpers.test.ts replaces the VmMetadata import with a local alias
  since the type no longer exists.
- types.ts (VmEntry, VmMetadata, patchActiveVms) is gone — all replaced
  by the vmMap helpers + VmMapEntry from mesh-sdk.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/preview): read VM from vmMap[userId][branch]

Uses useChatNavigation().branch as the key. When no branch is pinned on
the thread, previewUrl is null and the empty state renders.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): read vmMap[userId][branch]; pass branch to VM_START/DELETE

VM_START is called with the current thread branch when known; if the
server generates one (because caller passed no branch) the returned
value is written to the ?branch= URL param so subsequent renders find
the vm via vmMap. VM_DELETE now carries the branch so it targets the
right entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(ui): drop activeVms: {} from virtual-mcp create payload

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-generate decopilot/* branch on thread mount

When a thread opens against a virtualMCP with a GitHub repo connected,
AgentInsetProvider now auto-fills the ?branch= URL param with a fresh
decopilot/<adjective>-<noun> name when one is not already set. This
closes the "Select branch…" gap: every github-linked thread now has a
branch before any VM is started, matching the refactor's intent that we
"always have a branch."

generateBranchName moves from apps/mesh/src/tools/vm/ to apps/mesh/src/shared/
so both the server-side VM_START handler and the client-side shell layout
can import it without the UI pulling in server-only tools.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): reuse first vmMap branch for user before generating

On thread mount, if ?branch= is missing and the vMCP has a GitHub repo,
prefer the first branch from vmMap[userId] over generating a fresh one.
Only generate when the user has no entries yet. This keeps users on
their existing branch across revisits instead of minting a new name
every time.

Edge case: if the user opened the vMCP, got a generated branch, and
never started a VM (so vmMap stays empty), the next visit will
regenerate. This is accepted — once any VM is started, the branch
sticks for all future visits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui): auto-start VM on thread mount for github-linked vMCPs

Fires VM_START as soon as a thread opens on a github-linked vMCP and
the branch has no vmMap entry yet. Closes the "fresh branch on every
visit" loop: once the auto-start registers the vm, the sticky-branch
effect reuses it on subsequent mounts instead of minting a new name.

A ref guard dedupes concurrent effect runs; errors are logged but
non-fatal so the existing "Start Server" button remains a manual
fallback if auto-start fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/env): derive status from vmMap; transient override for actions

Replaces the useState(existingVm ? "running" : "idle") snapshot with a
derived status computed from vmMap on every render. Auto-start (in the
layout) and manual start/stop now both converge on the same code path:
invalidate vmMap query → refetch → env.tsx re-renders → derivedStatus
reflects the new truth.

User-initiated transitions ("creating", "stopping", "error") ride on a
separate override state that a sync-effect clears once derivedStatus
catches up. The previous "suspended" useEffect becomes redundant —
suspended is now derived from the SSE signal inside the same expression.

vmData is derived too; dropped vmDataRef. The SSE subscription no longer
gates on status === "running" — we subscribe whenever vmData is known,
which keeps suspended detection working without a separate transition.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/daemon): clone default, then fetch-or-create branch locally

The previous `git clone --depth 1 --single-branch -b <branch>` always
failed for newly-generated `decopilot/*` names — the remote has no such
ref. Switch to: plain `git clone --depth 1` (always works, gets default
branch) → `git fetch origin <branch>:<branch>` (silently no-ops when
remote lacks the ref) → `git checkout <branch>` or `git checkout -b
<branch>` depending on whether the fetch populated a local ref.

Now a brand-new thread with an auto-generated branch clones the default
branch, creates `decopilot/<adj>-<noun>` locally off its HEAD, and hands
off to `bun install` / `dev` without any "Remote branch not found"
error. Threads that reopen an existing branch still pick up the remote
commits via fetch.

Drops `--single-branch` because the second fetch may bring in a second
ref. One extra commit of data at most — negligible at --depth 1.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/toolbar): add Toolbar.RightSlot portal for right-aligned actions

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/toolbar): reorder header — toggles after nav, right slot for actions

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): move HeaderActions to right slot, drop BranchPicker from topbar

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): render BranchPicker in SidebarEmptyState for github-linked vMCPs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): add separator before PR actions, drop "..." menu from Create PR state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui/topbar): use matching data-attr specificity so h-5 overrides h-full on vertical separator

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ui/topbar): match toolbar separator to Create-PR separator height (data-attr specificity)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/tasks): expose branch on web Task type

* feat(ui/tasks): show task branch in row subtitle, repo as fallback

* feat(ui/tasks): include branch in optimistic task record

* refactor(vm): rename generated branch prefix decopilot/ -> deco/

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/branch-picker): drop New-branch form; picker-only popover

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): add New branch button next to BranchPicker in empty state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/branch-picker): move New button into popover, next to the search input

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/topbar): drop vMCP title from top bar — already shown in empty state

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(ui/chat): render vMCP avatar+title header above messages in middle panel

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore(ui/toolbar): add gap between nav buttons and toggle cluster

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/chat): center agent icon+title in middle-panel header

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/toolbar): tighten gap between nav buttons and toggles (ml-2 → ml-1)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(ui/toolbar): match inter-cluster gap to within-cluster gap (ml-1 → ml-0.5)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(ui/toolbar): use 3-column grid with centered vMCP header

Restructure the toolbar header as a 3-column grid so the center slot stays
screen-centered regardless of left/right content widths. Move the vMCP
icon+title from the chat middle-panel header into the toolbar center slot,
and drop the now-redundant ChatAgentHeader.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add commitAndPush/fixChecks/markReadyForReview/resolveReviewComments templates

New chat-prompt templates for the upcoming single-button HeaderActions.
rerunCheck and closePr stay for now — removed in the HeaderActions rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm/daemon): emit branch-status SSE event on setup/file-change/connect

Computes the VM's git state (working-tree dirty, unpushed, ahead/behind base)
via short exec() calls. Emits after setup completes, debounces 250ms on any
.git/ change (via fs.watch recursive, polling fallback), and replays the last
cached value to each new SSE client on connect.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(vm/events): expose branch-status on useVmEvents

Registers the branch-status SSE event type, parses the payload into a
typed BranchStatus, and exposes it on the hook return alongside the
existing status/scripts/processes fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add useBranchStatus hook

Thin wrapper around useVmEvents that resolves previewUrl from the vMCP's
vmMap metadata and returns the latest BranchStatus snapshot from the VM
daemon SSE stream.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add usePrReviews hook for draft/mergeable/conversations

Polls github-mcp-server's get_pull_request for an open PR and extracts the
signals the state-machine selector needs: draft flag, mergeable_state enum,
unresolved conversations count (heuristic), and missing-approvals flag.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): add selectHeaderButton selector + unit tests

Pure-function selector that derives the next-action button from
{ branchStatus, pr, checks, reviews } per the priority list in the spec.
17 table-driven tests cover every row and priority edge case.

The deprecated PanelState / derivePanelState exports stay temporarily for
header-actions.tsx compatibility; removed in the HeaderActions rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(thread/github): single-button HeaderActions driven by selectHeaderButton

Replaces the multi-state HeaderActions with a selector-driven renderer:
- Plain Button for actionable states (Commit & Push, Create PR, Reopen PR,
  Rebase on base, Fix checks, Mark ready for review, Resolve review comments)
- MergeSplitButton for the Merge state (squash default + chevron popover)
- Disabled status Button for "Waiting for checks" / "Waiting for review"

During chat streaming, whatever button is showing becomes disabled with a
"Chat is running" tooltip. closePr template dropped; rerunCheck kept (still
used by checks-tab.tsx for per-check reruns).

Removes the deprecated derivePanelState / PanelState compatibility shim.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(vm/daemon): create origin/<branch> ref; make branch-status resilient

Two fixes to branch-status computation that surfaced during E2E testing:

1. Setup previously did `git fetch origin BRANCH:BRANCH` which creates a
   local branch but not the refs/remotes/origin/<branch> remote-tracking ref.
   Without that ref, `git rev-list origin/base...origin/branch` fails and
   aheadOfBase/behindBase silently stay at 0 — so the selector never
   transitions to Create PR / Merge / etc.

   Adds a `+refs/heads/BRANCH:refs/remotes/origin/BRANCH` fetch before the
   existing one, so the remote-tracking ref is always present when the
   branch exists on origin.

2. computeBranchStatus() now falls back to HEAD on the "branch" side when
   origin/<branch> is missing (new local-only branch), and skips the
   rev-list when origin/<base> is absent. Guards the branch-status event
   against ever emitting nonsense.

Verified end-to-end on deco/misty-spruce + PR #11: branch-status now
reports { workingTreeDirty:false, unpushed:0, aheadOfBase:1, behindBase:0 }
and the header renders "Squash & merge".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(merge-split): add divider between primary button and chevron

Uses border-r with primary-foreground/20 so there's a subtle vertical
divider inside the split button, matching the pattern in the screenshot.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(merge-split): add Review PR option; drop duplicate Squash entry

- Adds a reviewPr() message template that prompts the agent to read the
  PR diff, post line-level review comments, and submit an overall
  approve/request-changes/comment review — a read-only pass.
- Removes the "Squash and merge" item from the dropdown since the
  primary split-button click already triggers it.

Dropdown is now: Rebase and merge / Merge commit / Review PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(merge-split): simplify to Merge + Review PR

- Primary button label: "Squash & merge" → "Merge" (still squash-merge
  under the hood)
- Drop "Rebase and merge" and "Merge commit" dropdown items plus their
  unused mergeRebase / mergeCommit templates
- Dropdown now contains only "Review PR"

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(thread/github): rename action labels to product-style language

Drops git-jargon labels in favor of outcome-focused ones:

- Commit & Push          → Save changes
- Reopen PR              → Reopen
- Create PR              → Submit for review
- Rebase on {base}       → Sync with {base}
- Fix checks             → Fix tests
- Waiting for checks     → Running tests…
- Mark ready for review  → Mark ready
- Resolve review comments → Address feedback
- Waiting for review     → Awaiting review
- Merge                  → Publish
- Review PR (dropdown)   → Review

Action identifiers in the selector stay the same; only the display
strings change. Unit tests updated (17/17 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(thread/github): migrate PR hooks to unified pull_request_read tool

github-mcp-server consolidated several per-action tools into a single
`pull_request_read` dispatched by a `method` arg. The old tool names
(`get_pull_request_files`, `list_check_runs`, `get_pull_request`,
`get_issue_comments`) are no longer exposed — calls return
`MCP error -32602: Tool not found` and our select() fell back to empty
results, silently hiding real data.

Observable fallout:
- PR sub-tabs showed "Changes 0" even when files existed.
- HeaderActions saw empty check/review data and always fell through to
  "Publish" regardless of actual CI/draft/approval state.

Changes:
- usePrFiles, useChecks, usePrComments → pull_request_read with the
  matching method ("get_files"/"get_check_runs"/"get_comments").
- usePrReviews → pull_request_read with method:"get".
- All args switched to camelCase (pullNumber, perPage).
- useChecks signature: headSha → prNumber (the new tool takes the PR
  number, not the commit SHA). ChecksTab and HeaderActions updated.
- usePrFiles derives `deletions` from `changes - additions` since the
  new response shape only includes `changes`.

Verified in-browser: "Changes 1" shown for PR #11 with the single
bun.lock file.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(changes-tab): vertically center +/-counts and external-link icon

Wraps the right-side cluster in inline-flex + items-center so the
LinkExternal01 icon aligns with the numeric counts instead of sitting on
the text baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(user-sandbox): remove freestyle runner and streamline Docker integration

- Deleted the FreestyleSandboxRunner and its associated logic to simplify the codebase.
- Updated the DockerSandboxRunner to handle all sandbox provisioning, ensuring consistent behavior.
- Removed unused dependencies and configurations related to the freestyle runner.
- Enhanced the Docker runner's documentation for clarity on its functionality and usage.

* refactor(thread/github): move branch + PR# from git-tab topbar to main header

The branch and PR number now ride alongside the vMCP title in the main
Toolbar's center column, visible across every main-panel tab instead of
only on the Git tab's sub-view.

- VirtualMcpHeaderInfo extends the center cluster with a branch chip
  (links to GitHub branch page) and a PR chip (#N + external-link,
  single click-target to pr.htmlUrl). Both are gated on the github-linked
  branch state; the PR chip hides when the PR is merged to stay
  consistent with the next-action selector treating merged as "no PR".
- git-tab.tsx drops the topbar above PrSubTabs (state C) and the
  mini-header above the "no PR" explanation (state B). Closed/merged
  summary (state D) unchanged — its body already carries the status.
- Copy tweak: state B mentions the new "Submit for review" button label.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(header-info): plain-text branch; drop middle-dot separators

The branch name is now a non-interactive span; only the PR #N chip is
still a link (opens the PR on GitHub). Middle-dot separators are
replaced by plain flex `gap-3` spacing.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(chat): remove unused branch property from task interface and chat context

- Deleted the redundant branch property from the Task interface in types.ts.
- Removed the branch extraction from useChatNavigation in chat-context.tsx to streamline the codebase.

* style(panels): align git sub-tabs + dev-panel headers to h-10 (40px)

PR sub-tabs (TabsList underline) was 52px; dev-panel header row was
implicit 31px. Both now explicit 40px, matching the main app Toolbar
height for visual cohesion across the three header rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(env): align dev-panel tab buttons to PR sub-tabs styling

Matches the TabsTrigger[variant=underline] styling exactly:
- text-sm (was text-xs), drop font-medium
- h-full px-3 (was px-3 py-1.5) so the row controls vertical alignment
- border-b-2 mb-[-1px] so the active-tab underline overlaps the
  container's border-b (matching PR sub-tabs). Previously the 2px
  underline sat above the 1px container border, producing a visible
  double line.

Also aligns the `+` add-script button to the same h-full vertical
rhythm. `capitalize` stays since the tab labels come from lowercase
data keys ("setup", "dev", "daemon").

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(panels): bump git + dev header rows to h-12 (48px)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(preview): bump address-bar row to h-12 to match git + dev headers

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(sandbox): migrate shared runner logic to lifecycle module

- Replaced references to the shared runner with the new lifecycle module across various files.
- Introduced lifecycle management for sandbox runners, including boot and shutdown sweeps.
- Removed the outdated shared-runner file to streamline the codebase and improve clarity on sandbox lifecycle handling.

* feat(sandbox): introduce daemon-client for HTTP API interactions

- Added a new `daemon-client.ts` file containing functions for health probing, command execution, and repository bootstrapping within the sandbox daemon.
- Refactored Docker-related functions by moving them from `docker-helpers.ts` to `docker-cli.ts`, enhancing modularity and clarity.
- Removed the now redundant `docker-helpers.ts` file to streamline the codebase.

* refactor(thread/github): redesign action-button prompts

Three shifts:

1. Decisive tone. Imperative one-liners. No more "You may call..." or
   "For each, do X: ...". Templates go from ~300 chars → ~60-100.

2. Drop environmental boilerplate. Owner, repo, branch, base are
   already in the agent's env (system prompt, VM cwd); stop restating
   them in every prompt. Most templates become zero-arg.

3. Don't ask, execute. The new <repo-environment> paragraphs tell the
   agent that short imperative git/PR actions from the user are a
   button click — authenticated intent, not a question. Skip
   user_ask. This overrides the default <safety> rule for this
   context, so merges/rebases/force-pushes don't get second-guessed.

Also moves the "git CLI for code ops, GitHub MCP for PR ops" rule
(and the `update_pull_request_branch` caveat) from the per-template
GIT_CLI_PREAMBLE into buildRepoEnvironmentPrompt, where it's stated
once and applies un…
yuriassuncx added a commit that referenced this pull request Sep 11, 2026
…rams (#7151)

The Blog Manager's "Editar no Studio" redirect (spire-agent PR #11,
merged 2026-07-14) navigates to
`?virtualmcpid=...&main=content&contentCollection=posts&contentItem=<blockKey>`
expecting the content editor to land on that exact post. Studio's
ContentBrowser never read those params — added in the still-open,
now-stale PR #4302 (based on a pre-rename `apps/mesh` path that no
longer exists) — so every "Editar no Studio" click just opened the
generic Posts list instead of the post itself.

Seed `activeCollection`/`selection` from `useSearch()` once via lazy
useState initializers, mirroring the existing storefront "." deep-link
pattern (`deepLinkPage`) already in this file. Older Studio builds
without this simply ignore the extra params (unaffected).

Co-authored-by: Claude Sonnet 5 <[email protected]>
pedrofrxncx added a commit that referenced this pull request Sep 22, 2026
…7428)

Replace [^}]+ with .+? (non-greedy any character) for proper multi-character
handling in triple/double brace delimiters. Addresses code-scanning alert #11
(incomplete multi-character sanitization) by using the correct non-greedy
matching pattern for Mustache templates, improving robustness on edge cases.
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