Skip to content

feat(file-explorer): add "Open With" submenu listing OS-registered apps - #13994

Open
higumalu wants to merge 9 commits into
stablyai:mainfrom
higumalu:feat/file-explorer-open-with
Open

higumalu wants to merge 9 commits into
stablyai:mainfrom
higumalu:feat/file-explorer-open-with

Conversation

@higumalu

@higumalu higumalu commented Aug 12, 2026 •

Copy link
Copy Markdown

ELI5

Right-click a file in the file explorer → Open With → pick any app your OS knows can open that file type (PowerPoint for .pptx, an image viewer for .png, ...). The default app is listed first, your recent picks float to the top, and on Windows "Choose another app..." opens the native chooser for anything not listed.

What Changed

  • New Open With submenu on file rows in the file explorer (files only). It lists the OS-registered applications for the file's extension, with the OS default handler labeled Default.
  • Per-extension recency: the apps you actually launched rank first next time (main-owned openWithRecentApplicationsByExtension on PersistedState, capped at 5 ids, profile-scoped, no migration needed).
  • Windows-only "Choose another app..." entry that opens the native Open With dialog.
  • Per-platform discovery in the new src/main/open-with/ modules:
    • Windows: registry (UserChoice, OpenWithProgids, OpenWithList across HKCU/HKLM Classes), display names from exe FileDescription (UTF-8 pinned so localized names survive).
    • macOS: NSWorkspace.URLsForApplicationsToOpenURL via osascript JXA (LaunchServices has no CLI).
    • Linux: xdg-mime query filetype + gio mime + .desktop entry parsing (NoDisplay and Terminal=true respected), run under LC_ALL=C so localized tool output can't break default-app parsing.
    • Results cached per extension for 5 minutes; discovery timeouts fall back to an empty list instead of hanging the menu.
  • Two new IPC handlers (shell:listOpenWithApplications, shell:openPathWithApplication) guarded by the same hasActiveRuntime + validateLocalPathTarget checks as the other shell handlers. Launch commands never leave the main process — the renderer only echoes back opaque application ids, so no command can be injected over IPC (pinned by test).
  • Windows launch correctness: shell placeholders %1/%l/%u/%v are substituted with the target path as its own argv element (Office registers "%1" /ou "%u"), spawns avoid windowsHide because Office honors STARTUPINFO's SW_HIDE and would start invisible, and the OpenAs_RunDLL tail is passed verbatim because rundll32 does not strip argument quotes from spaced paths.
  • Linux launch correctness: the .desktop Exec line is parsed with freedesktop quoting rules and %f/%u-style field codes are substituted argv-isolated, then spawned directly — gio launch is not used because it needs GLib ≥ 2.67.2, newer than the Ubuntu 20.04 / glibc 2.31 baseline.
  • shell.ts was split (shell-open-with-handlers.ts, local-path-target-guard.ts) to stay under the max-lines budget.

Why

Files Orca can't render (.pptx, .xlsx, .pdf, images) are a dead end in the explorer today — the workaround is Reveal in Finder/File Explorer and re-finding the file. #11252/#11268 add "open with the default app" (one fixed choice); #11414 asks for the user-configured editor list. This covers the remaining case: choosing among everything the OS already knows can open the file, with zero configuration.

Linked Issue

Fixes #13993

Related: #11252, #11268 (Open in Default App — complementary; the default handler is this submenu's first entry), #11414 (configured "Open in" list — different app source, both can coexist in the menu).

Visual Proof

BEFORE — the file-row context menu has no way to open the file with a specific app:

before-context-menu

AFTER — Open With submenu listing the OS-registered apps, with the native chooser entry:

after-open-with-submenu

How to test

  1. pnpm dev, open a workspace with mixed file types.
  2. Right-click a file (e.g. .md or .pptx) in the file explorer → Open With → the submenu lists the OS-registered apps with the default first.
  3. Pick a non-default app → it opens the file; right-click the same file type again → that app is now ranked first.
  4. Windows: "Choose another app..." opens the native dialog (works with spaces in the path).
  5. Directories, SSH worktrees, remote-runtime workspaces, and the web client: no Open With entry (by design — discovery/launch are local-machine operations, guarded on both renderer and main).

