Repository navigation
Conversation
102bef5 to
fd7cc25
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryIncremental pass over commit Assumptions: Files Reviewed (5 files)
Previous Review Summaries (10 snapshots, latest commit b5b4ed4)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit b5b4ed4)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryIncremental pass over the rebase that renamed the read-model migration to Assumptions: Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit fb53aed)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryBoth new findings are migration/documentation hygiene: the accepted plan still names the pre-renumbering migration, and one added concurrent index has no query that consumes its third column. Assumptions: Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (14 files)
Fix these issues in Kilo Cloud Previous review (commit d66c3f9)The review did not run because the selected model is no longer available. Choose another model in Kilo Code review settings: https://app.kilo.ai/code-reviews Previous review (commit d66c3f9)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental range since the previously reviewed head contains only a test-fixture UUID update in the AI-gateway usage client tests, so the sole remaining item is the unchanged unbounded root-chat payload in workspace summaries, retained by design in the open human design thread. Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files this pass)
Fix these issues in Kilo Cloud Previous review (commit cb9f462)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental range since the previously reviewed head contains no new PR-side code: the only content difference in PR files is the migration renumber to Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files this pass)
Fix these issues in Kilo Cloud Previous review (commit b1ed85a)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental range contains no PR-side code changes: Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files this pass)
Previous review (commit d91886d)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental fix narrows the stack lookup to root chats that resolve to a seed-repository PR base branch and now compares repository and branch together, resolving both prior findings; the only remaining issue is the unchanged unbounded root-chat payload in workspace summaries, retained by design in an open human thread. Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files this pass)
Fix these issues in Kilo Cloud Previous review (commit 1a68ca4)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe attempted fix for null checkout URLs filters rows after admission rather than admitting fewer rows: because Assumptions: Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (1 changed file this pass)
The remaining 99 PR files are byte-identical to the previously reviewed head Fix these issues in Kilo Cloud Previous review (commit da42cfe)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe highest-risk remaining issue is that every workspace summary still carries every root chat of that workspace with no bound, so the payload the sidebar re-fetches on each live event and 30s poll grows without limit for a long-lived workspace; the second is a residual scope-wide null-repository fallback in the stack CTE that expands a one-stack lookup to the user's whole scope. Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (100 files)
Fix these issues in Kilo Cloud Previous review (commit 504e11a)Status: 4 Issues Found | Recommendation: Address before merge Executive SummaryThis incremental pass (11 files, +275/−32 since Assumptions: [Snapshot truncated.] Additional previous summary content was truncated to keep this comment within platform limits. Reviewed by deepseek-flash-latest · Input: 34.3K · Output: 4.7K · Cached: 402.1K Review guidance: REVIEW.md from base branch |
iscekic
left a comment
There was a problem hiding this comment.
bot: Automated full review with end-to-end evidence for this pull request, requested by @eshurakov.
This PR moves the Cloud Agent sidebar onto a PostgreSQL read model. It adds listWorkspaceSummaries/readWorkspaceSummaries/readWorkspaceChatPage (workspace-read-model.ts, workspace-read-model-queries.ts) with server-side activity aggregation, stack destinations and visibility limits; moves closed-tab and tab-order state onto cloud_agent_worktrees (closed_session_ids, tab_order, plus five new tRPC tab mutations in workspace-tab-state.ts); adds a workspace.updated event end to end (session-ingest protocol, DO broadcast, SDK schema, useSidebarLiveUpdates); and replaces sidebar-wide worktreeDetails reads with hydrated summaries. Migration 0361_workspace_read_model adds the columns, five indexes with the repository's retry-safe concurrent-index pattern, and a last_activity_at backfill.
What I verified on this VM, from the checkout, against a real local Postgres migrated by this PR and the real web app driven through Chromium:
- Typecheck clean for the web app and the three touched packages; db jest 75, cloud-agent-next jest 2888, router/sidebar jest 537, workspace lib jest 34, session-ingest vitest 1781 (+85 postgres), SDK jest 2447 all passing.
- Migration bootstrap on an empty database, and its SQL replayed twice without error.
- Tab close, reopen, reorder and reload all persisted through the new mutations, and a second browser with cleared local storage showed the state that came from the server; foreign worktree and foreign chat ids returned 404.
- Chat pagination read 123 chats across three cursor pages with no gaps or duplicates; workspace
lastActivityAtused the newer of workspace and session activity; an idle sidebar made noworktreeDetailscalls and no summary polling.
The thing to fix first is the shape of the summary payload: every visible workspace ships every root chat with no bound. One workspace with 2001 chats cost 522 KB, and the 50-workspace sidebar page cost 609 KB, on the request that live events and polling re-fetch. After that, the ungrouped cap of 50 silently hides workspaces because nextCursor is only produced for searches, so the new “Load more workspaces” button cannot appear for the default list and the removed “limited to…” note leaves the user with no signal. Smaller items: workspaceTabDeletionUpdate and the workspaceRowsTruncated prop are now dead, and the truncation it.each case tests a value the component ignores.
No blocker found: no data loss or authz hole observed, and every build, typecheck and suite I could run passed. iOS was not exercised (no simulator or signing identity on this VM); the change adds no iOS code.
E2E: run.
Ran the real Next.js app (next dev on the checkout) against a local PostgreSQL 18 migrated by this PR's own migrations, with a fake-login user, and drove it with Playwright Chromium. iOS is out of scope on this VM, and the change touches no iOS surface; Android and the CLI were not needed because the changed behavior is the web sidebar, the tRPC read model and the session-ingest worker.
Setup and checks that ran green:
packages/dbmigration bootstrap to an empty database:0361_workspace_read_modelapplied, addingclosed_session_ids,tab_order,last_activity_atand the four concurrent indexes; re-running its SQL a second time succeeded (drop-if-exists plus the DO guard), so it is retry-safe. Covered by the schema checknpx jestin packages/db: 75 passed.- Web typecheck (
tsgo --noEmit), plus tsgo for packages/db, packages/cloud-agent-sdk and services/session-ingest: clean. apps/webjest: cloud-agent-next suite 2888 passed (164 suites), routers/cli-sessions-v2 + workspace-folders + server 537 passed, workspace-tab-state/session-events/workspace-activity 34 passed.services/session-ingestvitest: 1781 passed, 3 skipped; postgres config: 85 passed.packages/cloud-agent-sdkjest: 2447 passed.
Happy path, observed in the running app (tab-sync-transcript.log, screenshots 01-06):
- Sidebar rendered the seeded workspaces from
cliSessionsV2.listWorkspaces(01-sidebar-workspaces.png). - Opening a worktree showed both root chats as tabs (
A tabs open: ["Alpha root chat","Alpha chat two"], 02-browser-a-two-tabs.png). - Closing one tab removed it and persisted to the row (
closed_session_ids = {ses_alpha_root_0002},tab_order = {ses_alpha_root_0001}); after a reload the tab stayed closed (03-browser-a-after-close.png). - A second browser context with
localStorage.clear()showed the same single open tab, so the state came from the server, not the browser (B tabs (empty localStorage): ["Alpha root chat"], 04-browser-b-server-state.png). - Opening the closed chat's address reopened its tab (
B tabs after reopening: ["Alpha root chat","Alpha chat two"], 05-browser-b-reopened.png) and the first browser showed the same after reload (06-browser-a-sees-reopen.png). - Reorder through the real mutation moved
tab_orderto{ses_alpha_root_0002,ses_alpha_root_0001}and the tabs rendered in that order after reload (reorder.log). - Foreign input is refused: closing an unknown chat id and closing a chat under a workspace the user does not own both returned 404
Workspace chat not found(reorder.log).
Pagination, activity and cost measurements (pagination.log, list-payload.log, summary-payload.log, truncation.log, search-paging.log, requests-idle.log): 123 chats read across three pages (50/50/23) with keyset cursors, 123 unique, no gaps or duplicates; the workspace lastActivityAt equalled the greater of workspace and session activity; one workspace with 2001 chats produced a 522 KB summary and the 50-workspace sidebar page produced 609 KB; an idle sidebar issued no worktreeDetails calls and no workspace polling over 30 s.
The ungrouped cap was observed as a problem and is reported as a remark, not a blocker: with 63 ungrouped workspaces only 50 rendered and no cap or paging message appeared.
Every remark is attached to the changed line where GitHub accepts one.
This service never pushes, rebases, forces, closes, labels, or merges, and it posts nothing else on this pull request.
| LEFT JOIN workspace_open_runs open_runs ON open_runs.worktree_id = w.worktree_id | ||
| LEFT JOIN LATERAL (${workspacePrQuery(sql`${workspacePrFields}, pr_observations`)}) pr ON true | ||
| INNER JOIN LATERAL ( | ||
| SELECT jsonb_agg(${chatJson} ORDER BY s.created_at, s.session_id) AS chats |
There was a problem hiding this comment.
Every workspace summary carries every root chat of that workspace, with no LIMIT. hydrateWorkspaceChats aggregates all visible chats per worktree here, and hydrateWorkspaces puts that array on each row the sidebar renders.
Measured on the local stack against this checkout, with one workspace holding 2001 root chats:
cliSessionsV2.workspaceSummariesfor that single workspace returned 522 KB (openChats: 2001), against 13 KB for one 50-chat page ofcliSessionsV2.workspaceChats.cliSessionsV2.listWorkspaces(limit 200, 50 visible workspaces) returned 609 KB with 2173 chats carried.
This is the payload that useSidebarLiveUpdates re-fetches through workspaceSummaries on each coalesced live event and each 30s running poll, and that useClosedWorktreeChatTabs.refresh re-fetches after every tab mutation. A long-lived worktree grows this without bound, so the request that the PR intended to make heavy lists cheap is the one that keeps every chat of every visible workspace in memory and on the wire. The sidebar itself only needs the ordered open tabs, the closed-tab ids and the representative session.
Smallest fix: bound the aggregate in this lateral join (for example recent chats plus the closed ids the row already names), and let the new paged workspaceChats procedure serve history. If a cap is chosen, make openChats/chatCount reflect it so the UI can show that history is truncated.
There was a problem hiding this comment.
The payload growth is real. The current design explicitly retains every open and closed tab summary (docs/plans/cloud-agent-workspace-read-model.md, sections 2, 6, and 9). Chat membership defines open tabs unless the user closes them. Capping openChats here would silently hide open tabs and change tab navigation, synchronization, and counts. I have not added that contract change during review preparation. Separating compact sidebar summaries from paginated selected-workspace tabs needs an agreed API/UI change and dedicated verification. This thread remains open for that decision; the current PR does not solve payload growth within one long-lived workspace.
504e11a to
bfd1cd9
Compare
Review preparation verification
EvidenceThe adopted chat no longer appears as a standalone sidebar row: The ungrouped list reports its limit and total: |
da42cfe to
1a68ca4
Compare
Use PostgreSQL workspace summaries, paginate chat history, and synchronize tab state across clients. Limit incomplete-checkout stack candidates without dropping explicit links or inferred ancestors.
d91886d to
b1ed85a
Compare
Use PostgreSQL workspace summaries, paginate chat history, and synchronize tab state across clients. Limit incomplete-checkout stack candidates without dropping explicit links or inferred ancestors.
b1ed85a to
cb9f462
Compare
Apply the fixture-only fix from #11569 to clear the required web CI failure on the PR branch. The response validator and test assertions are unchanged.


Current review preparation (2026-11-17)
da42cfe59f43067acd5c24fea29f2555e2fe1168.da42cfe59f43067acd5c24fea29f2555e2fe1168. All check runs completed; none currently fail.Summary
Local manual verification
Tests used the real local web app, PostgreSQL, Session Ingest Worker, and WebSocket connections. Metadata fixtures were synthetic.
worktreeDetailsrequests.The local stack and test browsers were stopped after verification.
Automated verification
docs/plans/cloud-agent-workspace-read-model.md.Verification limits
0363_workspace_read_modelpreserves the eight generated DDL statements and concurrent-index retry safety. The unnecessary deployment backfill is removed; reads handle null or stale activity.pnpm validaterun.Earlier review preparation
worktreeDetailsrequests, persisted tab close, and event-driven reopen. Local services and the test browser were stopped afterward.Earlier CI status
c301aea39c319f11b9c53b70d3594ced86e9e110.cloud-agent-next (other)job passed on its single retry. Its first run failed an unchanged daemonized-process cleanup test; no test was disabled or changed.Evidence
Screenshots show only synthetic fixture data and the tested sidebar/tab regions.