Repository navigation
refactor(core): share job notice formatting and shell output snapshots - #60704
kitlangton wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks sound. With { restarted: true }, Job.formatNotice produces the same restart notices as the removed restartMessage for every shell and image status. Shell.result still renders (no output) for an empty capture, and Shell.snapshot only extracts the existing tail logic. I compared the old and new paths and ran job.test.ts, session-execution.test.ts and shell.test.ts in packages/core (59 pass). Type errors from tsc are the same as on the base, and none are in the changed files.
Public API is unchanged: Job.formatNotice, Job.Notice and Shell.Interface.snapshot are internal to packages/core.
One small inline note: the unknown cast in formatNotice.
| } | ||
|
|
||
| export function formatNotice( | ||
| input: Pick<Background, "id" | "status" | "output" | "error"> & { readonly value?: unknown }, |
There was a problem hiding this comment.
value?: unknown is then cast to the shell output type on line 86, so the type checker won't catch a wrong value passed in by the live-notice callers in the next splits. Could this take the ShellResult output type directly (exported from shell/result.ts if needed) instead of using unknown plus a cast?
Share background job notice formatting and live shell output snapshots ahead of auto-backgrounding.
Startup recovery and live background tools format the same shell and image completion notices, and shell result capture only worked after exit. Extracting both helpers keeps behavior identical today while preparing live job reads and central notice delivery.
❌ Before
session/execution/restart.tsowned a privaterestartMessageformatter for shell and image background notices.Shell.resultcomputed bounded output tails inline only afterwaitcompleted, so callers could not read bounded partial output from a still-running command.✅ After
Job.formatNoticeformats shell and image notices in one place, andrestart.tscalls it with{ restarted: true }.Shell.snapshotreads the bounded output tail without waiting for exit, andShell.resultreuses it.🟰 Behavior change: none.
📊 Numbers
+87 −66)Job.formatNotice+ liveShell.snapshotTests: 41 existing tests pass across
job.test.tsandsession-execution.test.ts.👀 Read:
packages/core/src/shell.tsaroundsnapshot, ensuring empty running output returns""while completed empty output still renders"(no output)". The rest is routine.🔍 Split 1 of 6 from #60495 · no user reports
Checks run
bun run --cwd packages/core typecheckbun --cwd packages/core test test/job.test.ts test/session-execution.test.ts: 41 pass