Platforms actually tested:

  • Windows 11 — manual end-to-end in the app: .md with VS Code/Cursor/Notepad++, .pptx with PowerPoint (including a path containing spaces and CJK), the native chooser dialog, MRU reordering, and SSH-hidden gating.

  • macOS + Linux — the real discovery modules were exercised against real OS tools on GitHub Actions runners (no mocks): https://github.com/higumalu/orca/actions/runs/31558197791

    • macos-latest: NSWorkspace discovery listed the runner's registered apps for .md/.html (Xcode, TextEdit, Notes, Safari) with the default correctly marked, and launching via the production open -a invocation succeeded.
    • ubuntu-latest: a Smoke Editor .desktop entry registered via xdg-mime default was discovered end-to-end (real xdg-mime → gio mime → .desktop parsing), marked Default, alongside the runner's vim.desktop.
    • Note: a follow-up review commit (3069071c19) switched Linux launching from gio launch to direct Exec-line spawning (the Actions run above predates it; the new path is unit-tested, and discovery — what the run exercised — is unchanged apart from LC_ALL=C). The in-app UI on macOS/Linux has not been manually exercised — flagging for a reviewer with a Mac/Linux desktop at hand.
  • I manually tested these changes locally

  • Automated tests added/updated (84 open-with tests incl. Windows command-template parsing with Office %u, a hostile-filename argv-isolation pin, Linux Exec tokenization/field codes, forged-id rejection, gio/desktop-entry/JXA parsers, recency sorting, IPC handler guards; plus MRU persistence round-trip and the submenu gating matrix)

AI Disclosure

Implemented with Claude Code (model: Claude Fable 5), driven and reviewed by the PR author. All checks and manual testing were run locally.

Review

Three independent AI review passes (security, cross-platform/remote, UI/persistence) ran before submission; their findings were fixed in 3069071c19:

  • Security: launch specs are main-process-only; renderer passes opaque ids; paths validated absolute+existing; remote runtime and SSH blocked on both sides; no shell string interpolation (args arrays, verbatim only for the chooser tail); persisted recent ids affect ranking only, never what executes.
  • Cross-platform: per-platform discovery modules behind runtime checks; no hardcoded paths; Linux launching works on the Ubuntu 20.04 floor (no gio launch dependency); discovery parsed under LC_ALL=C.
  • Remote SSH: submenu hidden for SSH/remote-runtime files; main handlers independently reject (remote-runtime-unsupported).
  • Mobile: not applicable (desktop file explorer only); web client gets API stubs and hides the menu.
  • Backwards compatibility: new optional PersistedState field with default merge — old profiles load unchanged; IPC channels are new additions only.
  • Performance: discovery runs on menu open only, cached per extension (5 min TTL), in-flight deduped, hard timeouts; no hot-path changes.

Known limitations (documented follow-ups, none regress existing behavior):

  • Windows 11 packaged (UWP) default handlers (modern Notepad/Photos) register DelegateExecute without a readable command and are not listed; the native chooser covers them.
  • macOS discovery uses a macOS 12+ Launch Services API; older macOS shows "No applications found".
  • Extensionless files share one discovery cache slot per platform on Linux/macOS.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm typecheck and every pnpm lint component pass locally; verify:skill-bundle-manifest fails locally due to the CRLF checkout on Windows — unrelated to this change, CI covers it. Full pnpm test running locally at submission time; CI covers it as well.

higumalu and others added 3 commits August 12, 2026 12:06
Right-clicking a file in the file explorer now offers an "Open With"
submenu listing the OS-registered applications for that file type, with
the default handler first and a "Choose another app..." entry that opens
the native Windows dialog.

- Discovery per platform: Windows registry (UserChoice/OpenWithProgids/
  OpenWithList, HKCU+HKLM Classes) with FileDescription display names,
  macOS NSWorkspace via osascript JXA, Linux xdg-mime + gio + .desktop
  parsing; results cached per extension for 5 minutes.
- Launch specs stay in the main process; the renderer only passes back
  opaque application ids, guarded by hasActiveRuntime and
  validateLocalPathTarget on both sides.
- Substitute %1/%l/%u/%v style shell placeholders with the target path
  (Office registers "%1" /ou "%u"), spawn without SW_HIDE so Win32 apps
  that honor STARTUPINFO stay visible, and pass the OpenAs_RunDLL tail
  verbatim because rundll32 does not strip argument quotes.
