Repository navigation
fix: answer /login cancel during chat sign-in on channels without command source - #175345
masatohoshino wants to merge 8 commits into
Conversation
Adopt channel ingress before the provider sign-in wait, as manual compaction does. The device-code wait can outlive the claim-to-adoption stall watchdog; adopting first frees the lane so `/login cancel` and other messages get through, and the claim cannot be retried into a second sign-in.
… channels Channels such as IRC and Slack pass command authorization without marking the command source, so their command turns resolve as normal turns. The admission ticket and the foreground reply FIFO only skip native or text-slash turns, so a typed `/login cancel` (or `/status`) waited behind the running sign-in turn. Resolve the turn for both checks through the existing fallback that already treats an authorized control-command body as an explicit command turn. Unauthorized senders and ordinary messages still wait in order.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesAdopt login ingress before device sign-in waits and recognize authorized typed control commands on channels without command-source metadata. Example: An IRC owner sends /login github-copilot, then /login cancel while approval is pending.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current login-cancellation bug with relevant runtime evidence and no actionable findings; current-head CI remains in progress. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherChannel ingress feeds authorized messages into shared command admission and buffered reply delivery; provider login waits asynchronously while cancellation must reach the same chat's flow. flowchart LR
A[Channel message] --> B[Durable ingress]
B --> C[Command turn resolution]
C --> D[Session admission]
D --> E[Login flow owner]
E --> F[Buffered reply delivery]
F --> G[Channel acknowledgement]
Technical reviewBest possible solution: Use the existing ingress-adoption lifecycle and shared command resolver to make cancellation responsive without changing ordinary-message ordering. Do we have a high-confidence way to reproduce the issue? Current-main source retains both reported waits, and the contributor supplies a concrete built-Gateway IRC reproduction; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? The patch fixes both owning boundaries with one shared resolver and the existing adoption operation, preserving command policy, authorization, and text-command settings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cd8290c2f6a9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +34, Tests +236. Total +270 across 9 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 30, 2026, 2:09 PM ET / 18:09 UTC (Revision 6). |
The unmarked-turn fallback promoted an authorized typed control command even on a surface that does not handle text commands (`commands.text: false` on a native-command channel), so a literal `/status` skipped the admission ticket and the foreground FIFO. Gate the promotion with `shouldHandleTextCommands` for the turn's surface. The admission and FIFO tests now observe the owner signals (the inherited admission ticket's wait, the delivery order behind the earlier turn) instead of 200 ms timeout races, and cover the disabled-text case.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The type-aware lint rule prefer-promise-reject-errors flags rejecting with the untyped abort reason. Reject with an Error, as the sibling commands-login test does.
Resolve the conflict in src/auto-reply/dispatch.delivery-order.test.ts by
porting the marked, unmarked and disabled-text /status ordering cases to
the reworked helpers (mockReplies, pause, sendFinal, finals).
The upstream rewrite of command-turn-context.test.ts dropped the shared
emptyConfig constant; the resolver cases now pass {} inline as the rest
of that file does.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
… case The admission case polled the dispatcher with vi.waitFor. Resolve a deferred from the reply resolver instead and wait on it within the test signal, as the neighboring /steer case does.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Closes #175344
What Problem This Solves
Fixes:
/login cancelgoes unanswered until the chat sign-in is dropped, about 5 minutes after/login(4 minutes after the cancel in the run below), when an owner starts/login github-copilot(or another device sign-in) on a channel that does not mark typed commands, such as IRC, Signal, LINE, Feishu, MS Teams or Nextcloud Talk.User Impact
User impact: during a chat sign-in on these channels,
/login cancelanswers within a second, as the sign-in prompt promises, and the sign-in no longer stalls the sender's channel lane.On these channels, every authorized typed active-run-safe command now runs beside an active turn, as it already does on channels that mark commands (Discord, Mattermost, Matrix, iMessage, Tlon, SMS). That set includes the state-changing
/new,/resetand/stop, not only/statusand/help. Unauthorized senders, ordinary messages, and typed commands on a surface withcommands.text: falsestill wait in order.Why This Change Was Made
The cancel was held back in two places, and both are needed for it to get through:
/loginturn waits for the provider inside the turn without marking its durable ingress claim adopted. The claim keeps the sender's ingress lane until the 5-minute adoption watchdog releases it for retry.runChannelProviderLoginnow adopts after the authorization check and before the provider flow, the same way/compactdoes. The flow still rechecks current authority first. Once the claim is adopted, a Gateway restart during the sign-in does not replay/login; the user sends it again.command_resolutionphase, which may run beside the active turn) and the foreground reply FIFO let an active-run-safe command pass only when it is a native or text-slash turn. A channel that passes command authorization without settingCommandSourceyields a normal turn, so the cancel queued behind the sign-in. The two checks now resolve the turn withresolveExplicitCommandTurnContext, which treats an authorized control command from an unmarked channel as an authorized text-slash turn. It reuses the existingisExplicitCommandTurnContextfallback that the first check already used as its outer gate, and promotes only whereshouldHandleTextCommandsaccepts typed commands for the turn's surface.Design note: the turn resolution owns this decision, so
isActiveRunSafeCommandTurnand its unit contract stay unchanged, and no/login cancel-only branch is added to the callers. Marking commands in each channel would also work, but it touches every unmarked channel plugin.Evidence
Tested at
4f132e1b82c, which mergesupstream/main287b38a78d2into this branch. Before and After both ran on 2026-10-23 with Node 24.22.1.Re-run on 2026-10-30 at
42f4fd443e9, which mergesupstream/main885e57e9f9d: the After run below, rebuilt with the same setup, gave the same result. The prompt and code arrived at +79.4 s,/login cancel(sent at +135.0 s) gotProvider login cancelled for this chat.at +136.8 s on a host under heavy load, the sign-in turn ended right after (totalMs=59419), and the 720 s run logged noclaim→adoption stalledand nostuck sessionline. The Before run was not repeated: the merge conflicts were only in test files, and the four production changes merged without conflict.Built CLI,
openclaw gateway runwith an isolated state directory and no outside network. The real IRC channel plugin connects to a loopback IRC server. A local stand-in for the GitHub device-code endpoints hands out a code and never approves it. The owner sends/login github-copilot(owner joins at +75 s), then/login cancel60 s later.Before (
upstream/main287b38a78d2):The cancel ran only after the stall watchdog ended the sign-in turn (
totalMs=299546), so it found no sign-in to cancel.After (this PR):
Observed result: the cancel answers in 0.2 s, and the sign-in turn ends right after it (
totalMs=59673). The 720 s run logs noclaim→adoption stalledand nostuck sessionline. The After run used26b392b3789; the later amend to4f132e1b82cchanged only a test file, and so does3a5b9ce67e0.In the first run of this PR (base
19c5e58c2e8), the same run with only the adoption fix still waitedreply.wait_admission_ticket:434111msfor the cancel. Both fixes are needed.Checks at
4f132e1b82c, repeated at3a5b9ce67e0for the one test file it changes (that file,oxlint,oxfmt,tsgoon everysrctest shard and the ratchet): the touched tests and the other auto-reply and channel-turn tests that import the four changed production files (21 files), type-awareoxlint(scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json, as CI runs it) andoxfmt --checkon the changed files,tsgoon the core project and everysrctest shard, andcheck-test-timeout-race-ratchet(baseline unchanged). One of the 21 files,route-reply.delivery-result.test.ts > preserves session writer authority through route normalization, fails the same way onupstream/main287b38a78d2without this change. These ran through the repo scripts directly.Each changed test file, timed with
node scripts/test-projects.mts <file> --maxWorkers=1(whatpnpm testruns) and a warm transform cache:--maxWorkers=1wallsrc/auto-reply/reply/commands-login.ingress.test.tssrc/auto-reply/reply/commands-login.ingress.test.ts(1 file, Vitest 11.43 s), CI run 39865252560src/auto-reply/command-turn-context.test.tssrc/auto-reply/command-turn-context.test.ts(1 file, Vitest 4.13 s), CI run 39865252560src/auto-reply/reply/dispatch-from-config.active-command.test.tssrc/auto-reply/reply/dispatch-from-config.active-command.test.ts(1 file, Vitest 6.62 s), CI run 39865252560src/auto-reply/dispatch.delivery-order.test.tssrc/auto-reply/dispatch.delivery-order.test.ts(1 file, Vitest 4.66 s), CI run 39865252560The CI seconds come from the CI run on the pre-merge head
3a5b9ce67e0, where each file ran as its own shard in the changed-test jobs. At42f4fd443e9the four files pass again: 1, 12, 13 and 12 tests. Their wall times on a loaded host were 17.7 s, 15.1 s, 29.8 s and 22.1 s.The merge follows two main changes. The reply admission ticket is gone (#175837, #176447), so the admission case moved from
dispatch-from-config.acp-abort.test.tstodispatch-from-config.active-command.test.ts, next to main's/login canceladmission cases. Main also rewrote the same-session/statusfence test, which now covers the marked command, so this PR keeps only its unmarked rows.The merge of
885e57e9f9dhad two conflicts, both in test files. Indispatch.delivery-order.test.ts, main added aqueuedrow to the fence-retention case next to this PR's unmarked/statusrows; both are kept. Invitest.database-worker-core-paths.mjs, main addeddispatch-from-config.reply-dispatch-scope.test.tsbeside this PR'scommands-login.ingress.test.tsentry; both entries are kept. At42f4fd443e9, the 21 related test files plus main'sreply-dispatch-scopetest (22 files, 305 tests) all pass, including theroute-reply.delivery-result.test.tscase that failed on287b38a78d2.tsgopasses on the core project and on everysrctest shard. Type-awareoxlintandoxfmt --checkpass on the changed files.Tests (before/after run of
42f4fd443e9against885e57e9f9d: 6 fail on the base and pass here, 32 guard tests pass on both; no added test uses a wall-clock race):commands-login.ingress.test.ts(new): drives the real channel ingress drain and its SQLite queue intohandleLoginCommandon a fake clock. It fails on the base because the stall watchdog releases the/loginclaim (expected "release" to not be called at all).dispatch-from-config.active-command.test.ts: with a turn active on the session, an authorized unmarked IRC/login cancelreaches its reply resolver and gets its reply while that turn stays active. The case waits on a deferred the resolver settles, within the test signal. On the base, the command waits behind the active turn, so the resolver is never reached and the case runs into the test timeout.dispatch.delivery-order.test.ts: the same-session/statusfence case runs for an unmarked command and for an unmarked command withcommands.text: false. The older turn is released when/statussends its final. The unmarked case fails on the base (expected [ 'old', 'status' ] to deeply equal [ 'status', 'old' ]); the disabled-text case expects['old', 'status'].command-turn-context.test.ts: the resolver promotes an authorized unmarked control command, keeps an unauthorized one a normal turn, and leaves a marked turn unchanged.Simplification pass: production +38/−4 in 4 files, tests +238/−3 in 4 files, plus one Vitest database-worker list entry. The admission fix is one resolver plus two one-line call changes. A
/login cancel-only branch at both callers was dropped for it. Main's reply admission has a third active-run-safe check (dispatch-from-config.lifecycle.ts); the run above shows the cancel already gets through without changing it, so it is left alone.command_resolutionadmission returns ready while another turn holds the mailbox (allowActiveResolution), so the third check is not reached for this turn.Not covered:
hello) sent during the sign-in still wait until the sign-in turn ends or is cancelled. This is the existing order for normal turns. In the run above,helloreached the agent but could not answer, since no model was reachable./new,/resetand/stop. This is intended: it matches channels that mark commands.