Repository navigation
fix(crew-window): open a crew session at its newest message and follow new rows - #39076
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a small, local scroll-follow in the component that owns the scroller, using the same follow pattern as [DESIGN-REVIEWED] e4da0c4 Description read[DESCRIPTION-READ] a7e17acbebdf15d0503709ab81a656547c3d76d1633cacf09e619f92cebc34bb That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix is at mechanism level: the crew window's own scroller never set a scroll position, and this change makes it do so. Moving onto the virtualizer is excluded as a non-goal. What this change shipsInventory (6 items) — 6 justifiedIntent: open a remote crew session in the crew window at its newest message and keep following new messages, as the local chat does. FIX (#39041).
[FIRST-PRINCIPLES-REVIEWED] e4da0c4 Description read[DESCRIPTION-READ] 6085d7bbf7805bab8963f4881c2ed76f9948efd2e3d00e78e172eb53500bb168 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: no control is added or changed, and the four screenshots show the window opening at the newest message and following a new reply. Notes
[UX-REVIEWED] e4da0c4 Description read[DESCRIPTION-READ] f3b96795bc21ffd254a4ce9d2178d0bc94f6a7b32bd0a76549a095676c4071d9 That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
Screenshot harness behind the before/after frames in the description, kept out of the diff (it duplicated capture-crew-window-scroll.mjs/**
* Screenshot harness: the crew chat window opens a long transcript at its
* newest message and follows a reply that lands while the reader is at the
* bottom, as the local chat does.
*
* Runs the REAL built SPA behind the shared in-process static server with every
* /api/** answered from fixtures (gateway-free), opens a peer row with a long
* transcript into the crew window and shoots it, then lands one more reply
* through the peer feed and shoots again. Each frame logs how far the view sits
* from the bottom. The screenshots are written BEFORE the assertions, so a
* failing run still leaves the frames to look at.
*
* Usage: [DIST=<dist dir>] node scripts/capture-crew-window-scroll.mjs [outDir] [prefix]
* `DIST` points the server at another build (the pre-fix frames come from main's).
*/
import { chromium } from 'playwright'
import { mkdirSync } from 'node:fs'
import { serveDist } from './lib/serve-dist.mjs'
import { logPageProblems, stubDashboardApi, json } from './lib/stub-dashboard-api.mjs'
const OUT = process.argv[2] || '../temp-screenshots/crew-window-scroll'
const PREFIX = process.argv[3] || 'after'
mkdirSync(OUT, { recursive: true })
const PREVIEW_INSTANCE_SESSIONS = 'mc-preview-instance-sessions'
const ASTRO = {
id: 'astro', name: 'astro', ssh_host: 'astro', remote_port: 5480, local_port: 7778,
ttl: '20h', remote_bin: '', connection_method: 'ssh', ssm_target: '', ssm_run_as: '',
aws_profile: '', aws_region: '', was_connected: true,
status: { instance_id: 'astro', state: 'connected', local_port: 7778, remote_port: 5480 },
}
const SSO = { state: 'ok', seconds_remaining: 72000, expires_at: null, reason: 'valid' }
const PEER_ROW = {
key: 'chat-9', row_identity: 'astro:chat-9', title: 'Watch the release checks',
last_turn_ts: new Date(Date.now() - 60_000).toISOString(), running: false, pending_approval: false, agent: 'default',
}
const PEER_SLOT = { ...PEER_ROW, interrupted: false, pending_approval: false, pending_approval_info: null }
const turns = []
for (let i = 1; i <= 15; i++) {
turns.push({ role: 'user', content: `Check ${i}: how are the release checks doing?`, ts: `u${i}` })
turns.push({ role: 'assistant', content: `Cycle ${i}: backend shards 5 to 8 are still running and PR Readiness waits on them. Nothing has failed so far.`, ts: `a${i}` })
}
let peerMessages = turns
const LOCAL_SLOTS = [{
key: 'chat-local', title: 'Release notes draft', messages: 2, running: false,
agent: 'kirocrew', created: '2026-09-13T20:00:00Z', last_ts: new Date(Date.now() - 120_000).toISOString(), folder_id: '',
}]
/** How far the transcript's view sits above its bottom, in CSS px. */
const gapToBottom = page => page.evaluate(() => {
const dock = document.querySelector('[data-testid="crew-window-dock"]')
const el = dock.previousElementSibling
return Math.round(el.scrollHeight - el.scrollTop - el.clientHeight)
})
async function main() {
const { srv, base } = await serveDist(process.env.DIST || undefined)
const { LD_LIBRARY_PATH: _mise, ...browserEnv } = process.env
const browser = await chromium.launch({ env: browserEnv })
const context = await browser.newContext({ viewport: { width: 1280, height: 820 }, deviceScaleFactor: 2 })
const page = await context.newPage()
await page.addInitScript(() => {
// A peer feed the harness can fire, so a reply lands the way a live one does.
window.__crewFeeds = []
window.EventSource = class {
constructor() { this.listeners = {}; window.__crewFeeds.push(this) }
addEventListener(type, fn) { (this.listeners[type] ||= []).push(fn) }
close() {}
}
})
await stubDashboardApi(page, {
folders: [], slots: LOCAL_SLOTS,
localStorageEntries: { [PREVIEW_INSTANCE_SESSIONS]: '1' },
extra: async (path, route) => {
if (path === '/api/instances') { await json(route, { active: true, instances: [ASTRO], warm_set_cap: 5, sso: SSO }); return true }
if (path === '/api/instances/astro/chat-slots') { await json(route, [PEER_ROW]); return true }
if (path === '/api/instances/astro/capabilities') { await json(route, { instance_id: 'astro', version: '0.9.0', local_version: '0.9.0', version_match: true, agents: [], workspaces: [] }); return true }
if (path === '/api/instances/astro/proxy/api/chat/slots') { await json(route, [PEER_SLOT]); return true }
if (path === '/api/instances/astro/proxy/api/chat/slots/chat-9') {
await json(route, { key: 'chat-9', title: PEER_ROW.title, running: false, messages: peerMessages }); return true
}
if (path === '/api/instances/astro/approval-state') { await json(route, { yolo: false }); return true }
if (path === '/api/instances/astro/connect' || path === '/api/instances/astro/status') {
await json(route, { ...ASTRO.status, token: 'tok' }); return true
}
if (path.startsWith('/api/instances/')) { await json(route, { ok: true }); return true }
if (path === '/api/chat/slots/chat-local') {
await json(route, { messages: [{ role: 'user', content: 'draft', ts: '2026-09-13T20:00:00Z', meta: { mid: 'l-1' } }], has_more: false, total: 1 })
return true
}
return false
},
})
logPageProblems(page)
await page.goto(`${base}/chat?sid=chat-local`, { waitUntil: 'domcontentloaded' })
await page.waitForSelector('[aria-label="Chat messages"]', { timeout: 20_000 })
const row = page.locator('[data-session-row="astro:chat-9"]').first()
await row.waitFor({ state: 'visible', timeout: 15_000 })
await row.click()
const win = page.locator('[data-testid="crew-chat-window"]')
await win.waitFor({ state: 'visible', timeout: 15_000 })
await win.getByText('Cycle 15:').waitFor({ state: 'attached', timeout: 15_000 })
await page.mouse.move(900, 60)
await page.waitForTimeout(800)
const shot1 = `${OUT}/${PREFIX}-1-open.png`
await page.screenshot({ path: shot1 })
const openGap = await gapToBottom(page)
console.log(`wrote ${shot1}; gap to bottom ${openGap}px`)
// Scene 2: a reply lands on the peer while the window is open.
peerMessages = [...turns, { role: 'assistant', content: 'Cycle 16: all checks passed. The PR is ready to merge.', ts: 'a16' }]
await page.evaluate(() => {
for (const es of window.__crewFeeds) for (const fn of es.listeners.chat_message || []) fn({ data: JSON.stringify({ slot: 'chat-9' }) })
})
await win.getByText('Cycle 16:').waitFor({ state: 'attached', timeout: 15_000 })
await page.waitForTimeout(800)
const shot2 = `${OUT}/${PREFIX}-2-new-reply.png`
await page.screenshot({ path: shot2 })
const replyGap = await gapToBottom(page)
console.log(`wrote ${shot2}; gap to bottom ${replyGap}px`)
await browser.close()
srv.close()
if (openGap > 48 || replyGap > 48) {
console.error(`FAIL: the transcript is not at its newest message (open ${openGap}px, after a reply ${replyGap}px from the bottom)`)
process.exit(1)
}
console.log('OK: opens at the newest message and follows a new reply')
}
main().catch(err => { console.error(err); process.exit(1) }) |
4377840 to
ff857b1
Compare
ff857b1 to
e4da0c4
Compare
|
self-added: yes
|
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. The PR does what it says: the crew window now opens at the newest message and follows new rows. It adds a Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. This review checked head e4da0c4. The scroller and the new content wrapper always mount, so the ResizeObserver always attaches. followBottom resets for each new target because the window is keyed per session. dockH in the effect deps handles dock growth, which the observer cannot see. The composer glass layout (padding and scrollbar gutter) is unchanged. Each new test fails without its production hunk and is deterministic (no sleeps or clocks, and the stubs are restored). No AUTOSDE blocking rule applies, and nothing already on main or in another open PR duplicates this.
Done well: the fix sits on the crew window's own scroller, which no virtualizer manages, and reuses the follow pattern ActivityViewer.tsx already uses. The tests separate the observer path from the layout effect path.
Optional:
send()in CrewChatWindow.tsx does not setfollowBottom.current = true. A reader who has scrolled up and then sends does not return to the bottom, unlike the local chat with its scrollOnSend setting. This is not a regression and could be a follow-up.- No test covers dock growth, the running state, the approval row, or a reader within the 48px slack. One dock-growth case and one "30px above the bottom" case would pin those.
Problem / Motivation
Goal: A remote crew session opened in the crew window starts at its newest message and stays there as new messages arrive, like the local chat.
Opening a connected crew's session from the shared Sessions list puts the crew window at the FIRST message. To read the latest turn you scroll all the way down, and a reply that lands while the window is open does not move the view either. Opening the same session from the crew's own tab starts at the latest message.
Why it matters
Everyone who uses Chat on a crew hits it on every session long enough to scroll. The newest turn, which is usually why the window was opened, starts out of sight, and a live reply arrives below the fold with nothing to show it came in.
Not a goal
What changed (motivation → approach → change)
CrewChatWindow's scroller (div.absolute.inset-0.overflow-y-auto) is handed only touseComposerDockMetrics. Nothing ever sets its scroll position. The local chat gets its bottom pin from the virtualizer behindChatMessageList, which the crew window does not use.website/src/pages/chat/crew-window/CrewChatWindow.tsx): afollowBottomref, true at mount. The scroller'sonScrollsets it to whether the view is within 48px of the bottom. A layout effect on the transcript rows, the running state, the pending approval and the dock height scrolls to the bottom whilefollowBottomholds, and aResizeObserveron the transcript content does the same when a row grows later by itself (an image or a Mermaid diagram that finishes drawing). So the window opens at the newest message, follows replies, late-growing rows and dock growth, and leaves a reader who scrolled up where they are. This is the same follow patternActivityViewer.tsxuses on its own lists.git log -SforscrollTop,scrollTo,scrollHeight,scrollToBottomanduseVirtualChaton the file finds nothing, so this undoes no earlier change. feat(chat): open crew sessions as a window onto the peer's own slot #16757, feat(chat): draw the crew window with the shared transcript and composer #18095 and fix(crew-window): float the composer in the local dock shape, not a glass band #23930 state no scroll placement.Backwards compatibility
Compatible: only the window's scroll position changes; no route, prop, stored key or contract changes.
Removes nothing: the diff adds a scroll handler and a layout effect and takes nothing away.
Tests
website/src/test/CrewChatWindow.test.tsx, newtranscript scroll positionblock (happy-dom given a 400px viewport over a measured content height):opens at the newest message, not the first: the scroller sits at its full scroll height once the peer's rows land.follows a new reply at the bottom, and keeps the place of a reader who scrolled up: a reply landing through the peer feed moves the view to the new bottom; after the reader scrolls up, the next reply leavesscrollTopunchanged.follows asynchronous content growth without new messages unless the reader scrolled up: content growth with no new message, fired through a fakeResizeObserver, moves the view to the new bottom; a scrolled-up reader is left at 300; returning to the bottom resumes following; the observer disconnects on unmount. Fails without the observer (expected 2000 to be 2600).The first two fail on main (
expected +0 to be 2000,expected +0 to be 2600) and pass with the fix.Proof: not provable -- frontend test (prove.py runs Python only)
Run:
npx vitest run src/test/CrewChatWindow.test.tsx src/test/CrewWindowGuard.test.tsx src/test/composerHost.crewWindowTranscript.test.tsx src/test/crewWindowTranscript.test.ts src/pages/chat/crew-window/ src/pages/ChatPage.views.test.tsx→ 6 files, 140 tests passed.npm run build(includestsc -p tsconfig.app.json),eslinton the changed files andscripts/check_file_line_cap.pypass.Manual verification
A Playwright harness (posted on this PR, not in the diff) runs the real built SPA with fixture APIs, opens a 30-row peer session in the crew window, then lands a reply through the peer feed, and prints how far the view sits from the bottom:
gap to bottom 1625pxon open,1658pxafter the reply (script exits 1).gap to bottom 0pxon open and after the reply.Real-machine verification
Machine: own computer (cloud desktop), Amazon Linux 2, x86_64, 16 vCPU / 61 GB.
Before (main ade7524):
DIST=<main build>/dist node capture-crew-window-scroll.mjs <out> before->FAIL: the transcript is not at its newest message (open 1625px, after a reply 1658px from the bottom)After (head e4da0c4):
node capture-crew-window-scroll.mjs <out> after->OK: opens at the newest message and follows a new replyCleanup: own computer; scratch build worktree removed.
Screenshots / video
Opening the session, before (main) and after:
A reply that lands while the window is open, before and after:
Related Issues
Fixes #39041
Sibling sweep
Swept: git grep -n -l "<ChatMessageList" -- website/src
Sibling: website/src/components/ChatPane.tsx -- not affected -- uses the virtualizer's bottom pin
Sibling: website/src/pages/chat/SideChat.tsx -- not affected -- passes its scroller to the virtualizer, which owns the follow
Sibling: website/src/app-sdk/ChatEmbed.tsx -- not affected -- pins through its list's own scrollToBottom
Pattern harvest
Not generalizable: the crew window is the only
ChatMessageListhost that mounts its own scroller outside the virtualizer.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.