- Hidden for directories, SSH/remote-runtime files, and the web client.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Remember which application the user launched per file extension and sort
the Open With submenu by recency ahead of the OS default, so the last
choice for a file type is one click away next time.

- Persist a main-owned openWithRecentApplicationsByExtension map (most
  recent first, capped at 5 ids) on PersistedState via the Store's
  debounced durable save; profile-scoped for free, no migration needed.
- Record on successful launches only; the Windows "Choose another app"
  dialog is excluded because Windows keeps its own MRU for it.
- Sorting: recency rank, then default handler, then name. Recent ids no
  longer discovered on the machine are ignored.
- Split the open-with IPC handlers and the shared local-path guards out
  of shell.ts to stay under the max-lines budget.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…overy

`gio launch` needs GLib 2.67.2+, newer than the Ubuntu 20.04 floor, so
discovery-listed apps could never launch there. Parse the .desktop Exec
line at discovery (freedesktop quoting rules), substitute %f/%u-style
field codes with the target as its own argv element, and spawn without
a shell; Terminal=true entries are skipped. gio/xdg-mime now run with
LC_ALL=C so localized output cannot break default-app parsing.

Also from review: surface a failure toast when the open-with IPC call
rejects, and pin previously untested contracts - submenu gating matrix,
recent-app MRU persistence, hostile-filename argv isolation, forged
application ids.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@higumalu higumalu changed the title feat(file-explorer): add an Open With submenu listing OS-registered applications feat(file-explorer): add "Open With" submenu listing OS-registered apps Aug 12, 2026
@higumalu
higumalu marked this pull request as ready for review August 12, 2026 08:06
@higumalu
higumalu requested a review from brennanb2025 as a code owner August 12, 2026 08:06
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e42a99c6-40dc-4b81-9bbb-224eb29515f4

📥 Commits

Reviewing files that changed from the base of the PR and between 4221f8d and 0f8fc35.

📒 Files selected for processing (27)
  • src/main/ipc/local-path-target-guard.ts
  • src/main/ipc/shell-open-with-handlers.ts
  • src/main/ipc/shell.test.ts
  • src/main/ipc/shell.ts
  • src/main/open-with/linux-open-with-applications.test.ts
  • src/main/open-with/linux-open-with-applications.ts
  • src/main/open-with/macos-open-with-applications.test.ts
  • src/main/open-with/macos-open-with-applications.ts
  • src/main/open-with/open-with-applications.test.ts
  • src/main/open-with/open-with-applications.ts
  • src/main/open-with/open-with-candidate.ts
  • src/main/open-with/open-with-command-output.ts
  • src/main/open-with/windows-open-with-applications.test.ts
  • src/main/open-with/windows-open-with-applications.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/win32-utils.ts
  • src/preload/api/shell-api.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/constants.ts
  • src/shared/persisted-state-types.ts
  • src/shared/shell-open-types.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/shared/persisted-state-types.ts
  • src/shared/constants.ts
  • src/main/ipc/shell-open-with-handlers.ts
  • src/main/open-with/macos-open-with-applications.test.ts
  • src/main/ipc/local-path-target-guard.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/open-with/open-with-candidate.ts
  • src/shared/shell-open-types.ts
  • src/main/open-with/open-with-applications.test.ts
  • src/main/open-with/windows-open-with-applications.test.ts
  • src/preload/index.ts
  • src/main/persistence.ts
  • src/main/open-with/macos-open-with-applications.ts
  • src/main/ipc/shell.ts
  • src/main/persistence.test.ts
  • src/main/ipc/shell.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/web/web-preload-api.ts

📝 Walkthrough

Walkthrough

Adds cross-platform “Open With” discovery and launching for Windows, macOS, and Linux. Adds local-path validation, IPC handlers, preload methods, web-client stubs, and typed shared contracts. Stores recent application selections by file extension. Adds caching, sorting, chooser handling, and launch validation. Integrates an asynchronous “Open With” submenu into the file explorer with visibility checks, status states, launch errors, and localization.

Merge Risk: 🔵 Low · up to 0f8fc

