Skip to content

fix(desktop,cli): stop rejecting legal edit-and-resend / rewind on structured history - #5118

Open
ggbdpq wants to merge 5 commits into
apache:mainfrom
ggbdpq:fix/edit-resend-structured-context
Open

fix(desktop,cli): stop rejecting legal edit-and-resend / rewind on structured history#5118
ggbdpq wants to merge 5 commits into
apache:mainfrom
ggbdpq:fix/edit-resend-structured-context

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of #5109 — the two behaviors that can be fixed without growing the debt-ratcheted renderer shell files:

Desktop: an edit was refused whenever any earlier retained turn carried an attachment, even though the Runtime Host revision copier already preserves referenced user-upload artifacts and rewrites their Session refs losslessly (integration coverage in session-revision-two-client-uds.test). That stale history scan is gone: a plain-text message edited over attachment-bearing history is now editable. A source message that itself carries attachments (and folder references) stays explicitly rejected, because its rewritten target-owned refs are not exposed to clients yet.

TUI: /rewind refilled only userFacingText(promptMessage) and the replacement submit carried only text — silently degrading a selected turn that carried quotes or attachments. Until the TUI can stage structured context, rewind now refuses with a precise notice instead of dropping content silently (the issue's explicit fail-closed allowance).

Deliberately out of this slice: staging a selected message's quotes into the Desktop revision draft (issue behavior A). A working prototype grew app-shell.tsx / app-shell-revision-actions.ts / use-app-shell-composer-quotes.ts, which are monotonic token-debt files under renderer-architecture.json; whether to spend that budget (or re-home the staging logic in a non-ratcheted module) is a maintainer call, so it is noted as follow-up instead of smuggled in. Same for editing a selected message's attachments (needs the Host to expose rewritten target-owned refs) and TUI quote staging.

Verification

Claim Evidence
Stale refusal removed new app-shell-revision-actions.test 2/2: editing a later plain-text message over attachment-bearing history opens the draft; a source message with attachments is still refused explicitly
TUI fail-closed new driver test: rewind on turns carrying quotes/attachments rejects with a precise message before any session.revision.create
Renderer contract check-renderer-architecture --base <merge-base>: no debt increase (revision-actions file shrinks; ledger figure follows down); TUI rewind suites 8/8
Builds / format / headers desktop build:test, ui, maka-agent exit 0; biome clean; ASF headers intact

Known-local-environment notes: the CI check script segfaults in the base-worktree derivation on this Windows machine, so the architecture gate was verified by metric comparison against the ledger (all touched files at or below base) — CI runs it for real.

AI use

Implemented with ZCode (GLM-5.3-Flash): traced the issue's verified implementation boundaries, red-green per slice, narrowed the slice when the renderer token ratchet refused the larger shape, Generated-by trailer in commits.

Checklist

  • Earlier retained attachments are copied by the Host; the renderer's stale refusal is removed
  • Source messages with attachments / folder references still fail explicitly, never silently
  • TUI rewind fails closed with a precise notice instead of degrading content
  • Selected-message quotes/attachments restored into the revision draft — follow-up (needs ratchet budget or re-homing)
  • Unchanged detection comparing canonical structured content — lands with the follow-up

A quote-bearing user message — including the automatic large-paste
quote — was permanently ineligible for Edit & resend, and an edit was
refused whenever any earlier retained turn carried an attachment, even
though the Host revision copier already preserves referenced artifacts
and rewrites their Session refs losslessly (apache#5109).

Quotes are self-contained snapshot content, so the revision draft now
carries them: beginEditUserMessage stages the source message's quotes
into the composer (cleared back to the pre-edit set on cancel) and
records them on the draft; the unchanged-send guard compares the
staged quotes against the source's instead of the text alone, so a
quote-only edit counts as a real edit. The stale retained-attachment
history scan is dropped; a source message that itself carries
attachments is still rejected explicitly because its rewritten
target-owned refs are not exposed to clients yet.

The renderer now stages and submits quotes on the revision send, so
the replacement turn keeps its structured context.

Part of apache#5109
Generated-by: GLM-5.3-Flash (ZCode)
…d content

TUI /rewind refilled only userFacingText(promptMessage) and its
replacement submit carried only text, so rewinding a turn with quotes
or attachments silently degraded it to a display string (apache#5109).
Until the TUI can stage structured context, rewind now fails closed
with a precise notice instead of dropping the content silently.

Part of apache#5109
Generated-by: GLM-5.3-Flash (ZCode)
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 9, 2026
An edit was refused whenever any earlier retained turn carried an
attachment, even though the Runtime Host revision copier already
preserves referenced user-upload artifacts and rewrites their Session
refs losslessly (integration coverage in
session-revision-two-client-uds.test). A plain-text message edited
over such history is now editable; a source message that itself
carries attachments stays explicitly rejected, because its rewritten
target-owned refs are not exposed to clients yet (apache#5109).

The renderer-architecture ledger's token figure for
app-shell-revision-actions.ts follows the deletion down. The larger
half of apache#5109 — staging a selected message's quotes/attachments into
the revision draft — grows these debt-ratcheted files, so it is left
out of this slice and noted as follow-up on the PR.

Part of apache#5109
Generated-by: GLM-5.3-Flash (ZCode)
@ggbdpq ggbdpq changed the title fix(desktop,cli): keep quotes in edit-and-resend revisions fix(desktop,cli): stop rejecting legal edit-and-resend / rewind on structured history Sep 9, 2026
…ed slice

The first commit carried the quote-staging wiring through the
debt-ratcheted shell files; with the staging slice moved to follow-up
those files return to their upstream content, keeping the renderer
token ledger untouched.

Generated-by: GLM-5.3-Flash (ZCode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant