Repository navigation
feat(apps): tell app pages which build is busy, and let a page report its runs - #2353
PabloWiedemann wants to merge 16 commits into
Conversation
… its runs
localBuilds now names the app a build is busy with (busyWith), and the
new onLocalBuildsChanged tells app pages when a build becomes busy or
free, for the website's Run on menu. Announcements are numbered, so a
late answer cannot overwrite a newer one.
The new window.comfyDesktopRuns.reportRun({ running }) lets a page say
when a run starts and ends. Once a page calls it, Desktop stops
following the page's run toast for that page.
The bridge types are regenerated and bumped to 0.18.0.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
…sktop cannot see busyWith now names the app whose run the build is working on, or the oldest queued run, and never the app that asks, so a page waiting behind its own run is not told to wait for itself. Each page gets the builds as it sees them. An app with no catalog name shows as "another app". The contract now says that busyWith and onLocalBuildsChanged see only runs from apps in the Apps view, so a build can still be busy with a run from its ComfyUI window. Build announcements stop once Apps is turned off. The bridge types are regenerated.
…Desktop lacks A queued run that starts working now tells the app pages, so busyWith moves to the run that is actually working. The builds pull uses the same caller check as the other local calls, and a broadcast looks up the builds once for all pages. busyWith.title is now absent when Desktop has no name for the app, so the page can say "another app" in its own words and language. The bridge types are regenerated.
|
Starting review at ec8f332. |
|
Holding at ec8f332 on 1 Must: waiting status names an app behind your run. Must
Should fix
Clean: Access, Contract, Vendor, Rules, Cause. Not covered:
Checked: Read head/base attribution paths and ComfyUI queue ordering; compared announcement delivery with page identity guards; searched bridge readers in companion clones. ~987k effective tokens for this review (4.8M raw; cache reads weighted 0.1x, cache writes 1.25-2x) |
busyWith now looks only at the run the build is working on and the runs queued ahead of the asking app's own runs. Before, it left out the asking app and then named the oldest other run, which could be one queued behind it, so the page said it waited for an app that was waiting for it. An app whose own run is working gets no busyWith. A builds announcement now goes to a page only when it still shows the app and document the lookup was for, the same check callerUnchanged makes, so a page that switched apps during the lookup does not get the old app's list. The bridge docs now say reportRun describes the whole page: report running false only when no run is left, since each report replaces the page's state.
|
Thanks. All three are fixed in a5afc84:
|
|
Starting re-review at a5afc84. |
|
Reviewed at a5afc84 (since ec8f332): queue attribution, page identity checks and run-report wording updated. Fixed: the reported sequential-queue case, delivery across an app switch, and aggregate run-report instructions. Still open: queue attribution needs one ordering fix covering normal submissions, identical timestamps, and concurrent requests accepted in a different order from their sends. Must
Clean: Resilience, Access, Words. Not covered:
~470k effective tokens for this review (2.2M raw; cache reads weighted 0.1x, cache writes 1.25-2x) |
Each run now keeps the queue number ComfyUI returns for it, and busyWith picks the blocker from the build's runs in that order, keeping the asking app's place. Before, runs were ordered by when Desktop sent them, so two requests that ComfyUI accepted in the other order could name an app behind the asking one, and runs sent at the same moment could hide the one ahead. Runs without a number fall back to send order, then the order they were accepted in.
|
Thanks. Fixed in d6e3fc7: each run keeps the queue number ComfyUI returns, and busyWith picks the blocker from the build's runs in that order, keeping the asking app's place. Runs with no number fall back to send time, then the order they were accepted in. Tests cover the three inputs together: numbers out of send order, runs sent at the same moment, and normal order. A localComfy test also checks that the number reaches the run through a real /prompt answer. Both fail without the fix. |
|
Starting re-review at d6e3fc7. |
|
Reviewed at d6e3fc7 (since a5afc84): queue attribution now follows ComfyUI's queue numbers. Fixed: normal queue order, identical send times, and requests accepted in a different order from their sends. Desktop retains the returned number at Still open: none. Clean: Correctness, Resilience, Access. Not covered:
Checked: Read the head/main queue paths and ComfyUI's queue implementation. ~359k effective tokens for this review (1.5M raw; cache reads weighted 0.1x, cache writes 1.25-2x) |
Stacked on #2351 (keep apps running in the background). Split out of #2351 in review, because this is the part the website uses. Related to DESK-588.
What changes
This PR adds two things to the bridge that Comfy pages in the Apps view use.
1. Which build is busy, for the website's Run on menu
comfyDesktopLocal.localBuilds()now givesbusyWith: { appId, title }for a build that is working on, or has first in its queue, a run from another app in the Apps view. It names the working run first, otherwise the oldest queued one, and never the app that asks. For example,titleis"Remove Background". It is absent when Desktop has no name for the app, so the page says "another app" in its own words and language. When a queued run starts working, the pages are told, sobusyWithfollows the working run.busyWithis absent when no other app has a run on the build, but the build can still be busy with a run from its own ComfyUI window or another tool. Reading the build's own queue too is a product question for later.comfyDesktopLocal.onLocalBuildsChanged(callback)is new and optional. It calls back when a run from an app starts or ends on a build. Each page gets the list as it sees it, and nothing is sent once Apps is turned off.POST /prompt. Desktop does not refuse or reorder runs.2. A page can report its own runs
window.comfyDesktopRuns.reportRun({ running: boolean })is new.running: truewhen the person presses Run, keep the run going through any queue wait, and call it withrunning: falsewhen the run finishes, fails or is cancelled..cs-toasts .cs-toast), as in feat(apps): keep apps running in the background when you switch away #2351.Contract
src/types/comfyDesktopBridge.tsdocuments all of it.@comfyorg/comfyui-desktop-bridge-typesis regenerated and bumped from 0.17.1 to 0.18.0, and its README listswindow.comfyDesktopRuns.What the website needs
busyWithis set, and keep it pickable. An absentbusyWithdoes not prove the build is free. Update live withonLocalBuildsChanged. Check that both exist first, because older Desktop builds lack them.execution_startandbusyWithis set, show "Waiting for {busyWith.title} to finish", or your own "another app" whentitleis absent. Then show the normal progress.reportRunat the start and end of every run, the waiting phase included.Tests
localAppEvents.test.ts: the working run is named before queued ones, and the oldest queued run when none works yet. The asking app is never named. Names clear when runs end. Watchers hear when runs start or end, when a queued run starts working, and when the oldest of 200 runs is dropped.openInComfy.test.ts:busyWithis given, with no name for an app the catalog lacks. It never names the asking app, several asking apps share one look at the builds, and a build shows as free again once its run ends.registerAppsLocalHandlers.test.ts: builds go to every open app page as that page sees them, are not looked up with no page open or with Apps off, and an older answer that arrives late is dropped.appRunWatcher.test.ts(browser): the toast is followed until the page reports runs itself. It is never watched after a report, and anything butrunning: truecounts as no run.pnpm run typecheck,pnpm run lint,pnpm run format:check,pnpm run bridge-types:checkand the full unit suite pass.Not checked
This PR has no live check. No website page calls
reportRunoronLocalBuildsChangedyet. That comes with the website PR.