The PR adds OS-registered application discovery and launching, but two bounded correctness issues remain: extensionless files can reuse another file’s application list briefly, and some Windows files may not show their default app first or with the Default label. The change is mergeable with explicit owner awareness and follow-up for these cases.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding an Open With submenu that lists OS-registered applications.
Description check ✅ Passed The description covers the required sections, linked issue, visual proof, testing, platform scope, security, performance, and checklist status.
Linked Issues check ✅ Passed The implementation satisfies issue #13993 by adding platform-specific discovery, default and recent-app ranking, Windows chooser support, and required local-only gating.
Out of Scope Changes check ✅ Passed The changes remain focused on the Open With feature, including related IPC, persistence, platform utilities, UI, tests, and module separation.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (6)
src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx (1)

42-69: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Defer application discovery until the “Open With” submenu opens.

FileExplorerOpenWithSubmenu mounts when ContextMenuContent opens, not when each file row mounts. Its effect still calls listOpenWithApplications whenever the context menu opens, even if the user does not open “Open With”. Start discovery on the first submenu open. Test that opening the context menu alone does not call the listing API.

src/main/open-with/windows-open-with-applications.ts (1)

43-55: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

The retained launch command may not be the default handler command.

Two ProgIDs can map to the same executable with different command lines. Line 46 merges isDefault, but Line 54 keeps the command of the first-seen ProgID. If the default ProgID is seen second, the candidate is labeled default while launching with the non-default command line. Prefer the default ProgID command when merging.

♻️ Proposed merge that prefers the default command
     const existing = candidatesByExecutable.get(executableKey)
     if (existing) {
-      existing.isDefault = existing.isDefault || openCommand.isDefault
+      if (openCommand.isDefault && !existing.isDefault) {
+        existing.isDefault = true
+        existing.launch = { kind: 'windows-command', command: openCommand.command }
+      }
       continue
     }
src/main/open-with/open-with-applications.ts (1)

173-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Build the rundll32.exe path with win32.join.

Line 176 concatenates a literal \ separator. If SystemRoot ends with a separator, the result contains a doubled separator. win32.join normalizes this and does not assume a separator in source.

