Skip to content

feat(apps): show where an app result is saved, and open it from there - #2157

Open
PabloWiedemann wants to merge 10 commits into
PabloWiedemann/apps-output-dialogfrom
PabloWiedemann/apps-result-saved-in
Open

PabloWiedemann wants to merge 10 commits into
PabloWiedemann/apps-output-dialogfrom
PabloWiedemann/apps-result-saved-in

Conversation

@PabloWiedemann

@PabloWiedemann PabloWiedemann commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: The output dialog says where an app result is saved. A result on this computer gets Show in Finder. A Comfy Cloud result gets View in Assets.

Why: after an app runs, people need a way to the file: Finder or Explorer for a local run, and the Assets page for a Cloud run.

Can affect: the app page bridge, outputRequest.ts, the output dialog, and how the panel moves from Apps to Assets.

Stacked on #2156. Replaces #2023 and #2050, rebuilt on main.

Changes

  • savedOn: 'cloud': "Saved in Comfy Cloud assets" and View in Assets. It opens Assets on Comfy Cloud with the newest file of that name open, for this visit only. When no Cloud file has that name, Assets shows a short note. When signed out or the workspace has no Cloud build, Assets shows its usual empty state and drops the request.
  • savedOn: 'computer' with comfyFile: main finds the real file in the output folder of the build the page runs on. It uses it only when the real path is inside that build's folder and inside the allowed output folders, and only when it has exactly the bytes the page sent. Show in Finder reveals it from main and checks the path again on click.
  • savedOn: 'computer' with only folder: shows that folder, and Show in folder goes back to the page.
  • Input checks: folder must be absolute with no hidden characters. comfyFile must be type: 'output' with a filename and subfolder of at most 1024 characters in all. Containment is the real guard; tests cover .. climbs, absolute file names and links out of the folder. Only the newest request from a page is shown.
  • Left out from feat(apps): Show in Finder for app results made on this computer #2050: the byte scan of the whole output folder for results with no comfyFile.

Size

About 330 non-test lines added.

Checks

  • typecheck, lint, format and the full Vitest suite pass (9347 tests).
  • Not checked in a running app with a real app page.

Each item an app page sends to window.comfyDesktopOutputs.showOutput may
now say where it is saved, with the shapes the website pages already send:

- savedOn: 'cloud' shows "Saved in Comfy Cloud assets" and View in
  Assets. View in Assets closes the app and opens the Assets page on Comfy
  Cloud with the newest Cloud file of that name open. It does this for
  this visit only: the saved Comfy Cloud | This computer choice
  (comfy.desktop.assets.place) is kept, and the file is opened once.
  The page sends no Cloud asset id, so the file is matched by name. When
  no Cloud file has that name, the Assets page says so in a short note
  instead of opening nothing.
- savedOn: 'computer' with folder (an absolute path, display only) shows
  "Saved in" with Show in folder, which goes back to the page as a new
  show-in-folder output action.
- savedOn: 'computer' with comfyFile ({ filename, subfolder, type:
  'output' }) lets Desktop find the real file ComfyUI saved. Main joins it
  to the output folder of the build the page runs on, resolves links, and
  uses it only when the file is inside that build's folder and inside the
  output folders Assets may show, and has exactly the bytes the page sent.
  The dialog then shows that folder, and Show in folder reveals the file
  from main (checked again on click) instead of going to the page. A
  page-sent folder is never shown for an item with a comfyFile.

Main drops a folder that is not absolute or has hidden characters, and a
comfyFile whose filename has a separator, . or .., or hidden characters,
or whose subfolder is absolute or has .., . or empty parts. Only the
newest showOutput request from a page is shown, so a slow file lookup
cannot replace a newer one.

The "Saved in" section and Show in folder button are the ones the Assets
folders view added to the output dialog. The output action listener moved
to registerAppsOutputsHandlers next to showOutput.

This rebuilds #2023 and #2050 on main's Apps page. Left out from #2050:
the byte scan of the whole output folder for results with no comfyFile,
and the per-preview turn on output actions.
@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: 7f40285c-0c4e-41ba-81ee-b52bac0bf52f

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

…g' into PabloWiedemann/apps-result-saved-in

