Skip to content

tui: preserve remote image attachments across resume/backtrack#10590

Merged
charley-oai merged 32 commits intomainfrom
support-app-images-in-tui
Feb 13, 2026
Merged

tui: preserve remote image attachments across resume/backtrack#10590
charley-oai merged 32 commits intomainfrom
support-app-images-in-tui

Conversation

@charley-oai
Copy link
Collaborator

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

Summary

This PR makes app-server-provided image URLs first-class attachments in TUI, so they survive resume/backtrack/history recall and are resubmitted correctly.

Screenshot 2026-02-12 at 8 27 08 PM

Can delete the attached image upon backtracking:
Screenshot 2026-02-12 at 8 27 31 PM

In both history and composer, remote images are rendered as normal [Image #N] placeholders, with numbering unified with local images.

What changed

  • Plumb remote image URLs through TUI message state:
    • UserHistoryCell
    • BacktrackSelection
    • ChatComposerHistory::HistoryEntry
    • ChatWidget::UserMessage
  • Show remote images as placeholder rows inside the composer box (above textarea), and in history cells.
  • Support keyboard selection/deletion for remote image rows in composer (Up/Down, Delete/Backspace).
  • Preserve remote-image-only turns in local composer history (Up/Down recall), including restore after backtrack.
  • Ensure submit/queue/backtrack resubmit include remote images in model input (UserInput::Image), and keep request shape stable for remote-image-only turns.
  • Keep image numbering contiguous across remote + local images:
    • remote images occupy [Image #1]..[Image #M]
    • local images start at [Image #M+1]
    • deletion renumbers consistently.
  • In protocol conversion, increment shared image index for remote images too, so mixed remote/local image tags stay in a single sequence.
  • Simplify restore logic to trust in-memory attachment order (no placeholder-number parsing path).
  • Backtrack/replay rollback handling now queues trims through AppEvent::ApplyThreadRollback and syncs transcript overlay/deferred lines after trims, so overlay/transcript state stays consistent.
  • Trim trailing blank rendered lines from user history rendering to avoid oversized blank padding.

Docs + tests

  • Updated: docs/tui-chat-composer.md (remote image flow, selection/deletion, numbering offsets)
  • Added/updated tests across tui/src/chatwidget/tests.rs, tui/src/app.rs, tui/src/app_backtrack.rs, tui/src/history_cell.rs, and tui/src/bottom_pane/chat_composer.rs
  • Added snapshot coverage for remote image composer states, including deleting the first of two remote images.

Validation

  • just fmt
  • cargo test -p codex-tui

Codex author

codex fork 019c2636-1571-74a1-8471-15a3b1c3f49d

@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: f885dff4d6

ℹ️ 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 force-pushed the support-app-images-in-tui branch from ebcfde4 to 6f8ee0e Compare February 5, 2026 00:14
@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: 6f8ee0e891

ℹ️ 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: 6266fc0b8b

ℹ️ 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: 4e8cf40dce

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

@charley-oai charley-oai force-pushed the support-app-images-in-tui branch from 57a5637 to 0442033 Compare February 6, 2026 22:25
@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: 04420335e2

ℹ️ 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 force-pushed the support-app-images-in-tui branch from 84a0a05 to 381d687 Compare February 8, 2026 23:37
@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

if record_history && (!text.is_empty() || !self.attached_images.is_empty()) {
let local_image_paths = self
.attached_images
.iter()
.map(|img| img.path.clone())

P2 Badge Preserve remote images in composer history recall

The new remote-image support allows submissions with pending_non_editable_image_urls, but history entries recorded here only capture text/local images and are gated on !text.is_empty() || !self.attached_images.is_empty(). That means (a) remote‑only submissions never enter ChatComposerHistory, and (b) submissions that include remote images will be recalled via Up/Down without those remote images. Users who backtrack/resume a remote‑image message and later use history navigation will silently drop the remote attachments. Consider storing remote image URLs in HistoryEntry (and recording/rehydrating them) so history recall preserves the full submission, including remote‑only cases.

ℹ️ 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: 106bb9e60c

ℹ️ 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 force-pushed the support-app-images-in-tui branch from a2099c3 to fbcca43 Compare February 10, 2026 18:49
@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: fbcca43a56

ℹ️ 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 force-pushed the support-app-images-in-tui branch from 1673f23 to 2c9819b Compare February 10, 2026 23:20
@charley-oai charley-oai changed the base branch from main to fix/tui-replay-thread-rollback-trim February 10, 2026 23:21
@charley-oai charley-oai force-pushed the support-app-images-in-tui branch from 2c9819b to ca60dcb Compare February 10, 2026 23:53
@charley-oai charley-oai force-pushed the fix/tui-replay-thread-rollback-trim branch from e5e0e60 to f9cf89d Compare February 11, 2026 02:37
Base automatically changed from fix/tui-replay-thread-rollback-trim to main February 11, 2026 02:53
@charley-oai charley-oai force-pushed the support-app-images-in-tui branch from 97cd3ef to a9600fa Compare February 11, 2026 02:59
@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: a9600fa92d

ℹ️ 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 force-pushed the support-app-images-in-tui branch from c2e8a35 to 0ef19af Compare February 13, 2026 15:42
@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: b22817ea5c

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

let mut next_image_label = total_remote_images + 1;

for (idx, message) in to_merge.into_iter().enumerate() {
if idx > 0 {
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 Skip separator newlines for remote-only queued messages

drain_queued_messages_for_restore unconditionally inserts \n for every merged entry after the first. Remote-image-only turns now have empty text, so if one is queued before a text turn, restore prepends a blank line and shifts TextElement byte ranges, changing the resubmitted prompt after an interrupt. Handle empty-text messages without adding separators.

Useful? React with 👍 / 👎.

@charley-oai charley-oai merged commit 26a7cd2 into main Feb 13, 2026
27 of 33 checks passed
@charley-oai charley-oai deleted the support-app-images-in-tui branch February 13, 2026 22:54
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 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