Repository navigation
feat(app): open Markdown files from the OS in the floating workspace - #17906
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed all 19 files end-to-end — the packaging config, hand-written NSIS installer hooks, main-process intake/buffer, renderer bridge, and their tests.
- Per-platform association declarations — macOS uses
CFBundleDocumentTypeswithrank: Alternateso Orca joins "Open With" without owning the default; Linux reusestext/markdownviamimeTypes; Windows registers an additive ProgID +OpenWithProgids+SupportedTypesthat never writes the.mddefault value. - Main-process intake and buffering —
OsOpenedMarkdownFileStatecaptures absolute markdown paths from argv, macOSopen-file, and second-instance forwarding, decodesfile://URIs, dedupes, and caps at 32 entries with push/pull delivery. - Renderer delivery — a new bridge drains pending paths on mount, opens each document in the floating workspace, and enables/reveals the workspace; the open logic is extracted from the native picker action and shared.
- Regression guards — tests pin that
fileAssociationsstays mac-scoped (so NSIS never emits the default-handler takeover), that the daemon sweep survives the include rename, and that argv is captured before the serve early return.
I verified the Windows registry writes against app-builder-lib's own FileAssociation.nsh (the additive WriteRegNone ... OpenWithProgids pattern matches its line 67 exactly, while the takeover WriteRegStr ... "" the PR avoids is line 66), and the Linux %U Exec claim against LinuxTargetHelper.computeDesktopEntry.
ℹ️ Windows installer run not yet verified
The one gap I could not close from a static review is the real Windows install/uninstall/update cycle, which the PR itself flags. The hooks are syntax- and content-checked and read correctly against app-builder-lib templates, so I have no specific defect to report — only the absence of an end-to-end installer run, worth doing once on a Windows VM before merging given the include rename.
Technical details
# Verify the NSIS hooks against a real Windows install
## Affected sites
- config/nsis/orca-installer-hooks.nsh — customInstall/customUnInstall markdown registration + relocated-daemon sweep
## Verified statically (no action needed)
- customInstall is inserted unconditionally (installSection.nsh:82); customUnInstall runs in uninstaller.nsh:157.
- $appExe, SHELL_CONTEXT, APP_EXECUTABLE_FILENAME are all defined in app-builder-lib templates.
- The additive OpenWithProgids write matches app-builder-lib's FileAssociation.nsh:67.
## Required outcome
- One manual pass on Windows: fresh install, then "Open with" listing, uninstall leaves the user's prior .md default intact, and an update keeps terminals alive (daemon sweep guarded by ${isUpdated}).DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior Pullfrog review: the merge of the refactored main startup pipeline (0332426 is comment-only) and how this PR's feature was adapted to it.
- Merged
origin/main's startup refactor —mainProcessStateextraction,runMainProcessPreflight,registerMainProcessIpcHandlers— and re-rooted the feature onto it:osOpenedMarkdownFilesnow lives inmainProcessState,publishOsOpenedMarkdownFilesreadsstate.mainWindow, and theui:consumePendingMarkdownFileOpenshandler moved intoregisterMainProcessIpcHandlers(). - Gated the macOS
open-file/open-urlhandlers and the cold-startcapture(process.argv)behindif (preflightReady), matching main's "transient second instance never touches userData" contract; the capture-before-shouldActivateDesktopForSecondInstanceordering is preserved and still pinned by test. - Migrated the preload surface (
onOpenMarkdownFiles,consumePendingMarkdownFileOpens) into the splitui-bridge-part-1.tsalongside the neighbouring skill-share/settings channels. - Updated
os-opened-markdown-wiring.test.tsto pin the new call sites acrossindex.ts,main-process-ipc-bootstrap.ts, andmain-process-preflight.ts.
All four feature test suites pass (45 tests) against the merged tree.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (24)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (19)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change adds Markdown file associations for macOS, Linux, and Windows. The main process captures and buffers Markdown paths opened by the operating system, resolves valid files, and delivers documents through IPC. The preload and web APIs expose listener and pending-file methods. The renderer opens received documents in the floating workspace and reports failures. Tests cover association configuration, path parsing, delivery ownership, IPC wiring, and renderer behavior. Merge Risk: 🟡 Moderate · up to OS-opened Markdown files can be lost during renderer reload because the readiness latch is cleared too late, so the PR is not merge-ready until that race is fixed or explicitly accepted. The new automatic authorization of OS-supplied local files also warrants owner awareness. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed context, implementation scope, linked issue, risks, testing results, and known verification gaps. However, it omits several required template sections, including Visual Proof, the checklist, and explicit Review, Notes, and Agent skill upstream boundary sections. Full details: Linked Issues checkExplanation The implementation satisfies the coding objectives in [ Full details: Out of Scope Changes checkExplanation The changes are focused on [ Full details: Docstring CoverageExplanation Docstring coverage is 38.10% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 22 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 91d003a3-653e-4839-b7fd-5697c2f8df16
📒 Files selected for processing (21)
config/electron-builder.config.cjsconfig/nsis/daemon-host-uninstall.nshconfig/nsis/orca-installer-hooks.nshconfig/scripts/electron-builder-markdown-associations.test.mjssrc/main/daemon/daemon-host-relocation.tssrc/main/index.tssrc/main/startup/main-process-ipc-bootstrap.tssrc/main/startup/main-process-state.tssrc/main/startup/os-opened-markdown-files.test.tssrc/main/startup/os-opened-markdown-files.tssrc/main/startup/os-opened-markdown-wiring.test.tssrc/preload/api/ui-bridge-part-1.tssrc/preload/api/ui-command-event-api.tssrc/renderer/src/components/floating-terminal/use-floating-terminal-create-actions.tssrc/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.tssrc/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.test.tssrc/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/open-markdown-in-floating-workspace.test.tssrc/renderer/src/lib/open-markdown-in-floating-workspace.tssrc/renderer/src/web/preload-api/web-ui-api.ts
💤 Files with no reviewable changes (1)
- config/nsis/daemon-host-uninstall.nsh
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Registers Orca as a Markdown handler on macOS, Windows and Linux, and opens an OS-handed .md/.markdown/.mdx file as a floating-workspace editor tab — the one editor surface that needs no project. Works cold-start and when Orca is already running. Main buffers the paths and both pushes to a live renderer and answers a pull on renderer mount, mirroring SkillShareDeepLinkState. The buffer is only released once delivery is possible: the renderer's pull is what proves its ui:openMarkdownFiles listener is attached, because a push into a window whose renderer has not subscribed is dropped by Electron with no error. Both the push and the pull restore an undelivered batch, and a renderer reload clears the latch so the fresh renderer re-proves itself. Paths are stat'd and proven to be files before authorizeExternalPath sees them. Windows association is registered by hand in the NSIS include rather than through electron-builder's `fileAssociations`: app-builder-lib emits APP_ASSOCIATE, whose first line overwrites Software\Classes\.md's default value with no backup — silently taking .md from whichever editor owns it, for every existing user on their next update — and APP_UNASSOCIATE never restores it. The hand-rolled registration is additive (ProgID + OpenWithProgids + SupportedTypes) and leaves the user's default alone; verified end to end on a real Windows 11 host. Co-authored-by: Wooseong Kim <[email protected]> Co-authored-by: Jaydev <[email protected]> Closes #10138
9b252c5 to
3fbbfc2
Compare
Addressing the CodeRabbit reviewBoth findings were real. I had reasoned that "a window exists" was sufficient proof a push would land; it isn't. 1. Pull path lost the batch on resolution failure. ipcMain.handle('ui:consumePendingMarkdownFileOpens', async () => {
state.markdownFileOpenListenerReady = true
const filePaths = state.osOpenedMarkdownFiles.consume()
try {
return await resolveOpenedMarkdownDocuments(filePaths)
} catch (error) {
state.osOpenedMarkdownFiles.restore(filePaths)
throw error
}
})2. Push into a window whose renderer hadn't subscribed. The worse of the two. Between Fixed by making the renderer's own pull the proof that the listener is live, rather than inferring it from window existence:
Regression coverage in On the reorder/duplicate note in the summary: On the two pre-merge check warningsDocstring coverage (40%) — not acting on this. The functions it counts are mostly 3-line test helpers and arrow callbacks; the exported surface ( Visual Proof — no packaged build exists for this branch, and the OS association only takes effect once installed, so I can't produce a genuine Finder/Explorer screenshot without shipping an artifact. What I do have is the real-hardware registry evidence in the description, which is the load-bearing claim for this change. Flagging it rather than quietly skipping it. Also rebasedThe branch was ~63 commits behind and conflicting. |
…rd a non-array payload CI caught two things the local run did not. useIpcEvents-lifecycle.test.ts is an inventory of every App-lifetime IPC listener and the exact order they register in; ui.onOpenMarkdownFiles now appears there, positioned after the workspace-shortcut bridge's last listener, which is where it actually registers. Chasing that failure surfaced a real gap: the pending-open payload crosses the preload boundary, so a stale or mismatched preload can resolve with something that is not an array, and reading .length off it threw inside the promise chain instead of failing at the boundary. Array.isArray now gates it, with a regression test.
|
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. |
There was a problem hiding this comment.
Important
The listener-ready latch is cleared at the wrong lifecycle point, which can silently drop OS-opened Markdown files during — and after — a reload.
Reviewed changes
Reviewed the delta since the prior Pullfrog review at 9b252c5: a renderer-listener-ready latch plus hardened push/pull delivery ownership.
- Listener-ready latch —
markdownFileOpenListenerReadyinmainProcessStategatespublishOsOpenedMarkdownFiles, so main only pushes buffered paths once the renderer has proven itsui:openMarkdownFileslistener is live via its mount-time pull (ui:consumePendingMarkdownFileOpens). - Pull-path hardening — the pull handler now sets the latch, and restores the consumed batch if
resolveOpenedMarkdownDocumentsrejects, so an undelivered batch survives to the next mount. - Reload re-arm —
did-finish-loadinmain-window-controller.tsresets the latch tofalse, on the theory that a reload drops the listener and the fresh renderer re-proves itself by pulling. - Delivery ownership tests — new
os-opened-markdown-delivery.test.tscovers keep-on-reject, hold-while-not-attached, and restore-after-consumed, plus wiring assertions for the latch and both restore paths.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| logStartupMilestone('did-finish-load') | ||
| // Why cleared here: a reload drops the old ui:openMarkdownFiles listener, and the fresh | ||
| // renderer re-attaches by pulling. Pushing into the gap between would be silently lost. | ||
| state.markdownFileOpenListenerReady = false |
There was a problem hiding this comment.
The latch is cleared at the wrong lifecycle point. did-finish-load fires at the end of a load, so during a reload the latch stays true (from before the reload) the whole time the document is reloading, and a publishOsOpenedMarkdownFiles push in that window consumes the batch and webContents.sends into a document with no listener — and because the window is not isDestroyed(), the .then branch never restore()s it. On initial load the same handler also fires: if did-finish-load lands after the mount-time pull (which sets the latch, since the load event and React's post-paint passive effects are not strictly ordered), the latch ends false while the listener is live, and every subsequent warm "Open With" is silently buffered forever — the renderer pulls exactly once per document lifetime.
Technical details
# Clear the listener-ready latch at reload start, not load finish
## Affected sites
- src/main/startup/main-window-controller.ts:150 — `state.markdownFileOpenListenerReady = false` runs on `did-finish-load`, after the fresh document has already loaded.
- src/main/index.ts:47 — `publishOsOpenedMarkdownFiles` trusts the latch and never restores on the non-destroyed-but-no-listener path.
## Required outcome
- The latch is `false` for the entire reload window (reload start -> fresh pull), so a push during that window is buffered, not consumed and sent into a document with no listener. It is also not reset by the initial load's `did-finish-load` unless that fires before the mount-time pull.
## Suggested approach
- Reset the latch when the reload *starts* rather than when it finishes: clear it in the `onBeforeReload` / `onBeforeRecoveryReload` callbacks already wired in this controller, or on `did-start-navigation` (main-frame, non-same-document) — the convention `src/main/ipc/pty/delivery/lifecycle-reset.ts` already uses for exactly this teardown window.
- For the initial load, avoid clearing a latch the pull may already have set — keying the reset to navigation start makes `did-finish-load` unnecessary for the initial load entirely.There was a problem hiding this comment.
ℹ️ No new issues in this delta.
Reviewed changes
Reviewed the delta since the prior Pullfrog review at 3fbbfc2: a non-array payload guard plus the missing IPC-inventory registration.
- Non-array payload guard —
openOsRequestedMarkdownFilesnow bails on!Array.isArray(documents), so a stale or partial preload resolvingnull(the same shape the web client'sconsumePendingSkillSharestub returns) can no longer throw inside the promise chain. - IPC inventory registration —
useIpcEvents-lifecycle.test.tsnow listsui.onOpenMarkdownFilesin bothEXPECTED_DIRECT_CALLBACK_METHODSandEXPECTED_CALLBACK_REGISTRATION_SEQUENCE, closing the gap the new listener left in the lifecycle inventory. - Coverage — a new
os-markdown-file-open-bridge.test.tscase asserts a non-array payload is ignored without opening, toasting, or leaking an unhandled rejection.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…tablyai#17906) * feat(app): open Markdown files from the OS in the floating workspace Registers Orca as a Markdown handler on macOS, Windows and Linux, and opens an OS-handed .md/.markdown/.mdx file as a floating-workspace editor tab — the one editor surface that needs no project. Works cold-start and when Orca is already running. Main buffers the paths and both pushes to a live renderer and answers a pull on renderer mount, mirroring SkillShareDeepLinkState. The buffer is only released once delivery is possible: the renderer's pull is what proves its ui:openMarkdownFiles listener is attached, because a push into a window whose renderer has not subscribed is dropped by Electron with no error. Both the push and the pull restore an undelivered batch, and a renderer reload clears the latch so the fresh renderer re-proves itself. Paths are stat'd and proven to be files before authorizeExternalPath sees them. Windows association is registered by hand in the NSIS include rather than through electron-builder's `fileAssociations`: app-builder-lib emits APP_ASSOCIATE, whose first line overwrites Software\Classes\.md's default value with no backup — silently taking .md from whichever editor owns it, for every existing user on their next update — and APP_UNASSOCIATE never restores it. The hand-rolled registration is additive (ProgID + OpenWithProgids + SupportedTypes) and leaves the user's default alone; verified end to end on a real Windows 11 host. Co-authored-by: Wooseong Kim <[email protected]> Co-authored-by: Jaydev <[email protected]> Closes stablyai#10138 * fix(os-open): register the new listener in the IPC inventory, and guard a non-array payload CI caught two things the local run did not. useIpcEvents-lifecycle.test.ts is an inventory of every App-lifetime IPC listener and the exact order they register in; ui.onOpenMarkdownFiles now appears there, positioned after the workspace-shortcut bridge's last listener, which is where it actually registers. Chasing that failure surfaced a real gap: the pending-open payload crosses the preload boundary, so a stale or mismatched preload can resolve with something that is not an array, and reading .length off it threw inside the promise chain instead of failing at the boundary. Array.isArray now gates it, with a regression test. Mirror-Of: 4efc86a
…n-host-materialization Conflicts, and how each was resolved: - config/nsis/daemon-host-uninstall.nsh: main deleted it (#17906 consolidated every NSIS hook into config/nsis/orca-installer-hooks.nsh, because electron-builder accepts exactly one `nsis.include`). Took the deletion; the rewritten uninstall macro is ported into the hooks file in the next commit. Doc references repointed at the surviving file. - docs/reference/windows-edr-posture.md: add/add. This branch's base (#17856) squash-landed on main, and #18151 then corrected several process-table claims there. Took main's corrected text and re-applied only this branch's daemon-host edits (the rename removal, T1036.005, the spawn-tree line, the checklist row). - .gitignore, AGENTS.md: kept both sides' added lines.
… include The uninstall macro this branch rewrote lived in config/nsis/daemon-host-uninstall.nsh, which main no longer includes: #17906 consolidated every Windows installer hook into config/nsis/orca-installer-hooks.nsh because electron-builder accepts exactly one `nsis.include`. Merged as-is, the rewritten macro would have been dead code while the shipped uninstaller kept running main's stale sweep — `taskkill /F /IM orca-terminal-daemon.exe`, which matches nothing now that the relocated host is a verbatim Orca.exe copy. The RMDir that follows then cannot delete the running image, so a live orphaned daemon and its ~224 MB tree would survive every uninstall. Ported into the live include: the ${APP_EXECUTABLE_FILENAME} kill, the USERNAME filter that keeps an elevated machine-wide uninstall out of another logged-on user's session, and the register save/restore around both. The legacy orca-terminal-daemon.exe kill stays so hosts left by older builds are still reaped. The ratchet that was meant to catch exactly this pinned only the legacy image name, which main's stale macro already satisfied, so it passed both ways. It now asserts the app-exe kill and the USERNAME filter, against comment-stripped script — the prose above the macro names both image names, so a toContain over the raw file proves nothing.
…t (MDE T1036) (#17865) * docs(windows): document the EDR signal surface Six Microsoft Defender for Endpoint incidents fired against Orca 1.4.192 in eight days on one enterprise Windows 11 / Intune tenant. All six were behavioural process-tree scoring, not signature hits; two escalated to multi-stage incidents mapped to ATT&CK Execution and Collection. Add a reference doc mapping each attack-technique-shaped behaviour to the code that produces it and to why it exists: the renamed daemon image (T1036), the per-process PEB read, encoded policy-bypassed PowerShell (T1049), caret-escaped cmd.exe lines, and computer-use screen capture plus runtime-compiled MSIL (T1113). Records that signing is not the gate -- reputation is signer plus hash-keyed prevalence -- and carries the two evidence gaps the report noted. Adds an engineer checklist, deployment guidance for admins (AV path exclusions do not suppress EDR behavioural alerts; an MDE alert suppression rule does), and an explicit pre-deployment warning about computer use. * docs(windows): correct the PowerShell flag inventory and admin paths Review corrections to the EDR posture doc. The "encoded, policy-bypassing PowerShell" list conflated three different shapes and was incomplete. Split it into the three tiers an EDR actually scores differently -- bypass plus encoding, encoding alone, and bypass alone -- and add the sites it missed, including windows-mobile-firewall.ts, which encodes a script and launches it elevated through Start-Process -Verb RunAs. system-fonts.ts (-Command) and desktop-script-provider-bridge.ts (-File) were listed as encoded and are not. Notes that a raw grep under-reports, because the hook sites reach -EncodedCommand through wrapWindowsPowerShellEncodedCommand. Attribute the in-payload Set-ExecutionPolicy move to #16576 rather than to #16003's measurement, which keyed on -WindowStyle Hidden + -EncodedCommand, and record that the launcher's own tradeoff is unverified on a real box. Admin guidance was missing two ways a suppression rule pinned to one full path misses real activity: the .staging-<hex> sibling that exists mid-update, which is when the update-cluster incidents fire, and the userData fallback when LOCALAPPDATA is unset. Also: state the measurement conditions on the process-table timings, note that Hermes has surface even though we have no telemetry for it, note that the uninstaller names are electron-builder-generated and in no repo file, drop a volatile line count, and mark the per-operation computer-use shape as being addressed by an unmerged change. Drops the duplicated AGENTS.md section, keeping the indexed bullet. * docs(windows): reconcile the EDR posture doc with the shipped remediation Three claims in this doc became false once the rest of the Windows EDR set landed, and two told engineers the opposite of what the release does. The process-table section still described one shared snapshot taken with `Memory | CommandLine | CreationTime`, argued that splitting the cache per field set "would restore exactly the fan-out it exists to prevent", and concluded the shape was unfixable because "the information is only in the PEB". The split shipped (identity opens no handle at all), `Memory` is retired, and the command line now comes from the kernel through `ProcessCommandLineInformation` -- `ReadProcessMemory` is absent from the compiled addon and a ratchet asserts it against the import table. An engineer reading the old text would have concluded both fixes were dead ends. The PowerShell site inventories were stale in three of four lists: the port scan went native, every `-ExecutionPolicy Bypass` + `-EncodedCommand` pair was dropped as a measured no-op, and of the unencoded-bypass list only `wsl-cli-scripts.ts` survives. Regenerated against the merged tree, including the sites that reach the flag through `wrapWindowsPowerShellEncodedCommand` and never spell it, which a raw `rg` misses. Incident-evidence sections are left alone: they record what the tenant observed on 1.4.192, not what the code does now. * fix(windows): copy the daemon host exe verbatim instead of renaming it Microsoft Defender for Endpoint flagged `orca-terminal-daemon.exe` as MITRE T1036 (Masquerading): Orca copied its own `Orca.exe` into %LOCALAPPDATA% under a different name, specifically so the NSIS updater's `taskkill /IM Orca.exe` could not match, then ran it detached. Because that process is what every other flagged action was attributed to, the name mismatch acted as a reputation multiplier on unrelated findings. The rename was never what made the daemon survive. In app-builder-lib 26.15.3 the installer's FIND_PROCESS/KILL_PROCESS select processes whose image path is under $INSTDIR; `taskkill /IM` is only the fallback for hosts where PowerShell is missing or blocked. Survival is a property of the path, and %LOCALAPPDATA%\Orca\daemon-host is outside $INSTDIR whatever the file is called. Derive the host exe name from process.execPath so the copy is byte-for-byte, name included — it keeps its Authenticode signature and carries no renamed-image signal. On the no-PowerShell fallback the daemon is now killed with the app and terminals cold-restore, which is the documented pre-relocation outcome the update harness already asserts, not a regression. The uninstall macro no longer needs a distinct name to find the daemon; it kills the app's own image name (plus the legacy name, for hosts left by older builds). Adds docs/reference/windows-daemon-host-relocation.md with the survival contract, the rejected alternatives and their measured costs, and the invariants to keep. * fix(windows): apply daemon-host relocation review corrections Scope the uninstall taskkill to the current user with `/FI "USERNAME eq %USERNAME%"` via cmd.exe, matching upstream's per-user KILL_PROCESS — without it an elevated machine-wide uninstall reaches another logged-on user's session, so the "no collateral" claim in the comment was overstated. Comment the rmSync-before-publish: Windows refuses to delete a running image, so a live daemon already hosted in this version's dir (same-version reinstall, or a dev channel reusing a version) throws and materialization fails open. Doc corrections: - The fallback selector is the full per-user `taskkill /F /IM "<app>.exe" /FI "PID ne $pid" /FI "USERNAME eq %USERNAME%"`, not a bare `taskkill /IM`. - The probe reads `Get-ExecutionPolicy -Scope Process`, not the effective policy, and GPO writes MachinePolicy/UserPolicy — so GPO-managed hosts take the primary path-scoped branch. Narrow the fallback triggers accordingly. - Drop the Authenticode sentence: the old name was equally byte-identical and equally signed, so a filename has no bearing on signature validity. - Name the new update-abort path: the daemon now matches FIND_PROCESS, so on the fallback branch an unkillable host reaches the retry loop's MessageBox /SD IDCANCEL and Quits, aborting a silent update. - Correct the customCheckAppRunning rejection. It is ~6 lines, not a rewrite; it is wrong because forcing the PowerShell branch where PowerShell is absent makes FIND/KILL silently no-op and leaves the real app running with files in use. - Bound the win honestly: OriginalFilename is empty on the shipped binary, so the strongest T1036 indicator never fired, and the residual copy-and-run-detached shape still maps to T1036.005. Reconcile docs/reference/windows-edr-posture.md, which documents the rename as a live finding and would otherwise contradict this change. Content-only edit: markdown under docs/reference/ is not oxfmt-formatted as a matter of practice and nothing in CI gates it, so the file is left consistent with its neighbours. * fix(windows): expand USERNAME in NSIS instead of spawning cmd.exe The uninstall macro routed both taskkills through `"$SYSDIR\cmd.exe" /C` purely so `%USERNAME%` would expand — two extra interpreter spawns on the uninstall path, in a change whose whole point is not adding scored behaviour, and the exact `cmd.exe /c` shape the new AGENTS.md EDR bullet warns about. NSIS reads the variable itself with ReadEnvStr, so the spawns buy nothing. Verified on Windows 11 that the generated command line does what the filter is there for: a copy of cmd.exe running as orca-nonexistent-probe.exe (pid 34244) was terminated by `taskkill /F /IM "orca-nonexistent-probe.exe" /FI "USERNAME eq <user>"` — SUCCESS, exit 0, process gone. Guarded on an empty USERNAME because the degenerate case is silent: taskkill rejects an empty filter value outright ("The search filter cannot be recognized") and kills nothing, which would leave exactly the orphaned daemon this macro exists to reap. `*` is rejected as a filter value too, so there is no branchless spelling. With no USERNAME to scope by it kills unfiltered, as the macro did before the filter was added. Stack stays balanced: three pushes, two nsExec pops, three restores. Also strike the last stale row in windows-edr-posture.md's remediation table. "Copying our own image under a different name" read as outstanding work; it is done by this change, so the row now points at the relocation doc. Same class of staleness as the section reconciled in the previous commit, and git would not have flagged it either. * fix(windows): port the daemon-host uninstall sweep into the live NSIS include The uninstall macro this branch rewrote lived in config/nsis/daemon-host-uninstall.nsh, which main no longer includes: #17906 consolidated every Windows installer hook into config/nsis/orca-installer-hooks.nsh because electron-builder accepts exactly one `nsis.include`. Merged as-is, the rewritten macro would have been dead code while the shipped uninstaller kept running main's stale sweep — `taskkill /F /IM orca-terminal-daemon.exe`, which matches nothing now that the relocated host is a verbatim Orca.exe copy. The RMDir that follows then cannot delete the running image, so a live orphaned daemon and its ~224 MB tree would survive every uninstall. Ported into the live include: the ${APP_EXECUTABLE_FILENAME} kill, the USERNAME filter that keeps an elevated machine-wide uninstall out of another logged-on user's session, and the register save/restore around both. The legacy orca-terminal-daemon.exe kill stays so hosts left by older builds are still reaped. The ratchet that was meant to catch exactly this pinned only the legacy image name, which main's stale macro already satisfied, so it passed both ways. It now asserts the app-exe kill and the USERNAME filter, against comment-stripped script — the prose above the macro names both image names, so a toContain over the raw file proves nothing. --------- Co-authored-by: Orca Worker <orca-worker@localhost>
…tablyai#17906) * feat(app): open Markdown files from the OS in the floating workspace Registers Orca as a Markdown handler on macOS, Windows and Linux, and opens an OS-handed .md/.markdown/.mdx file as a floating-workspace editor tab — the one editor surface that needs no project. Works cold-start and when Orca is already running. Main buffers the paths and both pushes to a live renderer and answers a pull on renderer mount, mirroring SkillShareDeepLinkState. The buffer is only released once delivery is possible: the renderer's pull is what proves its ui:openMarkdownFiles listener is attached, because a push into a window whose renderer has not subscribed is dropped by Electron with no error. Both the push and the pull restore an undelivered batch, and a renderer reload clears the latch so the fresh renderer re-proves itself. Paths are stat'd and proven to be files before authorizeExternalPath sees them. Windows association is registered by hand in the NSIS include rather than through electron-builder's `fileAssociations`: app-builder-lib emits APP_ASSOCIATE, whose first line overwrites Software\Classes\.md's default value with no backup — silently taking .md from whichever editor owns it, for every existing user on their next update — and APP_UNASSOCIATE never restores it. The hand-rolled registration is additive (ProgID + OpenWithProgids + SupportedTypes) and leaves the user's default alone; verified end to end on a real Windows 11 host. Co-authored-by: Wooseong Kim <[email protected]> Co-authored-by: Jaydev <[email protected]> Closes stablyai#10138 * fix(os-open): register the new listener in the IPC inventory, and guard a non-array payload CI caught two things the local run did not. useIpcEvents-lifecycle.test.ts is an inventory of every App-lifetime IPC listener and the exact order they register in; ui.onOpenMarkdownFiles now appears there, positioned after the workspace-shortcut bridge's last listener, which is where it actually registers. Chasing that failure surfaced a real gap: the pending-open payload crosses the preload boundary, so a stale or mismatched preload can resolve with something that is not an array, and reading .length off it threw inside the promise chain instead of failing at the boundary. Array.isArray now gates it, with a regression test.
…t (MDE T1036) (stablyai#17865) * docs(windows): document the EDR signal surface Six Microsoft Defender for Endpoint incidents fired against Orca 1.4.192 in eight days on one enterprise Windows 11 / Intune tenant. All six were behavioural process-tree scoring, not signature hits; two escalated to multi-stage incidents mapped to ATT&CK Execution and Collection. Add a reference doc mapping each attack-technique-shaped behaviour to the code that produces it and to why it exists: the renamed daemon image (T1036), the per-process PEB read, encoded policy-bypassed PowerShell (T1049), caret-escaped cmd.exe lines, and computer-use screen capture plus runtime-compiled MSIL (T1113). Records that signing is not the gate -- reputation is signer plus hash-keyed prevalence -- and carries the two evidence gaps the report noted. Adds an engineer checklist, deployment guidance for admins (AV path exclusions do not suppress EDR behavioural alerts; an MDE alert suppression rule does), and an explicit pre-deployment warning about computer use. * docs(windows): correct the PowerShell flag inventory and admin paths Review corrections to the EDR posture doc. The "encoded, policy-bypassing PowerShell" list conflated three different shapes and was incomplete. Split it into the three tiers an EDR actually scores differently -- bypass plus encoding, encoding alone, and bypass alone -- and add the sites it missed, including windows-mobile-firewall.ts, which encodes a script and launches it elevated through Start-Process -Verb RunAs. system-fonts.ts (-Command) and desktop-script-provider-bridge.ts (-File) were listed as encoded and are not. Notes that a raw grep under-reports, because the hook sites reach -EncodedCommand through wrapWindowsPowerShellEncodedCommand. Attribute the in-payload Set-ExecutionPolicy move to stablyai#16576 rather than to stablyai#16003's measurement, which keyed on -WindowStyle Hidden + -EncodedCommand, and record that the launcher's own tradeoff is unverified on a real box. Admin guidance was missing two ways a suppression rule pinned to one full path misses real activity: the .staging-<hex> sibling that exists mid-update, which is when the update-cluster incidents fire, and the userData fallback when LOCALAPPDATA is unset. Also: state the measurement conditions on the process-table timings, note that Hermes has surface even though we have no telemetry for it, note that the uninstaller names are electron-builder-generated and in no repo file, drop a volatile line count, and mark the per-operation computer-use shape as being addressed by an unmerged change. Drops the duplicated AGENTS.md section, keeping the indexed bullet. * docs(windows): reconcile the EDR posture doc with the shipped remediation Three claims in this doc became false once the rest of the Windows EDR set landed, and two told engineers the opposite of what the release does. The process-table section still described one shared snapshot taken with `Memory | CommandLine | CreationTime`, argued that splitting the cache per field set "would restore exactly the fan-out it exists to prevent", and concluded the shape was unfixable because "the information is only in the PEB". The split shipped (identity opens no handle at all), `Memory` is retired, and the command line now comes from the kernel through `ProcessCommandLineInformation` -- `ReadProcessMemory` is absent from the compiled addon and a ratchet asserts it against the import table. An engineer reading the old text would have concluded both fixes were dead ends. The PowerShell site inventories were stale in three of four lists: the port scan went native, every `-ExecutionPolicy Bypass` + `-EncodedCommand` pair was dropped as a measured no-op, and of the unencoded-bypass list only `wsl-cli-scripts.ts` survives. Regenerated against the merged tree, including the sites that reach the flag through `wrapWindowsPowerShellEncodedCommand` and never spell it, which a raw `rg` misses. Incident-evidence sections are left alone: they record what the tenant observed on 1.4.192, not what the code does now. * fix(windows): copy the daemon host exe verbatim instead of renaming it Microsoft Defender for Endpoint flagged `orca-terminal-daemon.exe` as MITRE T1036 (Masquerading): Orca copied its own `Orca.exe` into %LOCALAPPDATA% under a different name, specifically so the NSIS updater's `taskkill /IM Orca.exe` could not match, then ran it detached. Because that process is what every other flagged action was attributed to, the name mismatch acted as a reputation multiplier on unrelated findings. The rename was never what made the daemon survive. In app-builder-lib 26.15.3 the installer's FIND_PROCESS/KILL_PROCESS select processes whose image path is under $INSTDIR; `taskkill /IM` is only the fallback for hosts where PowerShell is missing or blocked. Survival is a property of the path, and %LOCALAPPDATA%\Orca\daemon-host is outside $INSTDIR whatever the file is called. Derive the host exe name from process.execPath so the copy is byte-for-byte, name included — it keeps its Authenticode signature and carries no renamed-image signal. On the no-PowerShell fallback the daemon is now killed with the app and terminals cold-restore, which is the documented pre-relocation outcome the update harness already asserts, not a regression. The uninstall macro no longer needs a distinct name to find the daemon; it kills the app's own image name (plus the legacy name, for hosts left by older builds). Adds docs/reference/windows-daemon-host-relocation.md with the survival contract, the rejected alternatives and their measured costs, and the invariants to keep. * fix(windows): apply daemon-host relocation review corrections Scope the uninstall taskkill to the current user with `/FI "USERNAME eq %USERNAME%"` via cmd.exe, matching upstream's per-user KILL_PROCESS — without it an elevated machine-wide uninstall reaches another logged-on user's session, so the "no collateral" claim in the comment was overstated. Comment the rmSync-before-publish: Windows refuses to delete a running image, so a live daemon already hosted in this version's dir (same-version reinstall, or a dev channel reusing a version) throws and materialization fails open. Doc corrections: - The fallback selector is the full per-user `taskkill /F /IM "<app>.exe" /FI "PID ne $pid" /FI "USERNAME eq %USERNAME%"`, not a bare `taskkill /IM`. - The probe reads `Get-ExecutionPolicy -Scope Process`, not the effective policy, and GPO writes MachinePolicy/UserPolicy — so GPO-managed hosts take the primary path-scoped branch. Narrow the fallback triggers accordingly. - Drop the Authenticode sentence: the old name was equally byte-identical and equally signed, so a filename has no bearing on signature validity. - Name the new update-abort path: the daemon now matches FIND_PROCESS, so on the fallback branch an unkillable host reaches the retry loop's MessageBox /SD IDCANCEL and Quits, aborting a silent update. - Correct the customCheckAppRunning rejection. It is ~6 lines, not a rewrite; it is wrong because forcing the PowerShell branch where PowerShell is absent makes FIND/KILL silently no-op and leaves the real app running with files in use. - Bound the win honestly: OriginalFilename is empty on the shipped binary, so the strongest T1036 indicator never fired, and the residual copy-and-run-detached shape still maps to T1036.005. Reconcile docs/reference/windows-edr-posture.md, which documents the rename as a live finding and would otherwise contradict this change. Content-only edit: markdown under docs/reference/ is not oxfmt-formatted as a matter of practice and nothing in CI gates it, so the file is left consistent with its neighbours. * fix(windows): expand USERNAME in NSIS instead of spawning cmd.exe The uninstall macro routed both taskkills through `"$SYSDIR\cmd.exe" /C` purely so `%USERNAME%` would expand — two extra interpreter spawns on the uninstall path, in a change whose whole point is not adding scored behaviour, and the exact `cmd.exe /c` shape the new AGENTS.md EDR bullet warns about. NSIS reads the variable itself with ReadEnvStr, so the spawns buy nothing. Verified on Windows 11 that the generated command line does what the filter is there for: a copy of cmd.exe running as orca-nonexistent-probe.exe (pid 34244) was terminated by `taskkill /F /IM "orca-nonexistent-probe.exe" /FI "USERNAME eq <user>"` — SUCCESS, exit 0, process gone. Guarded on an empty USERNAME because the degenerate case is silent: taskkill rejects an empty filter value outright ("The search filter cannot be recognized") and kills nothing, which would leave exactly the orphaned daemon this macro exists to reap. `*` is rejected as a filter value too, so there is no branchless spelling. With no USERNAME to scope by it kills unfiltered, as the macro did before the filter was added. Stack stays balanced: three pushes, two nsExec pops, three restores. Also strike the last stale row in windows-edr-posture.md's remediation table. "Copying our own image under a different name" read as outstanding work; it is done by this change, so the row now points at the relocation doc. Same class of staleness as the section reconciled in the previous commit, and git would not have flagged it either. * fix(windows): port the daemon-host uninstall sweep into the live NSIS include The uninstall macro this branch rewrote lived in config/nsis/daemon-host-uninstall.nsh, which main no longer includes: stablyai#17906 consolidated every Windows installer hook into config/nsis/orca-installer-hooks.nsh because electron-builder accepts exactly one `nsis.include`. Merged as-is, the rewritten macro would have been dead code while the shipped uninstaller kept running main's stale sweep — `taskkill /F /IM orca-terminal-daemon.exe`, which matches nothing now that the relocated host is a verbatim Orca.exe copy. The RMDir that follows then cannot delete the running image, so a live orphaned daemon and its ~224 MB tree would survive every uninstall. Ported into the live include: the ${APP_EXECUTABLE_FILENAME} kill, the USERNAME filter that keeps an elevated machine-wide uninstall out of another logged-on user's session, and the register save/restore around both. The legacy orca-terminal-daemon.exe kill stays so hosts left by older builds are still reaped. The ratchet that was meant to catch exactly this pinned only the legacy image name, which main's stale macro already satisfied, so it passed both ways. It now asserts the app-exe kill and the USERNAME filter, against comment-stripped script — the prose above the macro names both image names, so a toContain over the raw file proves nothing. --------- Co-authored-by: Orca Worker <orca-worker@localhost>

Closes #10138.
ELI5
Right now, if you have a Markdown file sitting on your Desktop, Orca can't open it. You have to launch Orca first, then go find the file. There's no "Open With → Orca."
This adds that. Double-click a
.md(or pick Orca from "Open With") and it opens in the floating workspace — Orca's little overlay editor that doesn't need a project or a git worktree behind it. It works whether Orca is already running or not.Three pieces:
open-fileevent, or throughsecond-instancewhen Orca is already running. If it arrives before the window is ready, we hold onto it and the window asks for it once it's listening.The important bit: Orca joins the "Open With" list. It does not become your default Markdown app. If VS Code opens your
.mdfiles today, it still will after this.Risk level: Medium
Not low, because it touches the Windows installer and ships a change that applies to every existing user on auto-update. Not high, because the app-side surface is small, additive, and heavily covered.
.md. Zero effect on every other launch.CFBundleDocumentTypeswithLSHandlerRank: Alternate. Merges with the existingmac.extendInfo(verified inapp-builder-lib), doesn't replace it.MimeType=text/markdown;line on the.desktopentry, reusing the system's existing mime type.mimeapps.liststill owns the default.config/nsis/daemon-host-uninstall.nshwas renamed toorca-installer-hooks.nshbecause electron-builder allows only onensis.include. The load-bearing daemon-host cleanup moved verbatim and is pinned by a test. This is the part that wants a real Windows install/uninstall/update check before merge.Rollback is a plain revert. Nothing is persisted that a previous version can't read, and uninstall removes exactly what install added.
The trap in this issue
Two contributor PRs exist (#10173, #11325). Both put
fileAssociationsat the top level of the electron-builder config. That feeds the NSIS packager, whoseAPP_ASSOCIATEmacro opens with:That overwrites whichever editor currently owns
.md— no backup, no prompt — for every existing user on their next update, not just people who wanted the feature. AndAPP_UNASSOCIATEdeletes the ProgID without restoring the default, so uninstalling Orca would leave.mdpointing at a key that no longer exists.#11325 believed
rank: 'Alternate'prevented this and asserted so in a test comment.rankisLSHandlerRank— macOS only. It does nothing on Windows.So this PR scopes
fileAssociationstomaconly, useslinux.mimeTypesto reuse the existingtext/markdowntype, and hand-writes the Windows registration in the NSIS include as an additive ProgID +OpenWithProgids+SupportedTypes, never touching the.mddefault.config/scripts/electron-builder-markdown-associations.test.mjsfails if anyone hoists the block back to the top level, and greps the.nshfor the forbidden write (with a falsifiability test proving that regex can actually fire).Credit — both contributors were on the right track
isMarkdownDocumentName,authorizeExternalPath, andmarkdownDocumentFromFilePath(root, path, { outsideRootRelativePath: 'basename' })— which is exactly what Orca's existingpickFloatingMarkdownDocumentdoes. That's a careful read of the codebase, and this PR's main-side shape follows it.rank: 'Alternate', validating existence +isFile()before trusting a path, and testing the packaging config at all — that last one is what this PR's regression guard grew out of.Both are credited as co-authors. Neither PR is taken as-is: both branch points are ~5 weeks stale and the ground moved under them (details below).
Why not just take one of them
src/main/index.tsalready grew the pattern both PRs were reaching for.requestDesktopActivation(argv)takes argv today,acquireSingleInstanceLock(app, requestDesktopActivation)already forwards it, andSkillShareDeepLinkState+ipcMain.handle('ui:consumePendingSkillShare')is an established push-and-pull buffer for exactly this "intent arrived before the renderer mounted" problem. This PR mirrors it instead of inventing a third mechanism.Concretely, since those branch points:
single-instance-lock.tswidening is now already on main, and its lambda would breakserve-desktop-activation-wiring.test.ts, which pins the exact call text.useIpcEvents.tswas split intohooks/ipc-events/*bridges; the floating-workspace panel moved fromApp.tsxtoapp-shell/use-floating-workspace-panel.ts. Both PRs edit files that no longer hold that code.What's here
Main —
src/main/startup/os-opened-markdown-files.tsmarkdownPathsFromArguments(argv, platform)— absolute Markdown paths only; drops switches, relative entries, and (via the extension check alone) the executable, asar and dev entry points. Case-insensitive dedupe on win32 only.OsOpenedMarkdownFileState— capped buffer (32) withcapture/captureFilePaths/consume/restore.resolveOpenedMarkdownDocuments—stat+isFile()beforeauthorizeExternalPath, then the sameMarkdownDocumentshape the native picker produces.Wired in
src/main/index.ts: capture insiderequestDesktopActivation(before theorca serveearly return), anapp.on('open-file')that onlypreventDefault()s paths it actually claims, a cold-startcapture(process.argv), andipcMain.handle('ui:consumePendingMarkdownFileOpens').Renderer
lib/open-markdown-in-floating-workspace.ts— extracted fromuse-floating-terminal-create-actions.ts, now shared by the native picker and the OS path (reuse-before-reimplementing).hooks/ipc-events/os-markdown-file-open-bridge.ts— subscribes, drains the pending queue on mount, enables + reveals the floating workspace the same way the Settings "Edit keybindings in Orca" action does, and isolates failures per document so one bad file in a multi-file selection doesn't cost you the rest.A Linux bug caught during review, present in both contributor PRs: electron-builder appends the
%Ufield code to the generatedExec=line, and%Umeans URLs — GIO hands overfile:///home/me/a.md, never a bare path. Both PRs' argv filters drop that, so the feature would have silently done nothing on every Linux desktop.localPathFromArgumentnow decodesfile://(including percent-escapes and the UNC authority form) with an explicitwindowsflag so it behaves identically on any host.Testing
pnpm tc,oxlint,pnpm run check:code-quality:changed(0 new findings), max-lines ratchet, and all three localization gates: green.pnpm teston the new suites plus their neighbours: 228 passed / 22 files, including 26 argv-and-buffer cases, per-platform path handling driven for darwin/win32/linux, real-filesystem fixtures proving a directory namedbundle.mdand a deleted path are both dropped without being authorized, and unhandled-rejection assertions on both the push and pull paths.Two failures in
src/main/startup/run-electron-vite-dev.test.tsare pre-existing — I reproduced them on an unmodifiedHEADworktree, same two tests, and that file is untouched here.Not verified
app-builder-lib's own templates, but nobody has run the installer. Given the rename of the include that carries the daemon-host cleanup, this is the thing I'd most want a second pair of eyes on.lsregister/update-desktop-databasebehaviour is reasoned fromapp-builder-libsource, not observed..mdxon Linux only works where the distro's mime database maps it, since we deliberately reusetext/markdownrather than shipping a glob override.