# Conflicts:
#	src/renderer/src/panel/AssetsView.vue
…g' into PabloWiedemann/apps-result-saved-in

# Conflicts:
#	src/main/lib/ipc/registerAppsOutputsHandlers.test.ts
#	src/main/lib/ipc/registerAppsOutputsHandlers.ts
…r lookup

The lookup already resolves the path, refuses anything outside the build's
output folder and needs the exact bytes, so the request only checks the
shape of comfyFile. Read the output action inline as before.
…g' into PabloWiedemann/apps-result-saved-in

# Conflicts:
#	src/main/apps/outputRequest.ts
#	src/types/comfyDesktopBridge.ts
When the user is signed out or the workspace has no Comfy Cloud build,
the page shows that empty state and no longer opens the file later.
@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 2
🟡 Medium 6
🟢 Low 2

Panel: 7/8 reviewers contributed findings.

Reviewers that did not contribute: kimi-k2.7-code:adversarial (error)

const stat = await fsp.stat(file).catch(() => null)
if (!stat?.isFile() || stat.size !== bytes.byteLength) return false
const handle = await fsp.open(file, READ_WITHOUT_FOLLOWING).catch(() => null)
if (!handle) return 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.

🟠 High — hasSameBytes checks stat.size and then calls handle.readFile() with no length cap, so the size bound is only advisory: a file that grows or is replaced between the stat and the read is slurped into the main process in full, bypassing the 100 MB MAX_OUTPUTS_BYTES budget and risking an OOM or a long main-process stall. Read at most bytes.byteLength into a fixed buffer (e.g. handle.read into a preallocated buffer, or chunked compare) and verify no extra bytes remain. Raised by 4 of 8 reviewers (gpt-5.6-sol-max adversarial, gemini-3.1-pro adversarial, gemini-3.1-pro 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.

Fixed in 6ec45b0: the compare now reads at most the output's size plus one byte into a fixed buffer, so a file that grew after stat is refused without being read in full.

Comment thread src/main/apps/outputFiles.ts Outdated
request: OutputRequest,
find: FindOutputFile
): Promise<LocatedOutputs> {
const files = await Promise.all(

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 — locateOutputFiles fans out an unbounded Promise.all over up to MAX_OUTPUTS (40) items, each of which reads a whole file into memory, and the isLatest() turn check in showOutputFromAppsPage only discards work after every read completes. A hosted page can issue overlapping apps-outputs:show calls with ~100 MB payloads and pin a multiple of that in the main process. Bound this with the same runPool(..., STATS_AT_ONCE) pattern used elsewhere in outputFolders.ts, and check isLatest() before starting the reads. Raised by 2 of 8 reviewers (gpt-5.6-sol-max adversarial, 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.

Fixed in db50f81: the lookups run at most four at a time through runPool, with a test. Each read is also capped at the output's size by 6ec45b0, so a request never reads more than the bytes it sent.

if (!action) return
const file =
action.action === 'show-in-folder' ? shownOutputFile(event.sender, action.index) : null
if (file) void revealOutputFile(file).catch(() => 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.

🟡 Medium — The boolean from revealOutputFile(file) is discarded, so when the file has been moved, deleted, or its root has dropped out of the 5-second allowedRoots cache, the user's Show in folder click silently does nothing and never falls back to sendAppOutputAction. Await the result and forward the action to the page when it resolves false. Raised by 4 of 8 reviewers (gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case, claude-opus-5-thinking-max edge-case, kimi-k2.7-code 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: allowedPath refreshes the roots when they are older than 5 seconds, so a false result means the file is gone and there is nothing to show; the contract says Desktop handles found files itself.


async function loadAssets(userAsked = false): Promise<void> {
const current = ++requestId
const settled = cloudSettled.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 — loadAssets snapshots settled = cloudSettled.value before awaiting but passes it to openPendingFocus after, while the cloudSettled watcher skips whenever loading is true. If auth settles during an in-flight load and cloudListable is false, neither path clears pendingFocus, so no "not found" note appears and the asset pops open unexpectedly on a later load after sign-in — the exact behaviour the "the file is not opened later" assertions guard. Read cloudSettled.value at call time instead of snapshotting. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max 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: reading the value at call time drops the target during startup while the dashboard workspace is still resolving, which a test covers. The remaining case needs auth to settle signed-out during that same load, and the signed-out empty state still shows then.

const detailKey = ref<string | null>(null)

function newestNamed(name: string): GalleryAsset | null {
return visibleAssets.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 — newestNamed searches visibleAssets, which is already narrowed by kindFilter (persisted in localStorage) and searchQuery. A user who previously filtered to another kind, or who typed in the search box before the focus resolved, gets the "Couldn't find X" note for an asset that is present. Match against assets.value instead. 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: the type filter and search are not saved, and the page mounts fresh with All and no search for each View in Assets. The viewer can also only open a card that is on the page.

}

export function shownOutputFile(panel: WebContents, index: number): string | null {
return shownOutputsOf(panel)?.shown.files[index] ?? null

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 — shownOutputFile indexes shown.files[index] without the index >= shown.count bound that sendAppOutputAction applies two lines below. showAppOutputs takes files as an independent parameter defaulting to [], so nothing guarantees files.length === count; a longer array would let a panel click reveal a file outside the shown set. Apply the same bound check in shownOutputFile. Raised by 1 of 8 reviewers (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: files is built from the same items that set count, so its length always equals count.

const dir = outputDirFor(inst, sharedOutputDir())
const root = dir ? await realDir(dir) : null
if (!root) return null
const real = await allowedPath(path.join(root, file.subfolder, file.filename))

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 — comfyOutputPath validates containment on the resolved path and then reopens by pathname inside hasSameBytes. O_NOFOLLOW only guards the final component, so a parent directory swapped for a symlink between allowedPath and the open yields a read outside the output root; on Windows O_NOFOLLOW/O_NONBLOCK are undefined and the ?? 0 fallback silently drops even that final-component protection. Opening the resolved path with a directory handle (or re-verifying containment via handle.stat ino/dev against the realpath) would close the window. Raised by 2 of 8 reviewers (gpt-5.6-sol-max adversarial, 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: this needs another process to swap folders inside the user's own output folder during the check, and the result is only a byte compare against bytes the page already sent.

function viewInAssets(index: number): void {
const name = outputs.value?.[index]?.name
releaseOutputs()
if (name) emit('view-in-assets', name)

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 — viewInAssets emits outputs.value[index].name, which readOutputRequest's trimmed() already whitespace-stripped and sliced to MAX_NAME_LENGTH (200), while newestNamed in AssetsView matches on exact string equality against the real Cloud asset name. Any output whose name exceeds 200 characters or had surrounding whitespace can never match and always falls through to the "not found" note. 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: Cloud asset names over 200 characters or with spaces at the ends are rare, and the note then says the file was not found.

if (!outputs) throw new Error('Desktop cannot show these outputs.')
return showAppOutputs(event.sender, sentFrom, outputs)
const isLatest = takeTurn(event.sender)
const located = await locateOutputFiles(outputs, await findInPageBuild(event.sender))

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 — await findInPageBuild(event.sender) is unguarded, so a rejection from installations.get escapes the ipcMain.handle callback and Electron serializes the main-process error message and stack back to the hosted page — where the bridge contract says a rejection means "Desktop cannot show these outputs." locateOutputFiles already wraps each find in .catch(() => null); do the same here and resolve false. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k2.7-code 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 db50f81: a failed build lookup now finds no file, so the request still shows without a folder, with a test.

if (place.value !== 'cloud' || failed.value || !cloudListable.value) return
const asset = newestNamed(name)
if (asset) openDetail(asset)
else notFoundName.value = name

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 — notFoundName is cleared only by choosePlace, so a successful openPendingFocus leaves any earlier "Couldn't find X" note rendered above a gallery that now contains the file, and it also survives a refresh() or workspace switch that loads the asset. Clear notFoundName on the success branch and when a new focus arrives. 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: the page mounts fresh for each View in Assets, and the note belongs to that request; it clears when the user picks a place.

…g' into PabloWiedemann/apps-result-saved-in

# Conflicts:
#	src/main/apps/outputRequest.ts
#	src/types/comfyDesktopBridge.ts

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