Skip to content

🤖 fix: persist compaction follow-up delivery#1958

Merged
ammario merged 7 commits intomainfrom
messaging-6jhs
Jan 29, 2026
Merged

🤖 fix: persist compaction follow-up delivery#1958
ammario merged 7 commits intomainfrom
messaging-6jhs

Conversation

@ammar-agent
Copy link
Collaborator

Summary

  • dispatch compaction follow-ups from persisted metadata after compaction completes
  • preserve follow-up attachments/reviews across retry/cancel flows and restore-to-input events
  • add coverage for follow-up helpers and UI formatting

Background

Queue-based follow-up delivery could drop "continue" messages on aborts/errors or resume flows. This change makes follow-up delivery deterministic from persisted compaction metadata instead of ephemeral queues.

Implementation

  • added a follow-up builder with stable dedupe keys and metadata tagging
  • moved dispatch into compaction completion and preserved follow-up data in UI restore paths
  • extended custom event payloads and tests for follow-up formatting/metadata

Validation

  • make static-check

Risks

  • compaction follow-up dispatch now bypasses queued message semantics; regressions would affect compaction retry/recovery behavior

Generated with mux • Model: openai:gpt-5.2-codex • Thinking: xhigh • Cost: $42.05

@github-actions github-actions bot added enhancement New feature or functionality refactor labels Jan 27, 2026
Copy link

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the messaging-6jhs branch 2 times, most recently from d5cfeb7 to 42df067 Compare January 28, 2026 16:51
@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed legacy continueMessage fallback and preserved baseOptions for compaction follow-ups. Added coverage for base options + legacy metadata.

Copy link

@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: 5eaaf61fb8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the messaging-6jhs branch 2 times, most recently from 3e041cd to e11982b Compare January 28, 2026 18:33
@ammar-agent
Copy link
Collaborator Author

@codex review

@ammar-agent
Copy link
Collaborator Author

re-running CI

@ammar-agent ammar-agent reopened this Jan 28, 2026
Copy link

@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: 0752cd1eb2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

ammar-agent added a commit that referenced this pull request Jan 28, 2026
- Await dispatchPendingFollowUp() before sendQueuedMessages() to prevent
  race where queued messages could append before follow-up reads history
- Extend CompactionFollowUpRequest to include preserved send options
  (thinkingLevel, additionalSystemInstructions, providerOptions, etc.)
- Pass preserved options through prepareCompactionMessage() and
  dispatchPendingFollowUp() so follow-up uses original user settings
- Add model fallback (DEFAULT_MODEL) for legacy follow-ups lacking model

Addresses sub-agent review feedback on PR #1958.
ammar-agent added a commit that referenced this pull request Jan 28, 2026
- Await dispatchPendingFollowUp() before sendQueuedMessages() to prevent
  race where queued messages could append before follow-up reads history
- Extend CompactionFollowUpRequest to include preserved send options
  (thinkingLevel, additionalSystemInstructions, providerOptions, etc.)
- Pass preserved options through prepareCompactionMessage() and
  dispatchPendingFollowUp() so follow-up uses original user settings
- Add model fallback (DEFAULT_MODEL) for legacy follow-ups lacking model

Addresses sub-agent review feedback on PR #1958.
@ammario
Copy link
Member

ammario commented Jan 29, 2026

@codex review

Copy link

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

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

ammar-agent added a commit that referenced this pull request Jan 29, 2026
- Await dispatchPendingFollowUp() before sendQueuedMessages() to prevent
  race where queued messages could append before follow-up reads history
- Extend CompactionFollowUpRequest to include preserved send options
  (thinkingLevel, additionalSystemInstructions, providerOptions, etc.)
- Pass preserved options through prepareCompactionMessage() and
  dispatchPendingFollowUp() so follow-up uses original user settings
- Add model fallback (DEFAULT_MODEL) for legacy follow-ups lacking model

Addresses sub-agent review feedback on PR #1958.
- Add CompactionSummaryMetadata type with pendingFollowUp field
- Attach follow-up to summary message in performCompaction()
- Add dispatchPendingFollowUp() method for single-owner dispatch
- Call from subscribeChat() (crash recovery) and stream-end (normal flow)
- Remove in-memory queue logic for follow-ups (70+ lines removed)

Follow-up content now survives app crashes because it's persisted on the
summary message. The existence of a subsequent user message serves as
proof of dispatch (no history rewrite needed).
Add legacy format handling for older persisted compaction requests:
- Convert mode ("exec"|"plan") to agentId when agentId is missing
- Support imageParts as alias for fileParts

Update test to reflect new crash-safe architecture where follow-up
is dispatched from summary message instead of in-memory queue.
- Await dispatchPendingFollowUp() before sendQueuedMessages() to prevent
  race where queued messages could append before follow-up reads history
- Extend CompactionFollowUpRequest to include preserved send options
  (thinkingLevel, additionalSystemInstructions, providerOptions, etc.)
- Pass preserved options through prepareCompactionMessage() and
  dispatchPendingFollowUp() so follow-up uses original user settings
- Add model fallback (DEFAULT_MODEL) for legacy follow-ups lacking model

Addresses sub-agent review feedback on PR #1958.
Add pickPreservedSendOptions() to centralize the field list for preserved
send options, avoiding duplication across type definition, assignment,
and usage sites.
…ring

Change void to await so the follow-up message is persisted before
sendQueuedMessages() runs, preventing race conditions where queued
messages could be appended before the follow-up.
@ammario ammario merged commit f75a0cf into main Jan 29, 2026
38 of 40 checks passed
@ammario ammario deleted the messaging-6jhs branch January 29, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or functionality refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants