Skip to content

Fix session list cwd pagination#329

Open
OldKrab wants to merge 4 commits into
agentclientprotocol:mainfrom
OldKrab:shushakov/fix-session-list-cwd
Open

Fix session list cwd pagination#329
OldKrab wants to merge 4 commits into
agentclientprotocol:mainfrom
OldKrab:shushakov/fix-session-list-cwd

Conversation

@OldKrab

@OldKrab OldKrab commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • forward ACP's session/list cwd filter to Codex App Server's thread/list
  • apply the filter before App Server pagination and cursor generation
  • match Codex CLI ordering with sortKey: "updated_at" and sortDirection: "desc"
  • leave limit unset so App Server keeps its default page size
  • cover both legacy string-only and newer string-or-array cwd handling
  • rely on App Server as the sole owner of CWD filtering
  • skip expensive global diagnostics when an empty filtered result is expected

Root cause

CodexAcpClient.listSessions requested a global App Server page, then filtered that page locally by cwd. A requested workspace could therefore receive an empty page with a nextCursor belonging to unrelated global results even when matching sessions existed on later pages.

Passing the scalar ACP cwd through to thread/list is compatible with both App Server forms and makes the returned page and cursor belong to the filtered result set. Local post-pagination filtering is removed because App Server now owns exact CWD filtering.

The request also uses the same updated-at descending ordering as Codex CLI. The CWD, opaque cursor, and ordering parameters are forwarded on every page without specifying a page-size limit.

Empty CWD-filtered listings are valid for new worktrees, so they return immediately. The existing three-query diagnostics remain limited to an empty unfiltered global listing; this avoids turning one filtered request into four App Server scans.

Verification

  • npx vitest run src/__tests__/CodexACPAgent/list-sessions.test.ts
  • npm run typecheck
  • npm test (329 passed, 28 skipped)
  • npm run build

@OldKrab
OldKrab marked this pull request as ready for review July 22, 2026 11:16
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