Repository navigation
Commit e6778dc
authored
fix: harden journal repair, task detach, subagent prompts, and login cancel (#221)
## Related Issue
No linked issue — maintainer-authored reliability and API work.
## Problem
Five separate gaps:
- A wire journal repair that fails (disk full, backup write refused)
left the journal corrupted, and the next `appendRecord` wrote behind the
corrupted tail. Callers of `flush()` saw success.
- Subagent turns opened in the transcript with no prompt, so the reader
could not see what the subagent was asked to do.
- A running foreground task could only be cancelled, never moved to the
background, over the server API.
- In the VS Code extension, two concurrent opens of the same session for
one view each wrapped the SDK session, so every streamed event was
delivered twice.
- Denying the OpenAI Codex consent page ended as `OpenAI Codex login
failed` after first prompting for the redirect URL, and the web sign-in
page waited out its full TTL.
## What changed
- `repairWireJournal` reports `repaired` / `failed`. `WireService` keeps
the failed repair pending, retries it before the next append, and
rethrows a `RECORDS_WRITE_FAILED` `WireError` from `flush()` when it
still fails, so nothing is appended behind a corrupted tail.
- `turn.started` now carries the prompt for `system_trigger` /
`subagent` origins, and the cold-path grouping folds the opening input
onto that turn. Search extraction still filters those messages out.
- New `POST /api/v1/sessions/{session_id}/tasks/{task_id}:detach`
action, answering `{ detached, status }`. The bash and subagent tools
report a user-initiated detach distinctly from a timeout detach, and
process tasks carry their parent tool call id.
- `PythinkerRuntime` serializes open / attach / detach per webview id,
so concurrent callers cannot both miss the session map.
- The OpenAI Codex callback distinguishes `error=access_denied` from
every other dead end. The CLI reports it as cancelled, and
`CodexLoginFlow` moves the attempt to `cancelled` with a reason instead
of waiting for expiry — the web sign-in page already renders that state.
## Checklist
- [x] I have read the
[CONTRIBUTING](https://github.com/PyModel/pythinker-code/blob/main/CONTRIBUTING.md)
document.
- [ ] I have linked a related issue (external PRs: the issue must have a
maintainer's `/approve`).
- [x] I have added tests that prove my feature works.
- [x] Ran `gen-changesets` skill, or this PR needs no changeset.
- [x] Ran `gen-docs` skill, or this PR needs no doc update.
## Risk
- Risk level: medium. Boundaries touched: session journal persistence,
the tasks REST surface, the VS Code session runtime, and the OAuth
callback.
- The journal change makes a previously silent failure loud: `flush()`
can now reject where it used to resolve. That is the intent — the
alternative is losing the record.
- The detach action is additive; `:cancel` keeps its behavior and its
error codes.
- No new dependency and no lockfile change.
## Verification
All exited 0:
- `pnpm run typecheck`
- `pnpm run lint` (0 errors, pre-existing warnings only)
- `pnpm test` — 1,218 files passed, 12 skipped; 20,522 tests passed, 3
expected fail, 79 skipped, 2 todo
- `pnpm run build`, `pnpm run build:web`, `pnpm run check:web`
- `pnpm sherif`, `node scripts/check-nix-workspace.mjs` (18 workspaces)
- `pnpm -C apps/vscode run typecheck`, `pnpm -C apps/vscode test` (18
files / 369 tests)
Each new guard was proven by mutation — reverting it fails the test that
covers it:
- dropping the `system_trigger`/`subagent` case from
`isDisplayablePromptOrigin` → 1 failure in `loop.test.ts`
- collapsing the per-view serialization → 3 failures in
`pythinker-runtime.test.ts`
- settling the callback with `null` instead of the denial → 1 failure in
`openai-codex-oauth.test.ts`
- folding the denial back into the timeout branch → 1 failure in
`codexLogin.test.ts`
`packages/transcript` and `packages/protocol` are web build inputs, so
`dist-web` was rebuilt; only `.web-bundle-manifest.json` changed.
## Rollback and review
- Rollback: revert the single commit; every change is additive or behind
a new branch.
- Residual risk: the journal `flush()` rejection is a new failure
surface for callers that previously ignored a silent loss.
- Human review wanted on the journal repair retry and the tasks route
split.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Foreground tasks can now be detached into the background.
- Background tasks and pending questions appear in the client’s
background-task panel.
- Subagent prompts and attachments display correctly in transcripts.
- Task details can retain parent tool-call information.
- **Bug Fixes**
- Prevented duplicated streaming output during concurrent session opens.
- Improved recovery from session journal write failures.
- Codex sign-in denials now appear as cancelled.
- Improved task detachment behavior and status reporting.
- **Documentation**
- Documented task detachment and updated background-task guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 6fb46b0 commit e6778dc
44 files changed
Lines changed: 957 additions & 67 deletions
File tree
- .changeset
- apps
- pythinker-code/dist-web
- vscode
- src/runtime
- test
- docs/reference
- packages
- agent-core-v2
- docs
- src
- agent
- loop
- tools
- agent
- ask-user-question
- os/bash
- app/codexLogin
- wire
- test
- agent
- fullCompaction
- loop
- questionTools/tools
- task
- app/codexLogin
- os/backends/node-local/tools
- tool
- wire
- agent-gateway
- src
- protocol
- routes
- test
- search
- services
- node-sdk
- src/login
- test
- oauth
- src
- test
- protocol/src
- __tests__
- rest
- transcript
- src/history
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| |||
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
122 | | - | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| |||
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
138 | | - | |
| 143 | + | |
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
| |||
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
164 | 179 | | |
165 | 180 | | |
166 | | - | |
| 181 | + | |
167 | 182 | | |
168 | 183 | | |
169 | 184 | | |
| |||
184 | 199 | | |
185 | 200 | | |
186 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
187 | 206 | | |
188 | 207 | | |
189 | 208 | | |
| |||
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
199 | 235 | | |
200 | 236 | | |
201 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
385 | 470 | | |
386 | 471 | | |
387 | 472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1353 | 1353 | | |
1354 | 1354 | | |
1355 | 1355 | | |
| 1356 | + | |
1356 | 1357 | | |
1357 | 1358 | | |
1358 | 1359 | | |
| |||
1400 | 1401 | | |
1401 | 1402 | | |
1402 | 1403 | | |
| 1404 | + | |
1403 | 1405 | | |
1404 | 1406 | | |
1405 | 1407 | | |
| |||
0 commit comments