You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d69236d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(core): add V2-native unqueue/edit of pending session inputs
New SessionV2.pending/withdraw/revise methods let a caller remove or
edit a message that's been durably admitted but not yet promoted into
a visible turn -- plus three new HTTP routes and a TUI /queue dialog.
Ported from upstream anomalyco#4821 (126 reactions): PR anomalyco#6415
"Easy Message Unqueue with /unqueue" (closed by a 60-day-stale bot,
never reviewed) and PR anomalyco#6271 "add edit and discard actions for queued
messages" (more thorough, self-closed after apparent lack of
maintainer response). Both PRs remove a queued message from an
in-memory callback list and delete the V1 message -- a backend model
with no equivalent in this repo's V2 session core, where a queued
message is a durable row that stays pending until a safe promotion
point. So the backend here is a fresh, V2-native design, not a port:
a durable event (session.next.prompt.withdrawn / .revised) is
published and projected the same way SessionInput.Prompted already
works, guarded to only affect rows that are neither promoted nor
withdrawn, with a withdraw winning any race against an in-flight
promotion. What was reused: the remove/edit concepts themselves,
/unqueue kept as a command alias (anomalyco#6415), and the general shape of a
queued-message picker UI (anomalyco#6271) -- reworked as a /queue list dialog
rather than anomalyco#6271's inline "EDITING" mode in the main prompt box.
New requireInput flag threads through the turn loop in
packages/core/src/session/runner/llm.ts so a turn whose only
justification was a withdrawn input is skipped rather than run with
nothing to answer -- merged by hand against this fork's own
model-fallback feature, which had already added a different
parameter (tried) to the exact same functions.
KNOWN, SIGNIFICANT GAP: the TUI still sends every prompt through the
legacy V1 SessionPrompt path, which never creates the V2 session_input
rows this feature acts on. /queue will show an empty list for
anything typed in the actual running TUI today. Switching the TUI to
send V2 prompts is a materially bigger decision than this feature's
own scope and was deliberately left for a separate follow-up rather
than silently expanded into. The backend is fully real, tested, and
reachable via the HTTP API directly today.
New tests: packages/core/test/session-prompt.test.ts (+10 cases),
session-runner.test.ts (+4), packages/tui/test/cli/tui/data.test.tsx
(+2), three new httpapi-exercise scenarios, event-manifest count
updated (88 -> 90 for the two new durable events). Client and legacy
JS SDKs regenerated. Verified against this fork's current dev,
including the manual merge against model-fallback: bun typecheck
clean across all 30 packages; packages/core 1178 pass (only the
pre-existing pty flake); packages/opencode 3613 pass, only the 4
pre-existing cf-ai-gateway failures; packages/tui 230 pass;
httpapi-exercise coverage mode 214 pass.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Copy file name to clipboardExpand all lines: FORK_CHANGES.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,17 @@ Each entry names the upstream gap it addresses, whether it originated as our own
6
6
7
7
## Implemented
8
8
9
+
### Unqueue / edit queued messages (V2 backend)
10
+
11
+
A durable, V2-native way to remove or edit a message that's been admitted but not yet promoted into a visible turn — new `SessionV2.pending`/`withdraw`/`revise` methods, three new HTTP routes, and a TUI `/queue` dialog. **Not yet reachable from the real TUI** — see known gaps.
12
+
13
+
-**Upstream gap:**[anomalyco/opencode#4821](https://github.com/anomalyco/opencode/issues/4821) — 126 reactions. [PR #6415](https://github.com/anomalyco/opencode/pull/6415) "Easy Message Unqueue with /unqueue" (9 files) was closed by a 60-day-stale bot, never reviewed. [PR #6271](https://github.com/anomalyco/opencode/pull/6271) "add edit and discard actions for queued messages" (11 files, more thorough — both edit and discard) was self-closed by the author after apparent lack of maintainer response, not a merit rejection.
14
+
- **Origin:** implemented by an Opus 5 agent, with an unusually important caveat flagged up front in its own research: both upstream PRs remove a queued message from an *in-memory callback list* and delete the V1 message — a backend model with no equivalent in this repo's V2 session core, where a queued message is a *durable row* that stays pending until a safe promotion point (see this repo's own `AGENTS.md`: "An explicit `queue` input remains pending until the Session would otherwise become idle; promote one queued input at that boundary..."). So the backend here is a fresh, V2-native design — not a port — built the same way `SessionInput.Prompted`/`projectPrompted` already work: a durable event (`session.next.prompt.withdrawn` / `.revised`) is published and then projected into a `withdrawn_seq` column (new, migration `20260923161657_session_input_withdrawn`) or a replaced `prompt` value, with the update guarded to only affect rows that are neither promoted nor withdrawn (racing a withdraw against an in-flight promotion resolves in the withdraw's favor — the runner skips answering a turn that no longer has anything pending for it). What *was* reused from the PRs: the "remove" and "edit" concepts themselves, `/unqueue` kept as a command alias (from #6415), and the general shape of a queued-message picker UI (from #6271) — reworked as a `/queue` list dialog (select a message to edit its text, or press ctrl+d twice to remove it) rather than #6271's inline "EDITING" mode in the main prompt box.
15
+
-**Where:**`packages/core/src/session/input.ts` (`listPending`/`withdraw`/`revise`/the new `NotPending` error), `packages/core/src/session.ts` (`SessionV2.pending`/`withdraw`/`revise`), `packages/core/src/session/runner/llm.ts` (a `requireInput` flag threading through the turn loop so a turn whose only justification was a withdrawn input is skipped rather than run with nothing to answer — merged by hand against this fork's own model-fallback feature, which had already added a different parameter to the exact same functions), three new routes (`GET /api/session/:id/input`, `PATCH .../input/:messageID`, `DELETE .../input/:messageID`) in `packages/protocol/src/groups/session.ts` + `packages/server/src/handlers/session.ts`, and a new `packages/tui/src/component/dialog-queued-input.tsx` + `/queue` command.
16
+
- **Known, significant gap — read before relying on this:** the TUI still sends every prompt through the legacy V1 `SessionPrompt` path, which never creates the V2 `session_input` rows this feature acts on. **`/queue` will show an empty list for anything typed in the actual running TUI today.** Switching the TUI to send V2 prompts (`delivery: "queue"`) would make this feature real end-to-end, but is a materially bigger decision (it changes how every prompt in the TUI is sent) than this feature's own scope, and was deliberately left for a separate follow-up rather than silently expanded into. The backend is fully real, tested, and reachable via the HTTP API directly today. Also: the web app's own queue UI keeps its queue in the browser and doesn't call these routes; there's no "QUEUED"/"EDITING" badge on messages in the transcript; editing changes text only, not attachments or agent mentions; withdrawal also applies to a not-yet-promoted default-"steer" message, not just explicitly-queued ones (the dialog labels those "next turn"); the TUI dialog itself has no render test (only its data layer and API calls are tested).
17
+
- **Verified:** `bun typecheck` clean across all 30 packages. New tests: `packages/core/test/session-prompt.test.ts` (+10 cases — a withdrawn message never reaches the model and the next queued one still runs; withdrawing the only queued message adds no extra model call; withdrawing an already-promoted message is rejected; an edited message runs with the edited text; a promotion that loses the race to a withdraw is refused; double-withdraw/unknown-id/wrong-session/retry-after-withdraw are all rejected), `packages/core/test/session-runner.test.ts` (+4), `packages/tui/test/cli/tui/data.test.tsx` (+2), three new `httpapi-exercise` scenarios, and an updated `event-manifest.test.ts` event count (88 → 90 for the two new durable events). Client and legacy JS SDKs regenerated. Full suites (re-verified against this fork's current `dev`, including the manual merge against model-fallback's own changes to the same runner functions): `packages/core` 1178 pass (only the pre-existing `pty` flake); `packages/opencode` 3613 pass, only the 4 pre-existing, confirmed-unrelated `cf-ai-gateway` failures; `packages/tui` 230 pass; `httpapi-exercise` coverage mode 214 pass (only the pre-existing, unrelated missing `/api/session/{sessionID}/cost` scenario).
Search within the current session's message history in the TUI — open with `<leader>f` or `/find` (alias `/search`), type a query, step between matches with Enter/Shift+Enter, Esc to close.
0 commit comments