← Back to Pull requests

Chat: edit a queued prompt before its turn starts (#557) #564

Closed
unknown closed this pull request without merging on Nov 27, 2026 22:08 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 16:51 UTC
Author

What and why

A typo in a queued prompt couldn't be fixed. The only way to change one was to wait for it to run, then rewind. Now a queued prompt has Edit: long-press it on a phone, or use the pencil or right-click on desktop. Edit puts the prompt in the composer under an "Editing a queued message" banner, and Send changes it in the queue. Cancel leaves it as it was.

The gateway holds the queue, and Kyllene sends a queued prompt at once, so the edit is a gateway call: prompt.replace_queued. Like Hermes, it moves the edited prompt to the back of the queue. The banner says so.

If the prompt's turn starts while you are editing, the prompt runs as it was. Your edit stays in the composer with a notice, so you can send it as a new message. This applies whether the turn starts before you tap Send (Kyllene sees message.start for that admission) or while the call is in flight (the gateway answers admission_started).

closes #557

Gateway

  • Method: prompt.replace_queued in hermes-agent gateway/session_queued_controls.py. It is on the session authority only, from v0.22.3. Kyllene sends exactly session_id, admission_id, submission_id and text, and no optional keys.

  • - The gateway cancels the old admission and admits the edit as a new one at the back of the FIFO.
    - An exact retry with the same submission_id is idempotent.
  • Capability check: Edit appears only when the prompt's row in pending (from session.info and the session.resume snapshot) lists "replace" in controls. Owners older than the verb list no controls, so they get no Edit and no call.

  • Refusals:

  • - -32601 or unsupported_control: Edit is hidden for that prompt and the user sees an "Update Hermes" error.
    - admission_started or not_found: the "turn already started" path.
    - Anything else: an error, and the prompt keeps its text. On a network failure editing resumes, so Send can retry.
  • Legacy (hermes dashboard / tui_gateway): no version has the method, so Edit never appears and nothing new is sent. Legacy rejects unknown keys with 4000; this PR adds no params to existing calls.

  • Fix found while testing: the cancelled old admission settles with its own message.complete (outcome: "cancelled", no execution_generation), from _settle_cancelled in gateway/session_authority.py. Kyllene had treated it as the running turn ending, which split the streaming reply in two. Such a settlement is now ignored, both in the reducer and in ChatSession's generation tracking.
  • | Hermes | Mode | Edit on a queued prompt |
    |---|---|---|
    | v0.22.0–v0.22.2 | legacy / authority | hidden (no verb, no controls) |
    | v0.22.3–v0.22.5 | legacy (Kyllene can't reach a remote authority before v0.22.6) | hidden |
    | v0.22.6–v0.23.4 | authority | offered |
    | any | legacy | hidden |

    How I tested it

  • Tests added:

  • - QueuedEditTest (core, 16 tests): parsing controls; moving the prompt behind the last queued one; an admission that already started; message.start overtaking the edit; a cancelled settlement that ends no turn while the running turn's own completion still does.
    - QueuedEditTest gateway tests with a fake gateway: the exact request keys; admission_started; unsupported_control; -32601; an authority without controls, which sends nothing; legacy, which sends nothing.
    - ChatViewModelTest (4 new): edit and send; cancel; a turn that starts mid-edit; a prompt the gateway doesn't offer.
  • Raw JSON-RPC against local test gateways (fake model):

  • - v0.22.7 and v0.23.4 authority: replace OK, with a new admission at the tail and controls: ["steer","replace"].
    - An exact retry gave the same admission.
    - The old admission again gave 4001 admission_started.
    - After its turn started, it gave admission_started.
    - The queue ran first, then the edited prompt.
    - v0.22.0–v0.22.2 and legacy: checked in the source; no such method.
  • On a device (emulator, Dev build, minified, v0.23.4 authority):

  • - Long-press on a queued prompt shows Copy, Comment and Edit.
    - The edit banner shows and Send stays enabled mid-turn.
    - After Send, the prompt moved behind the other queued one and ran last. The running reply kept streaming, and the saved transcript has the edited text.
    - The overtaken case shows the notice, and the edit stays in the composer.
  • Not checked by hand:

  • - Legacy on the emulator: the test dashboard wouldn't take the test sign-in. The legacy path is covered by the unit tests above.
    - The desktop UI: it builds, but I didn't run it.
    - 360 dp and dark theme.
  • Commands: the CONTRIBUTING command's builds, lintDebug and :desktopApp:compileKotlinJvm passed. All tests pass except LinuxClientCertificatesTest, which can't run on Windows (POSIX permissions) and isn't touched here.
  • Screenshots

    All from the local test gateway and fake model.

    | Edit on a queued prompt | Editing | Sent: moved to the back |
    |---|---|---|
    | !Long-press menu on a queued prompt: Copy, Comment, Edit | !Banner "Editing a queued message", the edited text in the composer, Send enabled mid-turn | !The edited prompt now waits behind the other queued prompt |

    | Run order | Turn started mid-edit |
    |---|---|
    | !The queued prompt ran first, then the edited one | !Notice: its turn started before your edit went; the edit is in the composer |

    Checklist

  • One feature or fix, and its ROADMAP item is ticked

  • Up to date with master, and the command under "Tests" in CONTRIBUTING.md passes (except the Windows-only failure above)

  • A late answer after a profile, gateway or chat switch is dropped; reconnect, rotation and a second tap work. The edit drops when the prompt goes, and a late answer applies only while the prompt still holds the admission it replaced.

  • Anything cached or stored is keyed by gateway and profile (nothing new is stored)

  • Tested with unusual text: only plain text was tried

  • No tokens in URLs, and no fetches of an address on the user's own network that a reply or page links to

  • Reuses the app's components, fits at 360 dp in both themes, and icon buttons have content descriptions: it reuses the existing edit banner and composer, but 360 dp and dark theme weren't checked on a device

  • The desktop app builds (./gradlew :desktopApp:compileKotlinJvm)

  • "Allow edits by maintainers" is on
  • Created with Claude Opus 5.5 in Claude Code.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Giton22 Review duration: 316m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #564"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%