Skip to content

Comments

Cloud Sessions - Unify v1/v2 sessions and refactor ResumeConfigModal#361

Open
eshurakov wants to merge 4 commits intomainfrom
eshurakov/cloud-agent-sessions-all-in-one
Open

Cloud Sessions - Unify v1/v2 sessions and refactor ResumeConfigModal#361
eshurakov wants to merge 4 commits intomainfrom
eshurakov/cloud-agent-sessions-all-in-one

Conversation

@eshurakov
Copy link
Contributor

Summary

  • Adds a unified sessions router (unified-sessions-router.ts) that queries both cli_sessions (v1) and cli_sessions_v2 (v2) tables via UNION ALL, providing a single API for listing and searching sessions across both versions.
  • Migrates the sessions page, sidebar, and deletion hooks from cliSessions/cliSessionsV2 tRPC routes to the new unifiedSessions router.
  • Refactors ResumeConfigModal (cloud-agent-next) to use RepositoryCombobox for repo selection and a free-text branch input, replacing the previous read-only display that derived repo/branch from git_url/git state.
  • Adds githubRepo and branch fields to ResumeConfig/StreamResumeConfig types, and propagates upstreamBranch through to prepareSession.
  • Adds a sub-session filter toggle on the admin sessions page to show/hide child sessions.
  • Makes repository display nullable across SessionsList, ChatSidebar, and the sessions page to handle v2 sessions that don't store git_url.
  • Adds a composite index (kilo_user_id, updated_at) on cli_sessions_v2 for efficient unified query ordering, with corresponding Drizzle migration.

})
);

const isLoadingRepos = isLoadingGitHubRepos && isLoadingGitLabRepos;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Logic bug — && should be ||

With &&, isLoadingRepos is only true when both GitHub and GitLab queries are loading simultaneously. As soon as one finishes, the loading indicator disappears even though the other query is still in-flight, causing the repository list to appear incomplete.

Suggested change
const isLoadingRepos = isLoadingGitHubRepos && isLoadingGitLabRepos;
const isLoadingRepos = isLoadingGitHubRepos || isLoadingGitLabRepos;


// Search filter: ILIKE on title and session_id::text
v1Where.push(
sql`(${cliSessions.title} ILIKE ${`%${search_string}%`} OR ${cliSessions.session_id}::text ILIKE ${`%${search_string}%`})`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: ILIKE wildcard characters (%, _) in search_string are not escaped

If a user searches for a literal % or _, those characters will be interpreted as ILIKE wildcards, producing unexpected results. Consider escaping them before interpolation:

const escaped = search_string.replace(/[%_]/g, '\\$&');

Then use escaped in the ILIKE patterns instead of search_string.

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 19, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/components/cloud-agent-next/CloudChatContainer.tsx 199 Logic bug — && should be || for isLoadingRepos. With &&, loading shows as false when only one provider has finished loading.
src/routers/unified-sessions-router.ts 117 cli_sessions_v2 has a git_url column (see schema) but v2Columns() hardcodes NULL AS git_url. V2 sessions with a git_url will lose that data in the unified view.

SUGGESTION

File Line Issue
src/routers/unified-sessions-router.ts 205 ILIKE wildcard characters (%, _) in search_string are not escaped, so user input containing these characters will be interpreted as SQL wildcards. Consider escaping them.
Files Reviewed (28 files)
  • .gitignore - 0 issues
  • src/app/(app)/cloud/sessions/SessionsPageContent.tsx - 0 issues
  • src/components/cloud-agent-next/ChatSidebar.tsx - 0 issues
  • src/components/cloud-agent-next/CloudChatContainer.tsx - 1 issue
  • src/components/cloud-agent-next/CloudChatPresentation.tsx - 0 issues
  • src/components/cloud-agent-next/CloudNextSessionsPage.tsx - 0 issues
  • src/components/cloud-agent-next/ResumeConfigModal.tsx - 0 issues
  • src/components/cloud-agent-next/SessionsList.tsx - 0 issues
  • src/components/cloud-agent-next/hooks/usePreparedSession.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useResumeConfigModal.test.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useResumeConfigModal.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useSessionDeletion.ts - 0 issues
  • src/components/cloud-agent-next/hooks/useSidebarSessions.ts - 0 issues
  • src/components/cloud-agent-next/session-config.test.ts - 0 issues
  • src/components/cloud-agent-next/store/db-session-atoms.ts - 0 issues
  • src/components/cloud-agent-next/types.ts - 0 issues
  • src/components/cloud-agent/ChatSidebar.tsx - 0 issues
  • src/components/cloud-agent/CloudSessionsPage.tsx - 0 issues
  • src/components/cloud-agent/ResumeConfigModal.tsx - 0 issues
  • src/components/cloud-agent/SessionsList.tsx - 0 issues
  • src/components/cloud-agent/hooks/useSessionDeletion.ts - 0 issues
  • src/components/cloud-agent/hooks/useSidebarSessions.ts - 0 issues
  • src/db/migrations/0021_lazy_adam_warlock.sql - 0 issues (generated)
  • src/db/migrations/meta/0021_snapshot.json - 0 issues (generated)
  • src/db/migrations/meta/_journal.json - 0 issues (generated)
  • src/db/schema.ts - 0 issues
  • src/routers/root-router.ts - 0 issues
  • src/routers/unified-sessions-router.ts - 2 issues

return sql`
${cli_sessions_v2.session_id} AS session_id,
COALESCE(${cli_sessions_v2.title}, 'Untitled') AS title,
NULL AS git_url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: cli_sessions_v2 has a git_url column (see schema line 2115), but this hardcodes NULL. V2 sessions that have a git_url set will never display their repository in the UI.

Was this intentional (e.g., v2 sessions never populate git_url yet), or should this read ${cli_sessions_v2.git_url} AS git_url like the v1 projection?

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