Skip to content

Commit 0134c4a

Browse files
committed
feat: enhance crew integration presentation and collision review
- Updated `presentCrewIntegration` to improve messaging for lane verification and applied integrations. - Added new tests for verifying lane selection prompts and base-change restoration warnings. - Introduced `CrewCollisionReview` component for cross-lane behavioral review, including styling and functionality for displaying collision findings. - Refactored styles for collision review and git sidebar to improve layout and readability. - Implemented `useStickToBottom` hook for better handling of scrolling behavior in threads. - Added tests for new tab actions and scrolling behavior.
1 parent 6fb7703 commit 0134c4a

34 files changed

Lines changed: 1285 additions & 222 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ docs-website/dist/
4242
docs-website/.astro/
4343
social-media-post.md
4444
Work/
45+
promo-video

‎docs/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal references).
1919

2020
| Doc | What it covers |
2121
| --- | --- |
22-
| [using-crews.md](./using-crews.md) | Crews: running multiple agents in parallel with lanes, modes, and a supervisor |
22+
| [using-crews.md](./using-crews.md) | Crews: parallel lanes, supervisors, and the select → verify → reconcile → apply Merge lanes workflow |
2323
| [reasoning-effort.md](./reasoning-effort.md) | Provider-native reasoning effort levels in the composer and crew lanes |
2424
| [realtime-voice.md](./realtime-voice.md) | Voice orb providers, coding-agent routing, natural spoken replies, credentials, and local roadmap |
2525
| [prompt-skill-studio.md](./prompt-skill-studio.md) | Prompt Builder Studio and local `.crewcode` prompt/skill folders _(needs a user-guide rewrite — currently changelog-style)_ |

‎docs/behavioral-merge-review.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ For isolated crews, **Cross-lane Diff** and the merge sidebar show:
1414

1515
The contract heuristics are intentionally narrow and explainable. They cover database migration/schema changes versus model/API consumers, API schemas versus clients/generated code, dependency manifests versus runtime source, and configuration versus consuming source. The sidebar lists the implicated lanes and paths. These warnings are review signals, not proof of a defect; no warning is not proof that combined behavior is correct.
1616

17+
Both surfaces render findings through one component, `components/crew/CrewCollisionReview.tsx` (styles in `styles/crew-collision-review.css`), so the merge sidebar and Cross-lane Diff cannot drift apart in what a signal looks like or says. `analyzeCrewCollisions` already returns `kind` and `severity`; the gate presents them instead of discarding them. Findings are ordered high severity first, each carrying a severity rail and badge, a plain-language kind label, the two implicated lanes as separate chips, the heuristic's reason as a sentence, and the exact paths as individual chips (collapsed past four behind a `+N more` control). Severity color is confined to the rail, badge, and tally counts — body text stays at normal foreground contrast, because tinting whole blocks of amber prose is what made the previous gate hard to read. The empty state is stated as "no heuristic collisions found" plus an explicit reminder that the heuristics are narrow, never as an all-clear.
18+
1719
## Combined integration gate
1820

19-
Crew lanes are no longer merged into the base one at a time. **Verify combined lanes** snapshots the base and every committed lane SHA, creates a detached disposable worktree under `.worktrees/`, and merges all candidate SHAs there in displayed order. The user's base checkout remains untouched.
21+
Isolated lane branch names include the full session timestamp and sequence, and provisioning rejects an existing branch instead of silently reopening a same-numbered branch from an older base. Crew lanes are no longer merged directly into the base one at a time. The operator can include one committed lane, several lanes, or all eligible lanes with the per-lane checkboxes. **Verify selected lanes** snapshots the base and each selected lane SHA, creates a detached disposable worktree under `.worktrees/`, and merges those candidate SHAs there in displayed order. Each lane's **verify only this lane** shortcut uses this same gate instead of bypassing it. If combination conflicts, **ask lane agent to reconcile** resumes the affected lane if paused, starts its configured runtime in that lane worktree, and immediately submits a task to merge the current base into the lane, resolve, check, and commit there. It does not route through or modify the base checkout. The user's base checkout remains untouched.
2022

2123
CrewCode then discovers the allowlisted `typecheck` and `test` package scripts using the repository's lockfile-selected package manager and runs them against that exact combined tree. This catches failures that no lane can expose alone—for example, a DB migration in one lane changing a column while a model/API lane independently changes the consumer to an incompatible name. Agents cannot submit arbitrary commands through this route; main runs only discovered check IDs, with `CI=1`, a two-minute local timeout, and bounded output. Local and SSH workspaces are supported.
2224

