[codex] add Codex session selection support#535
Open
dsus4wang wants to merge 1 commit intotiann:mainfrom
Open
Conversation
There was a problem hiding this comment.
Findings
- [Major] Scope Codex session discovery to the runner workspace —
listCodexSessions()currently walks every transcript underCODEX_HOME/sessions, so a runner started with--workspace-rootcan expose session titles and absolute paths from projects outside that root through/api/machines/:id/codex-sessions. Existing directory listing and spawn paths enforce the workspace root, but this new machine handler bypasses that boundary. Evidence:cli/src/modules/common/codexSessions.ts:194.
Questions
- None.
Summary
- Review mode: initial
- One issue found: Codex session discovery needs the same workspace-root scoping as the rest of machine browsing/spawn before exposing transcript metadata to the web UI.
Testing
- Not run:
bunis not installed in this runner image (bun: command not found).
HAPI Bot
| ? Math.floor(Number(request.cursor)) | ||
| : 0; | ||
|
|
||
| const sessionsDir = join(readCodexHome(), 'sessions'); |
There was a problem hiding this comment.
[MAJOR] Scope Codex session discovery to the runner workspace. This walks every Codex transcript under CODEX_HOME/sessions, so a runner configured with --workspace-root can still expose titles and absolute paths for sessions outside that root through the new web endpoint. Existing machine directory/spawn paths enforce the workspace boundary; this new handler should filter the discovered sessions before returning them.
Suggested fix:
export async function listCodexSessions(
request: ListCodexSessionsRequest = {},
options: { workspaceRoot?: string } = {}
): Promise<{ sessions: CodexSessionSummary[]; nextCursor: string | null }> {
const workspaceRoot = options.workspaceRoot ? await fs.realpath(options.workspaceRoot).catch(() => options.workspaceRoot) : null;
// ...after building sorted:
const scoped = workspaceRoot
? sorted.filter((entry) => entry.path && isPathWithinWorkspace(entry.path, workspaceRoot))
: sorted;
const filtered = includeOld ? scoped : scoped.filter((entry) => !entry.isOld);
}
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds Codex session selection to the new-session flow so users can browse and resume existing local Codex sessions from the web UI.
Changes
Validation