Skip to content

fix: cancel queued messages and preserve question answers - #88

Draft
andrebrait wants to merge 3 commits into
kahme247:mainfrom
andrebrait:fix/queue-dialog-upstream
Draft

andrebrait wants to merge 3 commits into
kahme247:mainfrom
andrebrait:fix/queue-dialog-upstream

Conversation

@andrebrait

@andrebrait andrebrait commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Stack: #67#88

Stacked on #67. Merge #67 first; this PR adds queue cancellation and question-answer preservation on top of its native queue-promotion implementation.

Both PRs currently target main, so this PR’s Files changed tab also includes the #67 implementation. After #67 merges, rebase this branch onto main so only this layer remains in the diff.

GitHub’s native stack registration is unavailable for these cross-fork PRs: it currently requires all branches to be in the same repository. This section records the explicit dependency and merge order; it does not indicate native stack membership.

Summary

  • Make queue Delete/Edit acknowledge native cancellation before removing the chip or recalling text. Preserve the original draft across navigation/unmount and publish one queue snapshot to remounted same-session hooks without double-removing duplicates.
  • Preserve question-dialog text and selections when SSE reconnects replay the same request ID; reset only for a genuinely new question.
  • Update localized confirmation text and refusal handling; failed cancellation leaves the queued item visible.

Contributor's reported symptoms:

Deleting messages I steered doesn't seem to be actually deleting them. They get eventually delivered as follow-ups instead.

The contributor also reported intermittent clearing of the question dialog's free-text answer. The cause was a reset effect keyed to request-object identity rather than question ID.

Explicit prerequisites and overlap

Draft: native RPC prerequisites are not yet in an official OMP release. Cancellation is provided by can1357/oh-my-pi#11872. Promotion is provided by can1357/oh-my-pi#11618.

This PR builds on the existing implementation proposed in #67: real native promotion, ref-serialized queue updates, delivery-before-acknowledgement bookkeeping and the StrictMode alive-state correction. It is the next layer, not a replacement for #67. Native Delete cannot safely follow a cosmetic-only Steer label because that would address the wrong backend queue. Review and merge #67 first, then the additional changes here; this does not introduce unrelated layout, provider, selection or integration patches.

Unsupported runtimes report an error and keep the queue item. There is no abort/resend fallback.

Verification

  • Upstream source port: typecheck, lint and full suite passed: 711 passed, 1 existing skip.
  • Regression coverage includes acknowledged/failed cancellation, duplicate queue isolation, same-session remount synchronization, original-draft recovery across navigation/unmount, promotion races and real question replay/new-ID behavior.
  • Original dialog replay regressions erased text/selection against baseline and passed after the fix. Original remount regressions retained ghost chips against baseline and passed after acknowledgement publication.
  • Agent-operated packaged-app/native runtime test reset actual staging TCP connections, observed SSE reconnect, and submitted the exact preserved multiline answer to native OMP. The contributor also exercised the deployed question field.
  • Compiled integrated stack test: follow-up -> native Steer -> Delete removed the target before it reached the provider; a remaining follow-up was delivered normally. The standalone native upstream port has its own real-RPC smoke.
  • The combined downstream integration is deployed locally with old active chats preserved during runtime retirement. The deployed integration includes other patches; this upstream diff does not.
  • Single condensed adversarial review of the upstream port found no blocking code defects.

Copilot/CodeRabbit review requests are routed only to companion PRs in our forks, not to this upstream PR.

Companion automated-review PR (Copilot/CodeRabbit run only in our fork): andrebrait#21

Promotion acknowledgement correction

Successful native promotions now update the session-scoped persisted mirror even after unmount/navigation. Shared pending ownership also protects a remounted delivery-before-ACK case from promoting the next duplicate. The remount, observer, subsequent Delete, duplicate, and unobserved-session regressions failed before this correction and pass afterward. Both feature variants pass 41 focused hook/composer/dialog tests; the refreshed clean deployment passed 682 tests with one existing skip. All README feature descriptions now match native cancellation semantics.

Final review corrections

  • Same-key remounted composers receive recalled text without losing pending typing or duplicating it.
  • Queue cancellation/promotion ACK waits are bounded to 5 seconds, with no automatic retry or process termination.
  • A vanished local queue item reports an actionable warning.
  • A separate failed-submit path was also found: the old finally timer dismissed a question after a rejected response. It now dismisses only after success, preserving the pending question and answer for retry. The original periodic while-typing issue was same-ID SSE replay, not this timer.

Verification: 58 focused hook/composer/dialog/draft/real-RpcProcess tests pass, plus TypeScript and ESLint, in both the upstream port and integration feature. The test-renderer migration nit remains with existing upstream #85 rather than adding a second test framework in this fix.

@noor-latif

Copy link
Copy Markdown
Contributor

I noticed this issue too! Impressive PR. I'm telling you, you could join the OMP dev team. Would have made this PR smaller :)

@andrebrait

Copy link
Copy Markdown
Contributor Author

@noor-latif I do have a few PRs open to bring the required changes to OMP too :)

@andrebrait

Copy link
Copy Markdown
Contributor Author

@noor-latif and part of the reason this PR looks so big is because it is technically stacked on top of #67. Let me make that explicit :)

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.

2 participants