-
Notifications
You must be signed in to change notification settings - Fork 38
feat(sessions): switch web session list from unified to cli sessions v2 endpoint #2478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Session List V2 Migration | ||
|
|
||
| Switch the web cloud-agent session list from the unified session endpoint to the CLI session v2 endpoint, and ensure sessions are grouped by updated time. | ||
|
|
||
| ## Background | ||
|
|
||
| All session list consumers currently call `unifiedSessions.list` — a tRPC procedure in `apps/web/src/routers/unified-sessions-router.ts` that runs a `UNION ALL` across both `cli_sessions` (v1) and `cli_sessions_v2` tables. | ||
|
|
||
| A dedicated `cliSessionsV2.list` procedure already exists in `apps/web/src/routers/cli-sessions-v2-router.ts:229` that queries only `cli_sessions_v2`. | ||
|
|
||
| For grouping, the sidebar in `ChatSidebar.tsx:49` already uses `session.updatedAt`, and all consumers pass `orderBy: 'updated_at'`. The schema default in `ListSessionsInputSchema` is still `'created_at'` though, which should be cleaned up. | ||
|
|
||
| --- | ||
|
|
||
| ## Task 1: Switch session list to `cliSessionsV2.list` | ||
|
|
||
| ### Consumers to update | ||
|
|
||
| | File | Line | Usage | | ||
| | ---------------------------------------------------------------------- | ---- | ----------------------------------- | | ||
| | `apps/web/src/components/cloud-agent-next/hooks/useSidebarSessions.ts` | 89 | `unifiedSessions.list` query | | ||
| | `apps/web/src/app/(app)/cloud/sessions/SessionsPageContent.tsx` | 78 | `unifiedSessions.list` query | | ||
| | `apps/web/src/components/cloud-agent/CloudSessionsPage.tsx` | 471 | `unifiedSessions.list` query | | ||
| | `apps/web/src/components/cloud-agent-next/CloudChatPage.tsx` | 151 | `unifiedSessions.list` invalidation | | ||
| | `apps/web/src/components/cloud-agent-next/CloudSidebarLayout.tsx` | 138 | `unifiedSessions.list` invalidation | | ||
| | `apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx` | 653 | `unifiedSessions.list` invalidation | | ||
|
|
||
| ### Steps | ||
|
|
||
| 1. **Compare input/output schemas** between `unifiedSessions.list` and `cliSessionsV2.list` — identify field name or shape differences that consumers depend on (e.g., `source` field, column mapping, cursor format). | ||
| 2. **Update each query consumer** to call `cliSessionsV2.list` instead of `unifiedSessions.list`. | ||
| 3. **Update each invalidation consumer** to invalidate `cliSessionsV2.list` instead of `unifiedSessions.list`. | ||
| 4. **Update search** — `unifiedSessions.search` is also a `UNION ALL`. Switch search callers to a v2-only equivalent. May need to add a `search` procedure to the v2 router if one doesn't exist. | ||
| 5. **Update `recentRepositories`** — currently on the unified router, also a `UNION ALL`. Either add to v2 router or migrate. | ||
| 6. **Typecheck** — run `pnpm typecheck` to catch schema mismatches from the migration. | ||
| 7. **Consider deprecation** — decide whether to remove or keep the unified router for backward compatibility. | ||
|
|
||
| --- | ||
|
|
||
| ## Task 2: Group sessions by updated time | ||
|
|
||
| ### Current state | ||
|
|
||
| - `ChatSidebar.tsx:49` — `groupSessionsByDate` already groups by `session.updatedAt`. This is correct. | ||
| - All consumers already pass `orderBy: 'updated_at'` to the list query. | ||
| - The `ListSessionsInputSchema` default for `orderBy` is `'created_at'` (unified-sessions-router.ts:40). | ||
|
|
||
| ### Steps | ||
|
|
||
| 1. **Audit all `createdAt`/`created_at` usage** in session-related ordering or display code. | ||
| 2. **Change the default `orderBy`** in `ListSessionsInputSchema` from `'created_at'` to `'updated_at'` — and similarly in the v2 router input schema if applicable. | ||
| 3. **Verify** `SessionsPageContent` and other full-page session views aren't sorting by `createdAt`. | ||
| 4. **Verify** the v2 router's `list` procedure supports `orderBy: 'updated_at'` and uses it correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Switching the sidebar to
cliSessionsV2drops legacy sessionsunifiedSessions.listwas the only query here that still UNIONedcli_sessionsandcli_sessions_v2. After this swap, any user whose history still lives incli_sessionsloses those sessions from the sidebar/search immediately, even though the PR keeps the unified router around for backward compatibility. Unless every legacy row has already been backfilled intocli_sessions_v2, this is a breaking regression.