Skip to content

feat(apps): show an app page's outputs in Desktop's output dialog - #2156

Open
PabloWiedemann wants to merge 7 commits into
PabloWiedemann/assets-local-foldersfrom
PabloWiedemann/apps-output-dialog
Open

PabloWiedemann wants to merge 7 commits into
PabloWiedemann/assets-local-foldersfrom
PabloWiedemann/apps-output-dialog

Conversation

@PabloWiedemann

@PabloWiedemann PabloWiedemann commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: An app page can show its outputs in the same Desktop output dialog that Assets uses, through a new bridge, window.comfyDesktopOutputs.

Why: every app had its own output card. One dialog that Desktop owns makes outputs look and work the same in Apps and Assets.

Can affect: the app page bridge (src/types/comfyDesktopBridge.ts), AppPageHost.vue, the output dialog, and the panel CSP (blob: in img-src and media-src).

Stacked on #2155. Replaces the Apps half of #2008; the Assets half landed in #2140.

Changes

  • Bridge: showOutput({ items, index }) with each output's name, media type, bytes, tags and whether it has a saved workflow. onOutputAction sends Download and Open workflow back to the page.
  • Checks in main: only from the hosted Apps page, while Apps is on, for the page document that is still loaded. At most 40 outputs and 100 MB, and only image, video and audio types the dialog can show. A name with control or bidi characters is refused, and such tags are dropped. Actions go only to the page that showed the outputs, and only for an index it sent.
  • Dialog: opens over the Apps view. Main's cover logic swaps the app for its still frame. The app gets the keyboard back on close.
  • IPC: the show handler and the action listener live together in registerAppsOutputsHandlers.ts.

Website

The pages read window.comfyDesktopApps today. They need one line to prefer window.comfyDesktopOutputs. That change is in Comfy-Org/comfy-website#456.

Size

About 360 non-test lines added.

Checks

  • typecheck, lint, format and the touched tests pass.
  • Not checked in a running app with a real app page.

An app page can now ask Desktop to show its outputs through a new bridge,
window.comfyDesktopOutputs. showOutput({ items, index }) takes each
output's name, media type, bytes, tags and whether it has a saved
workflow, the same payload the Apps pages send today. Desktop opens the
output dialog that Assets uses over the Apps view, with the outputs and
the one to show first.

Main checks the request the way it checks other page calls: only from
the hosted Apps page, while Apps is on, and only for the page document
that is still loaded. It takes at most 40 outputs and 100 MB in all, and
only image, video and audio types the dialog can show. A request it
cannot show is rejected; it resolves false while the app is not on
screen.

Download, and Open workflow for an output with a saved workflow, go back
to the page on onOutputAction, so the page uses its own download link
and its own Open in ComfyUI. Main sends an action only to the page
document that showed the outputs, and only for an index it sent.

The dialog covers the app page, so the page host swaps the app for its
still frame as it does for any cover. When the dialog closes, the app
gets the keyboard back. The panel CSP allows blob: for the output
previews.

This is the Apps half of #2008, rebuilt on main's Apps page. The Assets
half landed in #2140.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 316748fb-aef8-419a-a619-92060a7c2cb5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Register the panel's output action listener next to the show handler, so
registerAppsHandlers stays as it is on main.
@PabloWiedemann
PabloWiedemann marked this pull request as ready for review November 16, 2026 22:27
@PabloWiedemann
PabloWiedemann requested review from a team as code owners November 16, 2026 22:27
@PabloWiedemann PabloWiedemann added the cursor-review Trigger multi-model Cursor code review label Nov 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Cursor Review — Consolidated panel

Triggered by @PabloWiedemann.

Found 10 finding(s).

Severity Count
🟠 High 1
🟡 Medium 6
🟢 Low 3

Panel: 8/8 reviewers contributed findings.

function hasHiddenCharacters(value: string): boolean {
return (
BIDI_CONTROL.test(value) ||
Array.from(value).some((char) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High — hasHiddenCharacters runs Array.from(value) on the untruncated string, and trimmed only slices to MAX_NAME_LENGTH/MAX_TAG_LENGTH afterwards. Since name and tags are unbounded and are not counted toward MAX_OUTPUTS_BYTES (which sums only bytes buffers), one request with multi-megabyte names/tags materializes hundreds of millions of per-character strings in the main process, blocking the event loop or OOM-killing the app. Reject strings longer than the max (or slice first) before scanning characters. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9881948: names and tags are cut to their limit before the character check, so a very long string is scanned only up to 200 or 40 characters. A test sends a 5 MB name.

const outputs = Array.from(items, readOutput)
if (outputs.some((output) => output === null)) return null
const shown = outputs as AppOutput[]
const sentBytes = shown.reduce((sum, output) => sum + output.bytes.buffer.byteLength, 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — sentBytes sums output.bytes.buffer.byteLength, which double-counts when several outputs are views into one ArrayBuffer — structured clone preserves that sharing and transfers the buffer once. Two 30 MB views of a single 60 MB buffer, or 40 small views of one large buffer, are rejected with a thrown error even though the real payload is well inside the limit; sum byteLength per view, or dedupe buffers by identity. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: counting the whole buffer is deliberate, so a small view cannot carry a large buffer past the limit; a page sends one buffer per output.

if (sentFrom === null || !(await isFromAppsPage(event))) return false
const outputs = readOutputRequest(request)
if (!outputs) throw new Error('Desktop cannot show these outputs.')
return showAppOutputs(event.sender, sentFrom, outputs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — showOutputFromAppsPage accepts up to 100 MB per request with no per-page, per-window, or global rate limit, and the payload is fully deserialized into main-process memory before validation, then copied again to the panel renderer and a third time into Blobs. A hosted page can loop showOutput to exhaust memory; the sibling hosted-page channel already enforces PAGE_EVENTS_PER_MINUTE/PAGE_EVENTS_PER_SESSION in appPageEvents.ts. Raised by 3 of 8 reviewers (kimi-k2.7-code adversarial, claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: each request replaces the previous one in the dialog and is capped at 100 MB, and the sender is the hosted Apps page, not arbitrary content.

const panel = panelOf(windowKey)
if (!panel || !isOnScreen(hosted) || !isStillLoaded(hosted, sentFrom)) return false
hosted.outputs = { page: sentFrom, count: outputs.items.length }
if (comfyWindows.get(windowKey)?.window.isFocused()) panel.focus()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — comfyWindows.get(windowKey)?.window.isFocused() has no isDestroyed() guard, unlike hostOf which checks !entry.window.isDestroyed() before touching entry.window. If the window is torn down between the panelOf check and this call, isFocused() throws Object has been destroyed, which escapes showAppOutputs and rejects the page's showOutput invoke instead of resolving false as the bridge contract documents. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: panelOf already returns null for a destroyed panel, and the window cannot be destroyed between these two synchronous calls.

const host = hostOf(panel)
const hosted = host && hostedFor(host)
const shown = hosted?.outputs
if (!hosted || !shown || action.index >= shown.count || !isStillLoaded(hosted, shown.page)) return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — sendAppOutputAction checks isStillLoaded but not isOnScreen(hosted), while showAppOutputs requires both, and hosted.outputs is never cleared once set. After closeForList conceals the page with pageStillShowsApp true, hosted.loaded survives, so an action can still be delivered to a page the user can no longer see. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max edge-case, kimi-k2.7-code edge-case, claude-opus-5-thinking-max adversarial).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: while the dialog is open the app page is hidden behind a still frame, so requiring it to be on screen would drop every action. isStillLoaded keeps actions to the page that sent the outputs, and closing the app removes the dialog.

if (hosted.view.webContents !== contents) continue
const panel = panelOf(windowKey)
if (!panel || !isOnScreen(hosted) || !isStillLoaded(hosted, sentFrom)) return false
hosted.outputs = { page: sentFrom, count: outputs.items.length }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — ShownOutputs records only page and count, with no generation identifier, and is overwritten by each showOutput. If a page replaces its outputs while the dialog still displays the previous set, a click validates against the new count and the forwarded {action, index} resolves on the page against the newer set, so Download or Open workflow acts on an output the user never saw. Stamp each request with an incrementing id and include it in the action. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: a new request replaces the dialog's items as soon as it arrives, so the panel and the page use the same set; only a click in the same instant could race.

Comment thread src/main/apps/outputRequest.ts Outdated

function hasHiddenCharacters(value: string): boolean {
return (
BIDI_CONTROL.test(value) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — The hidden-character screen only catches C0 controls, DEL, and U+202A–U+202E/U+2066–U+2069. It lets through bidi marks U+200E/U+200F/U+061C, zero-width characters U+200B–U+200D and U+FEFF, U+2028/U+2029, and the C1 block U+0080–U+009F, so a page can still send a visually deceptive name that renders in Desktop's own h2 and aria-label — which the published bridge contract promises is refused. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9881948: the check now also refuses C1 controls, bidi marks (U+200E, U+200F, U+061C), zero-width characters, U+2028/U+2029 and U+FEFF, with tests.

}
justOpened = false
retrying = false
focusPage = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — focusPage is only cleared after takePlacement passes its rect.width === 0 || rect.height === 0 early return. If the host measures zero when the output dialog closes, the flag stays set and the next unrelated placement — a plain resize, say — carries focus: true and pulls the keyboard into the app page while the user is working in the panel. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: the host has its size whenever the dialog closes over it; it is zero only while the app is hidden, and the next placement is then the one that shows the app.

Comment thread src/main/apps/outputRequest.ts Outdated

function trimmed(value: unknown, max: number): string | null {
if (typeof value !== 'string' || value.trim() === '' || hasHiddenCharacters(value)) return null
return value.trim().slice(0, max)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — value.trim().slice(0, max) cuts by UTF-16 code unit, so a name or tag whose 200th (or 40th) unit falls inside a surrogate pair is truncated to a lone surrogate and renders as a replacement character in the dialog even though the input was well-formed. Slice by code points instead. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, gpt-5.6-sol-max edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: a lone surrogate only appears when a 200-character name or a 40-character tag is cut inside an emoji, which is cosmetic.

function readTags(value: unknown): string[] {
if (!Array.isArray(value)) return []
return value
.slice(0, MAX_TAGS)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — readTags slices to MAX_TAGS before mapping and filtering, so invalid tags early in the array consume the quota and valid tags later in the list are dropped. Filter first and take the first 8 valid tags to match the documented "keeps the first 8 tags" behaviour. Raised by 1 of 8 reviewers (gemini-3.1-pro edge-case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: taking the first 8 entries before checking them keeps the work bounded for a very long tag list.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant