Skip to content

feat(mecatui): merge queued follow-ups, edit-back, and auto-resume on transient errors (#228) - #229

Merged
JAORMX merged 3 commits into
mainfrom
feat/mecatui-queue-merge-editback-autoresume
Jul 3, 2026
Merged

JAORMX merged 3 commits into
mainfrom
feat/mecatui-queue-merge-editback-autoresume

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #228.

The follow-up-prompt queue in the mecatui Bubble Tea client had three UX gaps that surfaced together when a run died on a transient upstream idle timeout (the queue paused, offering only send-verbatim or drop-everything). This addresses all three, per the decisions locked in the issue.

What changed

1. Merge always

Multiple queued follow-ups now combine into one prompt (staged lines joined by a blank line, queueMergeSep = "\n\n") and drain in a single step — matching Claude Code — instead of N sequential FIFO turns. popAndSubmit merges the whole slice; the re-entrant ResultMsg → drainQueue now no-ops on the emptied queue. The pendingMode pause is preserved verbatim (merged text lands in the textarea, queuePaused="mode", no submit).

2. Edit-back

↑ on an empty input line with a non-empty queue pulls the merged queued text back into the textarea (non-destructive) so it can be revised and re-sent/re-queued. esc stays clear-all. EditBack is a rebindable keyMap action (struct field + defaultKeys() + applyKeyOverrides setter + keymap validator allow-list + --keymap help), wired into both the running and idle key paths.

3. Auto-resume transient errors

Transient/retryable failures (idle/stalled stream, Unavailable/DeadlineExceeded/ResourceExhausted, 429, transient 5xx, the shared message vocabulary) auto-fire the merged queue, since a plain retry is likely to succeed. Hard errors, a user cancel, max_consecutive_failures, and a clean stream close still pause. Auto-resume fires exactly once (the merged queue empties before submit, so the reopened run's own terminal finds an empty queue → no loop).

Classification lives entirely in the client package (Transient bool on ResultMsg/StreamErrMsg, set by TransientStreamErr/TransientResultError over a shared vocabulary); the ui reads only the boolean, preserving the proto-free ui boundary. Bare server_error is deliberately excluded (OpenRouter reuses it for non-transient faults).

Docs

docs/tui.md keys table + "queued follow-ups" section updated in lockstep. llms.txt regenerated (unchanged — the prose edits don't alter the generated index).

Testing

  • Merge (drain + resume + pending-mode pause), edit-back (all four gates + esc-still-clears + focus/status), transient classifier tables (gRPC codes + vocabulary + server_error carve-out at both the classifier and the EventToMsg mapper boundary), auto-resume (result + stream error), hard-error/cancel/StreamClosed pause, and the no-loop two-transient-in-a-row guarantee.
  • keyMap↔override-setter parity pinned by a reflection test.
  • task build, task test (full, -race, engine-standalone), task lint (both modules), task test:golden (no golden shifts), docs:check (0 broken links), and go run ./cmd/mecademo all green.

No engine/internal/proto API changes — the transient flag stays in the mecatui client package.

Review

Ran through the dev-pipeline (architect plan → implement → panel review). Spec/Standards/Architecture axes came back clean; the QA test-adequacy axis surfaced coverage gaps (StreamClosed queue-pause, the no-loop guarantee, the server_error mapper-boundary carve-out, edit-back focus) which are now covered.

🤖 Generated with Claude Code

jhrozek added a commit that referenced this pull request Jul 2, 2026
…onsecutive_failures pause

Three follow-up nits from PR #229 review:

- docs/tui.md: clarify that transient auto-resume fires only when
  follow-ups are staged — a transient death with an empty queue does
  not auto-retry the original prompt.
- ui/view.go: show the "· ↑ edit" queue hint only when the input is
  empty (EditBack is gated on empty input); a draft present made the
  hint misleading.
- ui/queue_merge_editback_test.go: add
  TestMaxConsecutiveFailuresStillPausesEvenIfTransientFlag —
  max_consecutive_failures pauses regardless of a spurious transient
  flag (the auto-resume gate requires stop==stopError).
@jhrozek

jhrozek commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the review nits — landed in 7923c79:

1. docs/tui.md — auto-resume scope clarification
The transient-failure paragraph read as if a transient death auto-retries the run. Clarified that auto-resume fires only when follow-ups are staged — a transient death of a run with an empty queue does not auto-retry the original prompt; the user must resend manually. This was always the behaviour (the gate is len(m.queued) > 0); only the docs were ambiguous.

2. cmd/mecatui/ui/view.go — gate the · ↑ edit hint
The non-paused queue card unconditionally showed ⏳ N queued · ↑ edit, but EditBack only works on an empty input line. With a draft present the hint misled. Now the · ↑ edit suffix shows only when strings.TrimSpace(m.ta.Value()) == ""; otherwise it renders the plain ⏳ N queued. The paused branch is unchanged.

3. cmd/mecatui/ui/queue_merge_editback_test.go — pin max_consecutive_failures pause
Added TestMaxConsecutiveFailuresStillPausesEvenIfTransientFlag. The auto-resume gate requires stop == stopError, so a max_consecutive_failures stop pauses regardless of any spurious transient flag (mirrors the existing cancelled analog). This was the one stop reason whose error text could plausibly carry transient vocab, so worth locking down explicitly.

The other two review notes were left as-is by design:

  • Substring false-positives in transientVocab (the bare 429/502/503/504 tokens) — bounded blast radius (one wasted retry, queue empties), and word-boundary-ing them is a classifier semantics change; left for a separate call if it ever bites.
  • ↑/scroll overload — a UX tradeoff, not a bug; ↑-for-edit-back mirrors Claude Code, which is the stated goal.

task build, go test ./cmd/mecatui/ui/ -race, and the strict link check are green. llms.txt regenerated byte-identical. Not pushing further.

JAORMX and others added 3 commits July 3, 2026 14:30
… transient errors (#228)

The follow-up-prompt queue had three UX gaps that surfaced when a run
died on a transient upstream idle timeout. This addresses all three:

1. Merge always — multiple queued follow-ups now combine into ONE prompt
   (joined by a blank line, queueMergeSep) and drain in a single step,
   matching Claude Code, instead of N sequential FIFO turns.

2. Edit-back — up on an empty input line with a non-empty queue pulls the
   merged queued text back into the textarea (non-destructive) so it can be
   revised and re-sent/re-queued. Esc stays clear-all. EditBack is a
   rebindable keyMap action wired into both the running and idle key paths.

3. Auto-resume transient errors — transient/retryable failures (idle/stalled
   stream, unavailable/overloaded backend, 429, transient 5xx) auto-fire the
   merged queue, since a plain retry is likely to succeed; hard errors, a
   user cancel, max_consecutive_failures, and a clean stream close still
   pause. Classification (Transient bool + TransientStreamErr/
   TransientResultError over a shared vocabulary) lives in the client
   package; the ui reads only the boolean, preserving the proto-free ui
   boundary. Auto-resume fires exactly once (the merged queue empties before
   submit, so the reopened run's own terminal finds an empty queue).

Docs (docs/tui.md keys table + queue-behaviour section) updated in lockstep.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UeMPVTcNMwm134V3L4AAsL
…onsecutive_failures pause

Three follow-up nits from PR #229 review:

- docs/tui.md: clarify that transient auto-resume fires only when
  follow-ups are staged — a transient death with an empty queue does
  not auto-retry the original prompt.
- ui/view.go: show the "· ↑ edit" queue hint only when the input is
  empty (EditBack is gated on empty input); a draft present made the
  hint misleading.
- ui/queue_merge_editback_test.go: add
  TestMaxConsecutiveFailuresStillPausesEvenIfTransientFlag —
  max_consecutive_failures pauses regardless of a spurious transient
  flag (the auto-resume gate requires stop==stopError).
…del-id false-positives

The numeric entries in transientVocab (429/502/503/504) matched as bare
substrings, so an error string carrying those digits in a port number or
model id ("port 50378", "model 1230503", "listening on 42900") was
misclassified as a transient HTTP status and would auto-resume the queue
against a non-retryable failure.

Split the numeric codes into transientCodes and match them with digit-
boundary checks (containsBoundedCode): "503" still matches "HTTP 503"
and "got a 503." but not a code embedded in a longer digit run. The
alphabetic word entries stay substring-matched (they land word-bounded in
real error text). The change is strictly a true→false tightening — no
existing true-positive regresses (all prior test cases have the codes as
standalone tokens), pinned by new boundary cases in both classifier table
tests.

This was the one deferred review nit worth taking (bounded blast radius,
per the PR comment); the ↑/scroll-overload tradeoff stays by design.
@JAORMX
JAORMX force-pushed the feat/mecatui-queue-merge-editback-autoresume branch from 7923c79 to 8e65c54 Compare July 3, 2026 11:38
@JAORMX

JAORMX commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on latest main (was 2 commits behind — #226 MCP typed tool results + #211 scheduler) and force-pushed. Rebase was clean, no conflicts.

Addressed the one deferred review nit

Substring false-positives in transientVocab (8e65c54) — the numeric HTTP status codes (429/502/503/504) matched as bare substrings, so an error string carrying those digits in a port number or model id ("port 50378", "model 1230503", "listening on 42900") was misclassified as a transient HTTP status → spurious auto-resume against a non-retryable failure.

Split the numeric codes into a transientCodes slice and match them with digit-boundary checks (containsBoundedCode): 503 still matches "HTTP 503" and "got a 503." but not a code embedded in a longer digit run. The alphabetic word entries stay substring-matched (they land word-bounded in real error text). The change is strictly a true→false tightening — no existing true-positive regresses (all prior test cases have the codes as standalone tokens), pinned by new boundary cases in both classifier table tests (TestTransientStreamErr + TestTransientResultError).

The other deferred nit — ↑/scroll overload — stays by design: ↑-for-edit-back mirrors Claude Code (the stated goal), and it only fires on an empty input line with a non-empty queue, so it never collides with cursor navigation over a draft.

Verification on the rebased branch

task build, task lint (both modules), task test (full, -race, engine-standalone), task test:golden (no golden shifts), task docs:check (0 broken links), and go run ./cmd/mecademo all green.

@JAORMX
JAORMX merged commit 02951ed into main Jul 3, 2026
13 checks passed
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.

mecatui: queued follow-ups — merge into one prompt, allow edit-back, and auto-resume on transient errors

2 participants