Commit c5e6f47
fix(permission): route HTTP reply to
The v1.4.0 upstream merge introduced a new Effect-based `Permission`
namespace (`packages/opencode/src/permission/index.ts`) and rewired the
HTTP permission routes to it, but left the tool ask path on the
existing `PermissionNext` namespace (`packages/opencode/src/permission/next.ts`).
Result: ask and reply talk to two separate in-memory pending Maps, and
every permission round-trip silently no-ops.
Concretely:
- `tool/bash.ts:155` and `altimate/tools/sql-execute.ts:32` call
`ctx.ask(...)` → `PermissionNext.ask` (via `session/processor.ts` and
`session/prompt.ts`), storing `{resolve, reject}` in
`PermissionNext`'s pending Map and publishing `permission.asked`.
- TUI `--yolo` auto-reply and manual `Allow once` / `Allow always` /
`Reject` buttons all reply via `POST /permission/{id}/reply`, which
post-merge invokes `Permission.reply` (`permission/index.ts:204`).
- `Permission.reply` looks up the id in `Permission`'s pending Map,
finds nothing, hits `if (!existing) return` (line 207), no-ops. The
deferred in `PermissionNext.pending` never resolves; tool stays in
`state.status = "running"` forever.
- Because the early return is *before* `Bus.publish(Event.Replied,
...)`, the TUI's `permission.replied` handler in
`cli/cmd/tui/context/sync.tsx:162` never clears the dialog — that's
why "Allow always + Confirm" loops back to the same prompt.
This change reverts the routing layer to `PermissionNext`, matching
`main`. Three files:
1. `server/routes/permission.ts` — runtime fix; this is the route the
TUI / yolo / SDK actually hit.
2. `server/routes/session.ts` — same bug pattern in the legacy
`/session/:sessionID/permission/:permissionID` route. No callers
in the current repo (TUI / ACP / SDK), but closes the dormant
footgun for any external SDK consumer.
3. `session/session.sql.ts` — type-only annotation.
`Permission.Ruleset` and `PermissionNext.Ruleset` are structurally
identical zod schemas, so cosmetic / consistency-with-main.
The new Effect-based `Permission` namespace from upstream is left
untouched but currently has no callers. Follow-up: either delete it or
migrate every `ctx.ask` site to it; out of scope for this fix.
Verified via session DB inspection on the upstream/merge-v1.4.0 branch:
`bash` on a non-trivial command (e.g. `which duckdb`) and `sql_execute`
on a write query (e.g. `CREATE TABLE …`) both stuck with
`state.status = "running"` indefinitely; tools that bypass `ctx.ask`
(warehouse_*, `sql_execute` on read queries) were unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>PermissionNext to unblock tool ask deadlock1 parent 04dbf62 commit c5e6f47
3 files changed
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
1021 | 1021 | | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | | - | |
| 1024 | + | |
1025 | 1025 | | |
1026 | 1026 | | |
1027 | | - | |
| 1027 | + | |
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
0 commit comments