23-
A passing candidate is retained by an internal Git ref. **Apply checked integration** rechecks all of the following before updating the base:
25+
A passing candidate is retained by an internal Git ref. Verification may run while the base checkout has uncommitted work because the disposable candidate is built exclusively from committed SHAs. **Apply checked integration** rechecks all of the following before updating the base:
2426

25-
- the base checkout is clean and still has the expected base branch checked out;
27+
- the base checkout still has the expected base branch checked out;
2628
- the base branch still points to the verified base SHA;
2729
- every lane branch still points to its verified SHA; and
2830
- the retained ref still points to the exact checked integration commit.
2931

30-
Only then does CrewCode use `git merge --ff-only` to apply the checked commit. A changed input makes the candidate stale and requires another verification.
32+
Only then does CrewCode preserve staged, unstaged, and untracked base changes in a recovery stash, use `git merge --ff-only` to apply the checked commit, and restore the user's work (including its staged state). If restoration conflicts with the applied commit, the integration remains applied, the recovery stash is retained, and the conflict is surfaced rather than discarding user data. A changed committed input makes the candidate stale and requires another verification.
3133

3234
The sidebar reports the result as a **candidate decision**, not as whether CrewCode itself worked. **Candidate rejected** means the safety gate ran and prevented an incompatible or otherwise failing combination from reaching the base. **Ready to apply** means the combined candidate passed the discovered checks. Failed check output is expanded beneath the check so the rejection reason is visible without opening developer tools.
3335

‎docs/crew-orchestrator.md‎

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@
5757
the shared-mode timeline
5858
(`CrewTimeline`) renders one composer per worker so the user types each
5959
task manually; split timeline rounds show each lane's own prompt in that
60-
lane card instead of one shared round prompt. Isolated mode already has
61-
per-lane composers.
60+
lane card instead of one shared round prompt. Isolated mode
61+
(`CrewColumns`) keeps one composer inside each lane pane card.
6262
- `broadcast`: the same message fans out to every worker (`handleBroadcast`),
6363
and the supervisor is told it may use `"to":"all"`; the hard split gates
64-
do not apply.
64+
do not apply. Without a supervisor, BOTH modes collapse to a single
65+
composer: shared mode uses the `crew-timeline-foot`, isolated mode drops
66+
every per-lane composer and renders one centered `crew-broadcast-foot`
67+
under the lane grid. Either one carries a `BroadcastTargetChip`, so the
68+
next send can still be retargeted at one enabled lane without leaving
69+
broadcast.
6570
- The toggle dispatches `set_distribution`, which — unlike `set_mode` — is
6671
legal at any lifecycle phase, so it can be flipped mid-run and takes effect
6772
on the next prompt.
@@ -89,6 +94,51 @@
8994
supervisor loop, and lane composer stop buttons stop only that lane so the
9095
next prompt respawns it.
9196

