Skip to content

tui: use thread_id for resume/fork cwd resolution#12727

Merged
charley-oai merged 9 commits intomainfrom
cc/thread-id-cwd-resume
Feb 26, 2026
Merged

tui: use thread_id for resume/fork cwd resolution#12727
charley-oai merged 9 commits intomainfrom
cc/thread-id-cwd-resume

Conversation

@charley-oai
Copy link
Collaborator

@charley-oai charley-oai commented Feb 25, 2026

Summary

  • make resume/fork targets explicit and typed as SessionTarget { path, thread_id } (non-optional thread_id)
  • resolve thread_id centrally via resolve_session_thread_id(...):
    • use CLI input directly when it is a UUID (--resume <uuid> / --fork <uuid>)
    • otherwise read thread_id from rollout SessionMeta for path-based selections (picker, --resume-last, name-based resume/fork)
  • use thread_id to read cwd from SQLite first during resume/fork cwd resolution
  • keep rollout fallback for cwd resolution when SQLite is unavailable or does not return thread metadata (TurnContext tail, then SessionMeta)
  • keep the resume picker open when a selected row has unreadable session metadata, and show an inline recoverable error instead of aborting the TUI

Why

This removes ad-hoc rollout filename parsing and makes resume/fork target identity explicit. The resume/fork cwd check can use indexed SQLite lookup by thread_id in the common path, while preserving rollout-based fallback behavior. It also keeps malformed legacy rows recoverable in the picker instead of letting a selection failure unwind the app.

Notes

  • minimal TUI-only change; no schema/protocol changes
  • includes TUI test coverage for SQLite cwd precedence when thread_id is available
  • includes TUI regression coverage for picker inline error rendering / non-fatal unreadable session rows

Codex author

codex resume 019c9205-7f8b-7173-a2a2-f082d4df3de3

@charley-oai
Copy link
Collaborator Author

@codex review this

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

Here are some automated review suggestions for this pull request.

Reviewed commit: b012c108e0

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@charley-oai
Copy link
Collaborator Author

@codex review this

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

Here are some automated review suggestions for this pull request.

Reviewed commit: a24b8dba8c

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@charley-oai
Copy link
Collaborator Author

@codex review this

@charley-oai charley-oai marked this pull request as ready for review February 25, 2026 02:53
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

Here are some automated review suggestions for this pull request.

Reviewed commit: e6e478aa51

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +794 to +802
Ok(Some(path)) => match resolve_session_thread_id(path.as_path(), None).await {
Some(thread_id) => {
resume_picker::SessionSelection::Resume(resume_picker::SessionTarget {
path,
thread_id,
})
}
None => {
let rollout_path = path.display();
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Keep resume/fork working when SessionMeta is missing

--resume-last now hard-fails when resolve_session_thread_id(...) returns None. That resolver depends on read_session_meta_line, which errors if a rollout does not start with SessionMeta (legacy or malformed files). These sessions can still be resumed/forked by path, and cwd can still be derived from rollout fallback, so this introduces a regression that blocks session recovery.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jif-oai do we want to support rollout files without a session meta?

@charley-oai
Copy link
Collaborator Author

@codex review this

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

Here are some automated review suggestions for this pull request.

Reviewed commit: d70f433d32

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +949 to +952
None => read_session_meta_line(path)
.await
.ok()
.map(|meta_line| meta_line.meta.id),
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Resolve thread id from full rollout scan, not head-only parse

resolve_session_thread_id(..., None) relies on read_session_meta_line, which requires SessionMeta at the very first rollout line. Resume/fork loading accepts the first SessionMeta anywhere in the file, so path-based flows (--resume-last, --fork-last, name-based resume/fork) can now reject sessions that are still resumable when head lines are malformed or reordered.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is not worth worrying about

@charley-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jif-oai
Copy link
Collaborator

jif-oai commented Feb 25, 2026

@codex review

Copy link
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

I'm not sure this is a good idea as it let users resuming sessions outside of ~/.config/sessions
What was the rational behind doing this?

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

Here are some automated review suggestions for this pull request.

Reviewed commit: cf6ac10a76

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@charley-oai charley-oai merged commit c1afb88 into main Feb 26, 2026
31 of 33 checks passed
@charley-oai charley-oai deleted the cc/thread-id-cwd-resume branch February 26, 2026 20:52
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants