Repository navigation
Conversation
b11d459 to
8846d18
Compare
User decisions: - Re-read the job list after a reconnect so missed events don't leave stale rows
There was a problem hiding this comment.
I couldn't run the web app here (no Playwright browsers), so I checked the reconnect path at the client level. It looks like the base already does what this PR adds.
The base job-list effect in model.ts reads serverSDK.connection.status(), and createClientConnection moves that status to reconnecting and back to connected on every stream reconnect, including after a server restart and the forced resync after sleep. I ran a quick check with a fake stream that drops twice. An effect gated on status() === "connected" ran on all three connects, each time before the batched server.connected (about 16 ms later). The base therefore already reloads the full list after a reconnect, and mergeJobList replaces the state, so a missed settle should already be cleared. With this change, every reconnect (and the first connect with a session open) sends two job.list requests, and the second cancels the first. If you've seen a stuck row that the status effect misses, could you describe the case? Otherwise the new server.connected handler can probably be dropped.
The bun.lock diff only removes libc fields from platform packages, which looks like output from a different Bun version (the repo pins bun@1.4.4). It's unrelated to this change and is probably best reverted.
The job-list tests pass and tsc -b for packages/app is clean. Public API: unchanged.
| const next = new Map(previous) | ||
| next.delete(info.id) | ||
| const stopJobs = serverSDK.event.on("experimental.job.updated", (event) => jobList.update(event.data.info)) | ||
| const stopJobsResync = serverSDK.event.on("server.connected", () => { |
There was a problem hiding this comment.
This looks redundant with the effect below. createClientConnection sets connection.status() to reconnecting and then connected on every stream reconnect, so that effect already calls loadJobs then. server.connected reaches listeners about 16 ms later (the event flush), so each reconnect, and the first connect, now sends two job.list requests, and the second cancels the first. Is there a case where server.connected arrives without a status change? If not, this handler can go.
There was a problem hiding this comment.
You're right, thanks. createClientConnection (packages/client/src/solid/connection.ts) sets status to connecting/reconnecting at the top of each connect attempt (L150) and after each drop (L163), then back to connected once server.connected is read (L115). The idle watchdog (L91) and resync() (L212-217, foreground/online) both just abort the live request, so they go through that same loop, and stop()/start() sets connecting (L208). I couldn't find a path where the stream reopens while staying connected, so the status-gated effect already re-lists on every reconnect.
Removed the server.connected handler in c9b5808. What's left is createJobList, which moves the existing list/event merge out of the effect, plus tests for the missed-settle and in-flight-event cases. That's a refactor with tests, not a behavior fix. The stray bun.lock change was already dropped (8846d18), and the diff only touches packages/app/src/session/requests/.
There was a problem hiding this comment.
I checked c9b5808 and it looks right. The server.connected handler is gone, and the effect is once again the only thing that re-lists jobs. In connection.ts, status goes to connecting or reconnecting at L150, L163 and L208, and back to connected at L115. That means every reconnect, including the ones triggered by the idle watchdog and resync(), re-lists jobs once.
What I verified:
git diff pr/base...pr/headchanges onlybackground.ts,job-list.test.tsandmodel.ts, all underpackages/app/src/session/requests/. There is nobun.lockchange.bun test src/session/requests/job-list.test.tspasses (4 tests).- In
model.ts, the effect's behavior is the same as before. The in-flight merge and theparams.id === sessionIDcheck are just moved intocreateJobList.
One thing left: the PR title (fix(app): re-read background jobs after reconnect) and the description still say it adds a server.connected re-read, and that's no longer true. Since this is now a refactor with tests, retitle it refactor(app): … and cut the server.connected paragraph from the description.
I didn't change anything in the checkout.
User decisions: - Re-read the job list after a reconnect so missed events don't leave stale rows
There was a problem hiding this comment.
The new commit reverts the unrelated bun.lock changes, so the lockfile is no longer in this PR. Its only other change is a blank line in model.ts, so the inline question about the server.connected handler duplicating the status effect is still open. job-list.test.ts still passes. Public API: unchanged.
There was a problem hiding this comment.
Removing the server.connected handler addresses my earlier comment. This is now a refactor with no behaviour change: createJobList handles events the same way the old code in model.ts did, and jobs are re-read only when the connection comes back. The tests in src/session/requests/ pass and tsc -b for packages/app is clean. Public API: unchanged.
|
Closing: as the review showed, the app already re-reads the job list on every reconnect (connection status goes through reconnecting → connected on every drop, watchdog and resync), so there's no bug to fix. What remained was a refactor plus tests for behaviour that already works. |
Issue for this PR
Closes #
Type of change
What does this PR do?
Moves the composer activity pill's job list/event merge from
model.tsintocreateJobList(background.ts) so it can be unit tested. Behavior is unchanged. The list is still re-read whenconnection.status()returns toconnected, which already happens on every stream reconnect, watchdog abort and forced resync (packages/client/src/solid/connection.ts). Each load replaces the job state, and events that arrive while a list request is in flight still win over its response (#64966).How did you verify your code works?
Added tests in
job-list.test.ts: a job whose settled event was missed disappears after a reload, and an event during the reload wins over the stale list. I also rantsc -bfor app.Screenshots / recordings
n/a
Checklist