Repository navigation
Commit bde2ec7
authored
fix(cli): show the background update notice inside the TUI (#379)
## Requirement or Bug
After a background auto-update, the "Pythinker Code updated to vX"
notice never shows in fullscreen mode.
## Bug Reproduction Steps
1. Set `tui_mode = "fullscreen"` and `[upgrade] auto_install = true` in
`tui.toml`.
2. Launch an older native build. The background check installs the new
version with no message.
3. Launch again. `install.json` records `notifiedAt`, but the screen
shows only the welcome banner.
## Root Cause
`showPendingBackgroundInstallNotice` wrote the notice to stdout before
the TUI started. Fullscreen mode enters the alternate screen and clears
it (`\x1b[?1049h` + `\x1b[2J`), so the line was erased right after it
was written, and `notifiedAt` was already set so it never came back.
This is a fundamental fix: the notice now goes through the TUI's
existing startup-notice path.
## Code Changes
```diff
handleMainCommand (shell mode)
- runUpdatePreflight(version, { track }) // notice -> stdout
+ runUpdatePreflight(version, { track, onUpdateNotice }) // notice -> variable
+ if result === 'exit': write the notice to stdout, then exit
- runShell(options, version)
+ runShell(options, version, { updateNotice })
PythinkerTUI({ startupNotice: combineStartupNotice(updateNotice, configWarning) })
finishStartup -> showStatus(startupNotice) // transcript, survives fullscreen
```
- `preflight.ts`: new optional `onUpdateNotice` option. Without it the
notice still goes to stdout.
- `main.ts`: shell mode collects the notice and passes it to `runShell`.
Print mode passes no callback, so it is unchanged.
- `run-shell.ts`: merges the update notice with the existing `tui.toml`
parse warning.
## Behavior Changes and Affected Users
| Behavior | Before | After | Who relies on the old behavior | Escape
hatch |
|---|---|---|---|---|
| Update notice, TUI fullscreen | Written to stdout, then erased by the
alt screen | Shown in the transcript | Nobody (never visible) | n/a |
| Update notice, TUI inline (`tui_mode = "regular"`) | Plain stdout line
above the TUI | Dim status line in the transcript | Users who read it in
scrollback | none; the text is the same |
| Update notice when preflight returns `exit` | stdout | stdout (written
just before exit) | Same population | n/a |
| Update notice, print mode / non-TTY | Not shown (`isTTY: false`) | Not
shown | Headless scripts | n/a |
| `runUpdatePreflight` with no `onUpdateNotice` | stdout | stdout | Any
other caller | n/a |
Affected module: `apps/pythinker-code` CLI startup. Test coverage:
- `preflight.test.ts`: notice goes to `onUpdateNotice` and not stdout;
the existing stdout test still passes.
- `main.test.ts`: shell mode hand-off to `runShell`; the `exit` path
prints the notice; print mode is unchanged.
- `run-shell.test.ts`: `updateNotice` becomes the TUI `startupNotice`.
- `pythinker-tui-startup.test.ts`: in fullscreen, the startup notice
renders in the transcript.
- Live run: `pnpm dev:cli` in fullscreen with a pending `lastSuccess`
shows "Pythinker Code updated to v2.7.0" and the changelog link in the
transcript.
## 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: issue must have a
maintainer's `/approve`).
- [x] I have added tests that prove my feature works.
- [x] The behavior-change table above is complete, and every removed
behavior or flipped default is named in the changeset and either has an
escape hatch or was explicitly approved by a maintainer in this PR.
- [x] Ran `gen-changesets` skill, or this PR needs no changeset.
- [x] Ran `gen-docs` skill, or this PR needs no doc update.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Background update completion notices now appear in the TUI startup
message. If the app exits before the TUI opens, the notice is shown in
the terminal instead.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 75b9548 commit bde2ec7
8 files changed
Lines changed: 141 additions & 11 deletions
File tree
- .changeset
- apps/pythinker-code
- src
- cli
- update
- test
- cli
- update
- tui
| 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 | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
437 | | - | |
| 438 | + | |
438 | 439 | | |
439 | 440 | | |
440 | 441 | | |
441 | 442 | | |
442 | 443 | | |
443 | | - | |
| 444 | + | |
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
| |||
469 | 470 | | |
470 | 471 | | |
471 | 472 | | |
472 | | - | |
| 473 | + | |
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
| |||
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
807 | | - | |
| 808 | + | |
808 | 809 | | |
809 | 810 | | |
810 | 811 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| |||
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | | - | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
259 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
260 | 281 | | |
261 | 282 | | |
262 | 283 | | |
| |||
365 | 386 | | |
366 | 387 | | |
367 | 388 | | |
| 389 | + | |
368 | 390 | | |
369 | | - | |
| 391 | + | |
370 | 392 | | |
371 | 393 | | |
372 | 394 | | |
| |||
433 | 455 | | |
434 | 456 | | |
435 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
436 | 479 | | |
437 | 480 | | |
438 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
656 | 688 | | |
657 | 689 | | |
658 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
978 | 1004 | | |
979 | 1005 | | |
980 | 1006 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
330 | 346 | | |
331 | 347 | | |
332 | 348 | | |
| |||
0 commit comments