97+
7d-i. Isolated lane layout — `CrewColumns` renders lanes into Workbench's
98+
99+
responsive pane grid (`.canvas-mode-pane-grid` from `styles.css`, with a
100+
denser `.crew-pane-grid` track floor of 420px/520px in `crew-surface.css`)
101+
instead of a horizontal scroller. Each `LaneColumn` is a
102+
`.canvas-mode-pane` card whose title strip is a `.canvas-mode-pane-bar`
103+
(provider logo, agent name, role pill, restart, status dot); the lane's
104+
branch, model picker, run switch, effort, next action, and usage strip stay
105+
in `.lane-head` directly beneath the bar. Lanes wrap onto new rows rather
106+
than squeezing, and `--lane-i` still drives the entry stagger.
107+
108+
7d-iii. Lane reading affordances — a lane thread follows the newest output
109+
110+
while its worker streams via `useStickToBottom` (`hooks/useStickToBottom.ts`,
111+
72px threshold, scroll applied in the next animation frame so a streaming
112+
turn never forces a synchronous reflow of the surface). Following is
113+
suspended the moment the operator scrolls up and re-armed when they scroll
114+
back down; a sticky `lane-scroll-bottom` button appears only while unpinned.
115+
The waiting loader is driven by `useIsBridgeRunning(lane.bridgeId)`, NOT by
116+
`lane.bridgeId != null` / `lane.status === 'running'` — both of those mean
117+
"a runtime is attached" and stay true between turns, which would leave a
118+
permanent spinner.
119+
Each lane pane bar also carries an expand/shrink button: expanding renders
120+
that lane alone in a single full-surface grid track (`.crew-pane-grid.is-maximized`),
121+
with `Escape` restoring the grid. The maximized lane is resolved against live
122+
`session.lanes`, so a lane edited away or archived while expanded falls back
123+
to the grid instead of rendering an empty surface.
124+
125+
7d-ii. Lane approvals and the composer dock — worker lane bridges start with
126+
127+
mode `'build'` (workers execute; only the supervisor starts `'ask'` /
128+
`'read-only'`). That is what makes `TurnPermissionGrantStore.prepareRequest`
129+
attach `allowAllForTurn`, so lane permission cards get the same
130+
"allow all (this turn ONLY)" button as a solo Build-mode chat. Eligibility
131+
is `kind === 'permission'` + a `turnId` + `mode === 'build'` +
132+
`toolPolicy !== 'read-only'`; the grant is keyed `bridgeId\0turnId` and dies
133+
with the turn, so it never outlives the turn that authorized it. Passing the
134+
mode explicitly does not change provider behavior — every bridge already
135+
treats an absent mode the same as `'build'`.
136+
`AgentActivityOverlay` renders in a `lane-composer-dock` pinned above the
137+
lane composer (mirroring solo's `composer-dock`) rather than inside the
138+
scrolling thread, so a turn-blocking permission pause cannot be scrolled out
139+
of view. The dock renders even when the composer is hidden (broadcast
140+
distribution or Supervisor-owned input) so the pause stays answerable.
141+
92142
7e. Supervisor reporting cadence — worker replies are fed back incrementally,
93143

94144
not batched. `useCrewSupervisor.feedSupervisor()` nudges the supervisor the

‎docs/using-crews.md‎

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,61 @@ checkpoint; the operator or supervisor decides when to continue.
105105

106106
After a stop, sending a message resumes orchestration cleanly.
107107

108+
## Reviewing and merging isolated lanes
109+
110+
Select **merge** in the crew header to open the **Merge lanes** sidebar. This
111+
sidebar moves committed lane work into the branch from which the crew was
112+
started (shown after the `→` in the header). It does not include uncommitted lane
113+
work; use the lane's **commit** action first when that warning appears.
114+
115+
### Choose what to include
116+
117+
- Every lane with committed changes is selected initially.
118+
- Clear a lane's checkbox to leave that branch out of this candidate.
119+
- Use **all** or **none** for quick selection.
120+
- **verify only this lane** selects that row alone and starts the same safe
121+
verification used for multi-lane candidates.
122+
- The lane enabled/paused switch controls its agent runtime, not merge selection.
123+
124+
Review **Cross-lane Diff** before merging when lanes edit related code. Candidate
125+
ownership records the exact base commit, lane branch and commit, worktree, and
126+
file paths used for the attempt. These are evidence for the candidate—not a list
127+
of uncommitted files.
128+
129+
### Verify before applying
130+
131+
Choose **Verify selected lanes**. CrewCode then:
132+
133+
1. snapshots the current base commit and selected lane commits;
134+
2. creates a disposable detached worktree without changing the base checkout;
135+
3. combines the selected commits in displayed order; and
136+
4. runs discovered, allowlisted `typecheck` and `test` package scripts.
137+
138+
A Git conflict or failed project check rejects only the disposable candidate;
139+
nothing is applied to the base branch. **Ready to apply** means the exact
140+
combined commit passed every discovered check. If no supported scripts exist,
141+
the sidebar explicitly says that only Git combination was verified.
142+
143+
If combination conflicts, **ask lane agent to reconcile** resumes and starts the
144+
affected lane's configured agent in that lane worktree, then sends it a task to
145+
merge the current base into the lane, resolve the named files, run checks, and
146+
commit. After the agent finishes, select **refresh** and verify again.
147+
148+
### Apply the verified commit
149+
150+
Choose **Apply verified commit** only after reviewing the candidate evidence.
151+
CrewCode confirms that the base and lane commits still match verification, then
152+
fast-forwards the base to that exact checked commit. If the base checkout has
153+
staged, unstaged, or untracked work, CrewCode preserves it in a recovery stash,
154+
applies the integration, and restores the work with its staged state. A restore
155+
conflict is reported and its recovery stash is retained rather than discarded.
156+
157+
Changing a selected lane, moving a lane branch, or moving the base commit makes
158+
old verification stale; refresh and verify the new candidate. Verification by
159+
itself never changes the base branch.
160+
108161
## Finishing up
109162

110-
In isolated mode, review lane ownership and collision signals in Cross-lane
111-
Diff, then use the merge sidebar to verify all selected lane commits together
112-
before applying the exact checked integration. Archive the crew afterward;
113-
worktrees are torn down only after agents are released. In shared mode the work
114-
is already on your branch; review the diff and commit as usual.
163+
Archive the crew after its selected work has been applied. Worktrees are torn
164+
down only after agents are released. In shared mode there are no isolated lane
165+
branches to merge: review the shared branch diff and commit as usual.

‎src/main/crew-integration-verification.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,59 @@ describe('crew combined integration verification', () => {
7979
expect(existsSync(integrationPath)).toBe(false)
8080
})
8181

82+
it('reports the lane and conflicted files instead of only Git rerere noise', async () => {
83+
const f = fixture()
84+
write(f.repo, 'migration.sql', 'CREATE TABLE users (account_id INTEGER);\n')
85+
git(f.repo, 'add', '.')
86+
git(f.repo, 'commit', '-m', 'base changes migration differently')
87+
const movedBase = git(f.repo, 'rev-parse', 'HEAD')
88+
const integrationPath = join(f.repo, '.crew-integration')
89+
90+
const result = await verifyCrewIntegration({
91+
repoPath: f.repo, integrationPath, integrationCwd: integrationPath,
92+
baseBranch: 'main', baseHead: movedBase,
93+
lanes: [
94+
{ laneId: 'migration', label: 'Migration', branch: 'lane/migration', head: f.migrationHead, worktreePath: '/migration', files: ['migration.sql'] },
95+
],
96+
retentionRef: 'refs/crewcode/integration/conflict-test',
97+
}, runner, async cwd => suggestedCrewChecks(cwd), runCheck)
98+
99+
expect(result.status).toBe('conflict')
100+
if (result.status !== 'conflict') return
101+
expect(result.conflicts).toEqual(['migration.sql'])
102+
expect(result.error).toContain('Could not combine lane/migration')
103+
expect(result.error).toContain('conflicted files: migration.sql')
104+
})
105+
106+
it('verifies with a dirty base and preserves base changes while applying in the background', async () => {
107+
const f = fixture()
108+
const integrationPath = join(f.repo, '.crew-integration')
109+
const request = {
110+
repoPath: f.repo, integrationPath, integrationCwd: integrationPath,
111+
baseBranch: 'main', baseHead: f.baseHead,
112+
lanes: [
113+
{ laneId: 'migration', label: 'Migration', branch: 'lane/migration', head: f.migrationHead, worktreePath: '/migration', files: ['migration.sql'] },
114+
],
115+
retentionRef: 'refs/crewcode/integration/dirty-test',
116+
}
117+
118+
write(f.repo, 'model.ts', 'export const primaryKey = "local-draft"\n')
119+
git(f.repo, 'add', 'model.ts')
120+
write(f.repo, 'local-notes.txt', 'untracked notes\n')
121+
122+
const verified = await verifyCrewIntegration(request, runner, async cwd => suggestedCrewChecks(cwd), runCheck)
123+
expect(verified.ok).toBe(true)
124+
if (!verified.ok) return
125+
126+
const applied = await applyCrewIntegration({ ...request, integrationHead: verified.integrationHead }, runner)
127+
expect(applied).toEqual({ ok: true })
128+
expect(git(f.repo, 'rev-parse', 'main')).toBe(verified.integrationHead)
129+
expect(readFileSync(join(f.repo, 'model.ts'), 'utf8')).toContain('local-draft')
130+
expect(readFileSync(join(f.repo, 'local-notes.txt'), 'utf8')).toContain('untracked notes')
131+
expect(git(f.repo, 'diff', '--cached', '--name-only')).toBe('model.ts')
132+
expect(git(f.repo, 'status', '--short')).toContain('?? local-notes.txt')
133+
})
134+
82135
it('retains the exact passing candidate and applies it only when inputs remain unchanged', async () => {
83136
const f = fixture()
84137
// Make the API lane compatible with the migration lane.

0 commit comments

Comments
 (0)