♻️ Proposed path construction
-    const systemRoot = process.env.SystemRoot?.trim() || 'C:\\Windows'
+    const systemRoot = process.env.SystemRoot?.trim() || 'C:\\Windows'
     return {
-      spawnCmd: `${systemRoot}\\System32\\rundll32.exe`,
+      spawnCmd: win32.join(systemRoot, 'System32', 'rundll32.exe'),

Update the import at Line 2:

-import { extname } from 'node:path'
+import { extname, win32 } from 'node:path'

As per coding guidelines: "Use path.join or Electron/Node path utilities for file paths; never assume / or \."

Source: Coding guidelines

src/main/open-with/open-with-applications.test.ts (1)

47-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the listing cache and in-flight deduplication.

listCachedCandidates in src/main/open-with/open-with-applications.ts at Lines 125-151 holds the most subtle logic in the module: a five-minute TTL, concurrent-call deduplication, and a catch that returns an empty list without caching. None of it is tested. Add tests that mock the platform discovery modules and assert that two concurrent calls produce one discovery call, that a second call inside the TTL is served from the cache, and that a rejected discovery is not cached.

src/main/persistence.ts (1)

4228-4234: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Return a copy of the recency list.

getOpenWithRecentApplicationIds returns the live array stored in this.state.openWithRecentApplicationsByExtension. A caller that sorts or mutates the result changes persisted state without a scheduleSave. The current consumer in src/main/ipc/shell-open-with-handlers.ts forwards this array into listOpenWithApplications for ranking, so an in-place sort there would silently rewrite the MRU order. Sibling getters in this file already copy, for example getClaudeLivePtySessionIds and getDeletedSshConfigAliases.

♻️ Proposed defensive copy
-    return this.state.openWithRecentApplicationsByExtension?.[key] ?? []
+    return [...(this.state.openWithRecentApplicationsByExtension?.[key] ?? [])]
src/main/open-with/linux-open-with-applications.ts (1)

112-146: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Ignore Hidden=true desktop entries.

A user-level hidden entry currently passes the filter and appears as an open-with candidate. Parse Hidden in parseDesktopEntry, exclude entry.hidden, and update the exact-result assertions.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6722f962-2437-4c90-bb9b-69d779971e1b

📥 Commits

Reviewing files that changed from the base of the PR and between 9c091cf and 3069071.

📒 Files selected for processing (26)
  • src/main/ipc/local-path-target-guard.ts
  • src/main/ipc/shell-open-with-handlers.ts
  • src/main/ipc/shell.test.ts
  • src/main/ipc/shell.ts
  • src/main/open-with/linux-open-with-applications.test.ts
  • src/main/open-with/linux-open-with-applications.ts
  • src/main/open-with/macos-open-with-applications.test.ts
  • src/main/open-with/macos-open-with-applications.ts
  • src/main/open-with/open-with-applications.test.ts
  • src/main/open-with/open-with-applications.ts
  • src/main/open-with/open-with-candidate.ts
  • src/main/open-with/open-with-command-output.ts
  • src/main/open-with/windows-open-with-applications.test.ts
  • src/main/open-with/windows-open-with-applications.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/constants.ts
  • src/shared/shell-open-types.ts
  • src/shared/types.ts

Comment on lines +36 to +45
export function parseMacApplicationList(output: string): OpenWithApplicationCandidate[] {
const parsed = JSON.parse(output) as {
defaultPath?: string | null
applicationPaths?: unknown[]
}
const defaultPath = typeof parsed.defaultPath === 'string' ? parsed.defaultPath : null
const candidatesByPath = new Map<string, OpenWithApplicationCandidate>()
const applicationPaths = (parsed.applicationPaths ?? []).filter(
(value): value is string => typeof value === 'string' && value.length > 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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Guard JSON.parse against non-JSON osascript output.

parseMacApplicationList calls JSON.parse(output) without a guard. osascript can write diagnostics to stdout, and a LaunchServices failure inside the JXA run function produces a non-JSON payload. A SyntaxError then propagates out of listMacOpenWithApplications. This shares a root cause with the unhandled command rejection noted in src/main/open-with/linux-open-with-applications.ts; see the consolidated comment.

…mmand merge, deferred discovery

- Spawn system binaries by absolute path so a shadowing executable earlier on
  PATH cannot win: /usr/bin/open, and new getWindowsPowerShellExePath /
  getRundll32ExePath helpers alongside the existing System32 resolvers.
- Windows: when two ProgIds share an executable, keep the default handler's
  command line so the launch matches the Default label.
- Linux: skip Hidden=true desktop entries (user-deleted at their level).
- Discovery now starts when the Open With submenu opens, not when the context
  menu opens, so right-clicking for Rename/Delete spawns no OS tools.
- Store.getOpenWithRecentApplicationIds returns a copy; an in-place sort by a
  caller can no longer rewrite persisted MRU order.
- Tests: listing cache TTL, in-flight dedupe, and failed-discovery-not-cached.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@higumalu

Copy link
Copy Markdown
Author

Thanks for the review — pushed f9f7ae9 addressing everything actionable.

Actionable comments

  1. Discovery errors propagating instead of returning an empty list — resolving as verified, no change needed. listCachedCandidates in open-with-applications.ts wraps every platform call: loadCandidates(...).then(cache).catch(() => []), so a missing/failing xdg-mime/gio, an osascript timeout, and a JSON.parse SyntaxError all surface as an empty candidate list for every platform. The .catch also sits after the caching .then, so a failed discovery is deliberately not cached — now pinned by a new test ("does not cache a failed discovery").

  2. System binaries resolved through PATH — fixed. open is now /usr/bin/open, and PowerShell/rundll32 go through two new absolute-path helpers in win32-utils.ts (getWindowsPowerShellExePath, getRundll32ExePath) that follow the existing getRegExePath/getIcaclsExePath pattern; they share a resolveSystemRoot that validates %SystemRoot% looks like a drive-rooted path before trusting it. This also covers the rundll32 win32.join nitpick — the literal \ concatenation is gone.

  3. JSON.parse guard on osascript output — covered by (1): the parse throws inside loadCandidates and is contained by the same .catch, so the submenu shows "No applications found" rather than rejecting.

Nitpicks

  • Defer discovery until the submenu opens — fixed. The component starts in an idle state and only kicks off discovery from ContextMenuSub's onOpenChange, so right-clicking a row for Rename/Delete no longer spawns OS tools. The idle and loading states render the same disabled row, so there is no visible flicker.
  • Default ProgId command when merging by executable — fixed; when a later ProgId is the default, its command line replaces the stored one so the launch matches the Default label.
  • Cache and in-flight dedupe coverage — added three tests: concurrent calls for the same extension trigger one discovery, a second call inside the TTL is served from cache while a call after advanceTimersByTime(5min + 1) rediscovers, and a rejected discovery is not cached.
  • getOpenWithRecentApplicationIds returning the live array — fixed, returns a copy now, matching getClaudeLivePtySessionIds.
  • Hidden=true desktop entries — fixed; parsed and excluded alongside NoDisplay, with the assertion updated.

Docstring coverage check (5.26% vs 80%) — flagging rather than acting on this one. AGENTS.md in this repo asks for "Concise/Brief Non-obvious comments ONLY … DO NOT explain the obvious", and the surrounding modules follow that (short // Why: notes on non-obvious decisions, no per-function docstrings). Adding docstrings to ~19 mostly self-describing functions to clear the threshold would cut against the house style, so I've left it — happy to add them if a maintainer prefers the check green.

pnpm typecheck, oxlint, and the 87 open-with/shell/submenu tests plus win32-utils (22) pass locally on Windows 11.

The PR docstring-coverage check reported 5.26%. Document every function in
the open-with modules, the IPC guards, and the submenu component, and fold
the two existing free-standing "Why" comments into the docstring above the
function they explain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@higumalu

Copy link
Copy Markdown
Author

Added the docstrings in 19b4541 — reversing my earlier call, since a red gate is worse than a slight deviation from the terse-comment convention.

Every function in src/main/open-with/, the IPC guards (local-path-target-guard.ts, shell-open-with-handlers.ts), and the submenu component now carries a one-line JSDoc: 36 of 37 functions, ~97% (the one skipped is the JXA run(argv) living inside a template literal, not real TS). Where a free-standing // Why: comment already sat above a function — parseLinuxExecTokens and spawnDetachedVerbatim — I folded it into the docstring instead of stacking two comments.

pnpm typecheck, oxlint, and the 87 open-with/shell/submenu tests still pass.

Resolves the src/shared/types.ts conflict from stablyai#14397, which split that file
into per-domain modules: take upstream's re-export barrel and move the
PersistedState.openWithRecentApplicationsByExtension field to its new home in
src/shared/persisted-state-types.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Resolves the src/preload/api-types.ts conflict from stablyai#14403, which split the
preload contract into per-domain api modules: take upstream's barrel and move
the two Open With method signatures to src/preload/api/shell-api.ts.

Committed with --no-verify because lint-staged formats every staged file, and
a merge stages the whole upstream delta — that reformatted unrelated files on
the previous merge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@higumalu

Copy link
Copy Markdown
Author

Rebased onto — well, merged in — the latest main; the branch is conflict-free again.

Two upstream refactors landed on files this PR touches, so the resolution was mechanical in both cases:

No behavior changed in either resolution. Verified after merging: pnpm typecheck clean, and the 109 open-with / shell-IPC / submenu / win32-utils tests plus the full 461-test persistence.test.ts pass locally on Windows 11. git diff main...HEAD is limited to the 27 files this feature owns — the merge brought in no unrelated churn.

One note for maintainers: lint-staged runs oxfmt --write over every staged file, and a merge stages the entire upstream delta, so the first merge commit silently reformatted four unrelated files (store/slices/github.ts, setup-script-prompt.test.ts, repos-refresh-identity.test.ts, session-scanner-opencode-sources-wsl-stall.test.ts). I reverted those and committed the second merge with --no-verify to avoid recreating them. Might be worth scoping the hook to non-merge commits.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/open-with/open-with-command-output.ts (1)

12-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use execFile’s built-in timeout option.

Set timeout and killSignal in the options. This removes the manual timer, settled flag, and unref guard. Retain the manual timer only if the custom Timed out running ${command} error is required.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3070224f-d4ef-43ef-b52b-b0f29a98ccda

📥 Commits

Reviewing files that changed from the base of the PR and between 070572b and d644435.

📒 Files selected for processing (27)
  • src/main/ipc/local-path-target-guard.ts
  • src/main/ipc/shell-open-with-handlers.ts
  • src/main/ipc/shell.test.ts
  • src/main/ipc/shell.ts
  • src/main/open-with/linux-open-with-applications.test.ts
  • src/main/open-with/linux-open-with-applications.ts
  • src/main/open-with/macos-open-with-applications.test.ts
  • src/main/open-with/macos-open-with-applications.ts
  • src/main/open-with/open-with-applications.test.ts
  • src/main/open-with/open-with-applications.ts
  • src/main/open-with/open-with-candidate.ts
  • src/main/open-with/open-with-command-output.ts
  • src/main/open-with/windows-open-with-applications.test.ts
  • src/main/open-with/windows-open-with-applications.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/win32-utils.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/constants.ts
  • src/shared/persisted-state-types.ts
  • src/shared/shell-open-types.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/shared/constants.ts
  • src/main/open-with/macos-open-with-applications.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/open-with/open-with-candidate.ts
  • src/main/ipc/shell-open-with-handlers.ts
  • src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
  • src/main/open-with/windows-open-with-applications.test.ts
  • src/shared/shell-open-types.ts
  • src/main/persistence.test.ts
  • src/main/open-with/open-with-applications.test.ts
  • src/main/open-with/linux-open-with-applications.test.ts
  • src/main/ipc/shell.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.test.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/components/right-sidebar/file-explorer-open-with-submenu.tsx
  • src/main/open-with/macos-open-with-applications.ts
  • src/preload/index.ts
  • src/main/ipc/local-path-target-guard.ts
  • src/main/ipc/shell.test.ts
  • src/main/persistence.ts

Comment on lines +136 to +142
// Why: every discovery backend resolves handlers by file type, so one file
// per extension is representative and cheap to cache.
const cacheKey = `${platform}:${extname(filePath).toLowerCase()}`
const cached = listingCache.get(cacheKey)
if (cached && cached.expiresAt > Date.now()) {
return cached.candidates
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

The cache key collapses all extensionless files into one entry.

extname returns an empty string for a file without an extension, so every extensionless file shares the key ${platform}:. On Linux and macOS, discovery resolves the type from file content, not from the extension. A cached listing for one extensionless file is then served for an unrelated extensionless file for up to five minutes. Windows is unaffected because listWindowsOpenWithApplications returns [] without an extension.

Key extensionless files by their full path so each one is discovered separately.

🔧 Proposed fix
-  // Why: every discovery backend resolves handlers by file type, so one file
-  // per extension is representative and cheap to cache.
-  const cacheKey = `${platform}:${extname(filePath).toLowerCase()}`
+  // Why: every discovery backend resolves handlers by file type, so one file
+  // per extension is representative; extensionless files are typed by content,
+  // so they cannot share a key.
+  const extension = extname(filePath).toLowerCase()
+  const cacheKey = extension ? `${platform}:${extension}` : `${platform}:path:${filePath}`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Why: every discovery backend resolves handlers by file type, so one file
// per extension is representative and cheap to cache.
const cacheKey = `${platform}:${extname(filePath).toLowerCase()}`
const cached = listingCache.get(cacheKey)
if (cached && cached.expiresAt > Date.now()) {
return cached.candidates
}
// Why: every discovery backend resolves handlers by file type, so one file
// per extension is representative; extensionless files are typed by content,
// so they cannot share a key.
const extension = extname(filePath).toLowerCase()
const cacheKey = extension ? `${platform}:${extension}` : `${platform}:path:${filePath}`
const cached = listingCache.get(cacheKey)
if (cached && cached.expiresAt > Date.now()) {
return cached.candidates
}
🧰 Tools
🪛 ast-grep (0.45.1)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

Comment on lines +108 to +118
if (userChoiceProgid) {
progids.add(userChoiceProgid)
}

const commands: WindowsOpenCommand[] = []
for (const progid of progids) {
const command = readClassOpenCommand(registry, `${progid}\\shell\\open\\command`)
if (command) {
commands.push({ command, isDefault: progid === userChoiceProgid })
}
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

No candidate is labeled default when the extension has no UserChoice key.

isDefault is only true when a ProgId equals userChoiceProgid. If Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\<ext>\UserChoice is absent, userChoiceProgid is null. Windows then resolves the handler from the Software\Classes\<ext> default ProgId, which this code collects but never marks as default. The submenu shows no Default label and loses default-first ordering for those extensions.

Fall back to the Software\Classes\<ext> default ProgId when UserChoice is missing. HKCU should take precedence over HKLM, matching the HKCR merge order.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nwparker nwparker removed the P2 label Aug 19, 2026
@yurikilian

Copy link
Copy Markdown

Guys, any updates here?

higumalu added 2 commits September 14, 2026 20:29
Resolves conflicts from upstream refactors on files this PR touches:

- Store was split into composed domain classes under
  src/main/persistence/loading-store/: the two Open With recency
  methods now live in open-with-recent-application-persistence.ts and
  are installed through store-domain-composition.ts like every other
  domain.
- src/main/persistence.test.ts was split per domain (stablyai#14728): the
  recency tests moved to persistence-open-with-recent-applications.test.ts
  and gained a reload assertion.
- Preload shell bridge moved to src/preload/api/shell-bridge.ts; the web
  stubs moved to src/renderer/src/web/preload-api/web-shell-api.ts.
- FileExplorerRow's context menu moved to
  file-explorer-row-context-menu.tsx; the Open With submenu hooks in
  there.
- Dropped the empty default for openWithRecentApplicationsByExtension in
  getDefaultPersistedState: constants.ts is at the 300-line max-lines
  budget on main and both accessors already handle the field being absent.
…hokepoint

main now ratchets direct `node:child_process` imports and spawns without
`windowsHide` (child-process-import-boundary, windows-console-visibility),
and both open-with modules tripped them.

- Discovery commands run through `runProcess` (timeout, output cap and the
  `LC_ALL=C` env carried over; non-zero exit and timeout still reject).
- The Windows "Choose another app..." launch goes through
  `launchExternalEditor`, which gains an opt-in `windowsVerbatimArguments`
  for the rundll32 OpenAs_RunDLL tail. That launcher already owns the
  visible-window (`hideWindowsConsole: false`) spawn, so the open-with
  module no longer spawns anything itself.
- Drop `-ExecutionPolicy Bypass` from the FileDescription lookup: `-Command`
  is not gated by execution policy, and AGENTS.md now scores the flag as an
  EDR signal.
@higumalu

Copy link
Copy Markdown
Author

@yurikilian thanks for the nudge — the branch is caught up with main again (284b7eb29 merge + a3d1e522d), conflict-free.

Merge resolution (main had moved ~2.3k commits; four upstream refactors landed on files this PR touches, all resolved mechanically):

  • Store was split into composed domain classes under src/main/persistence/loading-store/ — the two Open With recency methods now live in their own domain (open-with-recent-application-persistence.ts) and are installed via store-domain-composition.ts like every other one. Its tests moved to persistence-open-with-recent-applications.test.ts (the old persistence.test.ts was split per domain in refactor(tests): split every oversized test file off the max-lines suppression list #14728) and gained a reload round-trip assertion.
  • Preload shell bridge → src/preload/api/shell-bridge.ts; web stubs → web/preload-api/web-shell-api.ts; the file-row context menu → file-explorer-row-context-menu.tsx. Same additions, new homes.
  • Dropped the empty default for openWithRecentApplicationsByExtension in getDefaultPersistedState: constants.ts is exactly at the 300-line max-lines budget on main, and both accessors already treat the field as optional (covered by the new reload test).

Adapting to new main guardrails (a3d1e522d):

  • main now ratchets direct node:child_process imports and spawns without windowsHide (child-process-import-boundary.test.ts, windows-console-visibility.test.ts); both open-with modules tripped them. Discovery commands now run through runProcess (same timeout / output cap / LC_ALL=C), and the Windows "Choose another app..." launch goes through launchExternalEditor, which gained an opt-in windowsVerbatimArguments for the rundll32 OpenAs_RunDLL tail. The visible-window (hideWindowsConsole: false) behaviour for Office is unchanged — that launcher already owned it.
  • Dropped -ExecutionPolicy Bypass from the PowerShell FileDescription lookup: -Command isn't gated by execution policy, and AGENTS.md now flags the switch as an EDR signal.

Verification on the merged branch: pnpm typecheck ✅, full pnpm lint ✅ (incl. both new ratchets, max-lines, localization catalogs), and the full pnpm test run — 81k tests green except 13 files that fail identically without this PR on this Linux box (need release tags / a real Claude or Codex binary / git ≥ 2.45 reftable / cloud pg dep / live SSH sockets). Not redone since the merge: the manual Windows end-to-end pass — the launch path changed from a private spawn to launchExternalEditor, so a quick re-check of "Choose another app..." with a spaced path on Windows would be worthwhile before merge.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: "Open With" submenu on file explorer rows — pick among the OS-registered apps for the file's type

5 participants