Skip to content

Conversation

grahama1970
Copy link

@grahama1970 grahama1970 commented Sep 27, 2025

Title

CLI/TUI: show resume file path; picker [project] tag; plain verify


Summary

Problems

  • CLI did not show the rollout file when resuming, making it slow to find/inspect state.
  • TUI resume list lacked project context to disambiguate sessions.
  • Resumed TUI view did not surface the rollout path.

Fixes

  • CLI (human output): print resume file: with the absolute rollout path in the initial config summary on resume.
  • TUI (picker): prepend a bracketed [project] tag (derived from SessionMeta.cwd basename) after the time.
  • TUI (resumed header): print a resume file: line directly under the header when resuming.
  • Dev helpers: plain picker verification (no alt‑screen) + optional pre‑filter, to make local/CI checks trivial.

Scope

  • Presentation only (CLI/TUI). No protocol or JSON output changes. No request construction or resume semantics changed.

Risk

  • Low. Changes are confined to rendering, with guards for tiny terminals, non‑UTF‑8 paths, and non‑TTY environments.

User‑Visible Changes

CLI

  • New line in the config summary (on resume):
    • resume file: /absolute/path/to/sessions/YYYY/MM/DD/rollout-...jsonl
  • Placement: inside the initial summary block, before the divider and “User instructions:”.

TUI

  • Resume picker rows now show:
    • > 1 minute ago [project] preview…
    • [project] = basename(SessionMeta.cwd); styled cyan + bold.
    • Previews are single‑line and truncated if needed.
  • Resumed view header prints a resume file: line directly under the header on resume.

Implementation Notes

CLI

  • File: codex-rs/exec/src/event_processor_with_human_output.rs
  • In print_config_summary (resume only):
println!("{} {}", "resume file:".style(self.bold), ev.rollout_path.display());

TUI — Resume picker [project] tag

  • File: codex-rs/tui/src/resume_picker.rs
  • Derive project from SessionMeta.cwd basename in head_to_row (UTF‑8 safe).
  • Render tag after the time: format!("[{}]", tag).cyan().bold().
  • Layout guards: saturation math for tiny terminals; display‑width aware truncation for previews.

TUI — Resumed header resume file: line

  • File: codex-rs/tui/src/history_cell.rs
  • On first event of a resumed run, insert a plain history line: "resume file:" (dim) + rollout_path.display().

Dev‑only verification helpers

  • File: codex-rs/tui/src/resume_picker.rs
  • Plain mode: if CODEX_TUI_PLAIN=1, print picker rows and exit (honors NO_COLOR/TERM=dumb).
  • Filter: if CODEX_TUI_FILTER is set, pre‑filter rows by substring match over [project], preview, or path.

Change Surface

  • codex-rs/exec/src/event_processor_with_human_output.rs
  • codex-rs/tui/src/resume_picker.rs
  • codex-rs/tui/src/history_cell.rs
  • minor: codex-rs/tui/src/lib.rs (panic hook to leave alt‑screen on panic)

Compatibility

  • JSON output: unchanged.
  • Protocol: unchanged; uses existing SessionConfiguredEvent.rollout_path.
  • Styling: respects terminal color settings; degrades gracefully when color/TTY is unavailable.

Testing Plan

Automated

cd codex-rs
cargo test -p codex-exec
cargo test -p codex-tui

Manual (network‑free via SSE fixture)

cd codex-rs
cargo build --workspace

export CODEX_HOME=/tmp/codex-resume-demo
rm -rf -- "$CODEX_HOME"; mkdir -p -- "$CODEX_HOME"

export OPENAI_API_KEY=dummy
export OPENAI_BASE_URL=http://unused.local
export CODEX_RS_SSE_FIXTURE="$PWD/exec/tests/fixtures/cli_responses_fixture.sse"

# Seed sessions
target/debug/codex-exec --skip-git-repo-check -C "$PWD" "echo MARK1" >/dev/null
target/debug/codex-exec --skip-git-repo-check -C /tmp  "echo MARK2"  >/dev/null

# CLI summary shows rollout path
target/debug/codex-exec --skip-git-repo-check -C "$PWD" "echo MARK2" resume --last | sed -n '1,30p'

# TUI picker + header
script -q -c 'TERM=${TERM:-xterm-256color} target/debug/codex resume' /dev/null

# Plain verification (no TUI)
CODEX_TUI_PLAIN=1 target/debug/codex resume
# Optional filter
CODEX_TUI_FILTER=codex CODEX_TUI_PLAIN=1 target/debug/codex resume

Accessibility & Styling

  • [project] tag uses cyan + bold in TUI (consistent with existing status styling).
  • In plain/TTY‑limited environments, color is omitted (respects NO_COLOR and TERM=dumb).
  • Previews are single‑line and truncated to prevent overflow.

Performance, Security, Privacy

  • Performance: negligible; uses existing head reads; a few extra spans in the TUI.
  • Security/Privacy: prints only a local file path already on disk; no secrets. Honors color/TTY env; onboarding flows untouched.

Risks & Mitigations

  • Non‑UTF‑8 cwd: guarded.
  • Tiny terminals: width saturation + truncation.
  • Non‑TTY: panic hook leaves alt‑screen on error; plain mode avoids alt‑screen entirely.

Rollout / Backout

  • Safe to land. If issues arise:
    • Revert TUI row/header independently of the CLI summary line.
    • Disable the developer‑only env helpers if desired (no user‑facing surface).

Developer Notes

  • Formatting: cd codex-rs && just fmt
  • Lints: cd codex-rs && just fix -p codex-exec && just fix -p codex-tui
  • Snapshot tests: not affected; JSON/protocol unchanged.
  • Local artifacts: keep local/ out of repo history (use .git/info/exclude).

Copy link

github-actions bot commented Sep 27, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

fn apply_filter(&mut self) {
if self.query.is_empty() {
self.filtered_rows = self.all_rows.clone();
} else {
let q = self.query.to_lowercase();
self.filtered_rows = self
.all_rows
.iter()
.filter(|r| r.preview.to_lowercase().contains(&q))
.cloned()
.collect();

[P1] Query filtering ignores project tag and path

The new /resume <query> flow depends on being able to filter by the [project] tag or rollout path, but the filtering logic still only checks Row.preview. apply_filter lowercases the query and returns rows where r.preview contains the substring, never examining r.project or r.path. A command like /resume tmp (or the CODEX_TUI_FILTER env var) will therefore not match sessions whose project tag is [tmp] unless the preview text also contains tmp. This makes the advertised project/path filtering ineffective.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

@grahama1970 grahama1970 force-pushed the feat/exec-tui-resume-path-and-project branch 2 times, most recently from 0833f5d to e305be7 Compare September 27, 2025 20:03
@grahama1970
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Sep 27, 2025
@grahama1970
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@grahama1970 grahama1970 changed the title CLI/TUI: show resume file path; picker [project] tag CLI/TUI: show resume file path; picker [project] tag; plain verify Sep 27, 2025
…y + filter; panic hook for alt-screen cleanup; tests green

Signed-off-by: Graham Anderson <graham@grahama.co>
@grahama1970 grahama1970 force-pushed the feat/exec-tui-resume-path-and-project branch from e305be7 to 4b863cc Compare September 27, 2025 20:34
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