Skip to content

fix: retain undelivered marker on new messages - #88

Open
Pleasurecruise wants to merge 1 commit into
LodyAI:mainfrom
Pleasurecruise:fix/late-msg
Open

fix: retain undelivered marker on new messages#88
Pleasurecruise wants to merge 1 commit into
LodyAI:mainfrom
Pleasurecruise:fix/late-msg

Conversation

@Pleasurecruise

@Pleasurecruise Pleasurecruise commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Related issue

Fix #47

Problem / pressure

PR #74 made lastMissingHistoryUserMsgId a permanent negative acknowledgement for an undelivered turn, but missed the ordinary new-message path:

  1. Message A times out waiting for history and is blocked by the marker.
  2. A's history entry later reaches the CLI with status: pending.
  3. The user sends a different message B instead of resending A.
  4. The renderer points latestUserMsgId at B but also clears A's marker.
  5. The dispatcher scans pending history from oldest to newest and selects A before B.

This can execute a message the UI already presented as not delivered.

Summary

  • Preserve the existing missing-history marker when the renderer publishes a different new turn.
  • Keep the marker-specific resend flow responsible for terminalizing the abandoned entry.
  • Tighten the renderer metadata-write test so clearing the marker fails the assertion.
  • Correct the nearby comments and contributor invariants that described the old behavior.
  • Rebase the change onto the latest main and resolve the contributor-invariant conflict.

Before / after

Before After
Sending B cleared A's marker, making late pending A dispatchable again. Sending B changes only latestUserMsgId; A remains excluded and B dispatches normally.

Test plan

  • packages/components/node_modules/.bin/vitest run tests/use-session-actions.test.ts tests/resend-undelivered-dialog.test.tsx tests/undelivered-user-turn.test.ts — 34 tests passed after rebasing.
  • apps/cli/node_modules/.bin/vitest run src/session/session-dispatch-logic.test.ts tests/session-dispatch-watcher.test.ts — 50 tests passed after rebasing.
  • CLI and Components tsgo --noEmit passed before the rebase.
  • Type-aware lint completed with 0 errors on the changed TypeScript files before the rebase.
  • Prettier check passed before the rebase; git diff --check passed after conflict resolution.

Context handoff

Instructions for reviewing agents

  • Review focus: Verify the metadata patch in use-session-actions.ts preserves an existing marker while moving latestUserMsgId to B.
  • Decisions to challenge: Confirm retaining A's exact-ID tombstone is preferable to implicitly canceling A when the user sends unrelated B.
  • Plausible failures / evidence gaps: The fix is intentionally scoped to renderer sends; CLI commands and internal dispatch producers were not changed.

Authoring context

  • User goal / directives: Fix the PR fix: surface missing-history-acked messages as Not delivered with explicit resend #74 gap where sending B can revive an older not-delivered A, keep the change minimal, and explain the reproduction chain in the PR.
  • Constraints / non-goals: Do not redesign dispatch state, broaden unrelated producer behavior, include dependency-store artifacts, or expose conversation transcripts.
  • Risk-bearing decisions: Retain the exact-ID marker across unrelated renderer sends so A remains excluded while B still activates dispatch.
  • Destructive or irreversible behavior: The product change does not migrate or delete persisted data; the PR branch was rebased onto current main to resolve conflicts.
  • Deliberately not done or tested: Full repository CI was not rerun locally after the rebase; the affected Components and CLI suites were rerun instead.
  • Unknowns / confidence: Confidence is high for the reported renderer path; equivalent behavior in non-renderer producers remains outside this PR's scope.

@github-actions github-actions Bot added scope: cli scope: components status:needs-pr-body PR body does not meet the contribution template labels Aug 27, 2026
@github-actions github-actions Bot removed the status:needs-pr-body PR body does not meet the contribution template label Aug 28, 2026
@Leeeon233
Leeeon233 requested a review from zxch3n September 2, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message_delivery_failed after daemon restart under ENOSPC: pending turn pointer survives but history payload never re-syncs to the joined doc room

1 participant