Skip to content

feat(app): open Markdown files from the OS in the floating workspace - #17906

Merged
nwparker merged 2 commits into
mainfrom
nwparker/feature-support-opening-markdown-files-from-the
Sep 2, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/feature-support-opening-markdown-files-from-the

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​930 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​930
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​469 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​425

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:

  1. Tell the OS Orca can handle Markdown. Finder, Explorer and the Linux file manager each need this declared at install time.
  2. Catch the file path when the OS hands it over. It can arrive three ways: on the command line at launch, via macOS's open-file event, or through second-instance when 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.
  3. Open it. Same code path the floating workspace's own "open a Markdown file" button already uses.

The important bit: Orca joins the "Open With" list. It does not become your default Markdown app. If VS Code opens your .md files 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.

Area Risk Why
App runtime Low New code only runs when the OS hands over a .md. Zero effect on every other launch.
macOS packaging Low CFBundleDocumentTypes with LSHandlerRank: Alternate. Merges with the existing mac.extendInfo (verified in app-builder-lib), doesn't replace it.
Linux packaging Low One MimeType=text/markdown; line on the .desktop entry, reusing the system's existing mime type. mimeapps.list still owns the default.
Windows installer Medium Registry writes, plus config/nsis/daemon-host-uninstall.nsh was renamed to orca-installer-hooks.nsh because electron-builder allows only one nsis.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 fileAssociations at the top level of the electron-builder config. That feeds the NSIS packager, whose APP_ASSOCIATE macro opens with:

WriteRegStr SHELL_CONTEXT "Software\Classes\.md" "" "<ProgID>"

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. And APP_UNASSOCIATE deletes the ProgID without restoring the default, so uninstalling Orca would leave .md pointing at a key that no longer exists.

#11325 believed rank: 'Alternate' prevented this and asserted so in a test comment. rank is LSHandlerRank — macOS only. It does nothing on Windows.

So this PR scopes fileAssociations to mac only, uses linux.mimeTypes to reuse the existing text/markdown type, and hand-writes the Windows registration in the NSIS include as an additive ProgID + OpenWithProgids + SupportedTypes, never touching the .md default. config/scripts/electron-builder-markdown-associations.test.mjs fails if anyone hoists the block back to the top level, and greps the .nsh for the forbidden write (with a falsifiability test proving that regex can actually fire).

Credit — both contributors were on the right track

  • @innocarpe (feat(app): open OS Markdown files in the floating workspace #10173) picked the correct target: the floating workspace, as the issue asked. They also found the right main-process primitives on their own — isMarkdownDocumentName, authorizeExternalPath, and markdownDocumentFromFilePath(root, path, { outsideRootRelativePath: 'basename' }) — which is exactly what Orca's existing pickFloatingMarkdownDocument does. That's a careful read of the codebase, and this PR's main-side shape follows it.
  • @java-jaydev (feat: open markdown files from the OS file manager #11325) took the wrong architectural route (creating a folder workspace per opened file) and said so themselves in the issue, which was a genuinely useful thing to do. Their PR contributed the ideas worth keeping: 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.ts already grew the pattern both PRs were reaching for. requestDesktopActivation(argv) takes argv today, acquireSingleInstanceLock(app, requestDesktopActivation) already forwards it, and SkillShareDeepLinkState + 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:

What's here

Main — src/main/startup/os-opened-markdown-files.ts

  • markdownPathsFromArguments(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) with capture / captureFilePaths / consume / restore.
  • resolveOpenedMarkdownDocuments — stat + isFile() before authorizeExternalPath, then the same MarkdownDocument shape the native picker produces.

Wired in src/main/index.ts: capture inside requestDesktopActivation (before the orca serve early return), an app.on('open-file') that only preventDefault()s paths it actually claims, a cold-start capture(process.argv), and ipcMain.handle('ui:consumePendingMarkdownFileOpens').

Renderer

  • lib/open-markdown-in-floating-workspace.ts — extracted from use-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 %U field code to the generated Exec= line, and %U means URLs — GIO hands over file:///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. localPathFromArgument now decodes file:// (including percent-escapes and the UNC authority form) with an explicit windows flag 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 test on 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 named bundle.md and 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.ts are pre-existing — I reproduced them on an unmodified HEAD worktree, same two tests, and that file is untouched here.

Not verified

  • No real Windows install/uninstall/update run. The NSIS hooks are syntax- and content-checked by test and read against 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.
  • No packaged macOS or Linux build; lsregister / update-desktop-database behaviour is reasoned from app-builder-lib source, not observed.
  • .mdx on Linux only works where the distro's mime database maps it, since we deliberately reuse text/markdown rather than shipping a glob override.

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

✅ 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 CFBundleDocumentTypes with rank: Alternate so Orca joins "Open With" without owning the default; Linux reuses text/markdown via mimeTypes; Windows registers an additive ProgID + OpenWithProgids + SupportedTypes that never writes the .md default value.
  • Main-process intake and buffering — OsOpenedMarkdownFileState captures absolute markdown paths from argv, macOS open-file, and second-instance forwarding, decodes file:// 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 fileAssociations stays 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}).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ 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 — mainProcessState extraction, runMainProcessPreflight, registerMainProcessIpcHandlers — and re-rooted the feature onto it: osOpenedMarkdownFiles now lives in mainProcessState, publishOsOpenedMarkdownFiles reads state.mainWindow, and the ui:consumePendingMarkdownFileOpens handler moved into registerMainProcessIpcHandlers().
  • Gated the macOS open-file/open-url handlers and the cold-start capture(process.argv) behind if (preflightReady), matching main's "transient second instance never touches userData" contract; the capture-before-shouldActivateDesktopForSecondInstance ordering is preserved and still pinned by test.
  • Migrated the preload surface (onOpenMarkdownFiles, consumePendingMarkdownFileOpens) into the split ui-bridge-part-1.ts alongside the neighbouring skill-share/settings channels.
  • Updated os-opened-markdown-wiring.test.ts to pin the new call sites across index.ts, main-process-ipc-bootstrap.ts, and main-process-preflight.ts.

All four feature test suites pass (45 tests) against the merged tree.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c07e32bc-538b-4c74-821b-74b789ea21b9

📥 Commits

Reviewing files that changed from the base of the PR and between c893793 and cb41332.

📒 Files selected for processing (24)
  • config/electron-builder.config.cjs
  • config/nsis/daemon-host-uninstall.nsh
  • config/nsis/orca-installer-hooks.nsh
  • config/scripts/electron-builder-markdown-associations.test.mjs
  • src/main/daemon/daemon-host-relocation.ts
  • src/main/index.ts
  • src/main/startup/main-process-ipc-bootstrap.ts
  • src/main/startup/main-process-state.ts
  • src/main/startup/main-window-controller.ts
  • src/main/startup/os-opened-markdown-delivery.test.ts
  • src/main/startup/os-opened-markdown-files.test.ts
  • src/main/startup/os-opened-markdown-files.ts
  • src/main/startup/os-opened-markdown-wiring.test.ts
  • src/preload/api/ui-bridge-state-and-menu-commands.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/components/floating-terminal/use-floating-terminal-create-actions.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.test.ts
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/open-markdown-in-floating-workspace.test.ts
  • src/renderer/src/lib/open-markdown-in-floating-workspace.ts
  • src/renderer/src/web/preload-api/web-ui-api.ts
💤 Files with no reviewable changes (1)
  • config/nsis/daemon-host-uninstall.nsh
🚧 Files skipped from review as they are similar to previous changes (19)
  • src/main/daemon/daemon-host-relocation.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/open-markdown-in-floating-workspace.ts
  • src/renderer/src/web/preload-api/web-ui-api.ts
  • src/main/startup/main-process-ipc-bootstrap.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/main/startup/os-opened-markdown-wiring.test.ts
  • src/main/startup/main-process-state.ts
  • src/renderer/src/components/floating-terminal/use-floating-terminal-create-actions.ts
  • config/nsis/orca-installer-hooks.nsh
  • config/scripts/electron-builder-markdown-associations.test.mjs
  • config/electron-builder.config.cjs
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.ts
  • src/main/startup/os-opened-markdown-files.test.ts
  • src/main/index.ts
  • src/renderer/src/lib/open-markdown-in-floating-workspace.test.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.test.ts
  • src/main/startup/os-opened-markdown-files.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The 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 cb413

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides detailed context, implementation scope, linked issue, risks, testing results, and known verification gaps. However, it omits several required template sections, including Visu… Add the required template sections. Provide before-and-after visual proof, or write exactly N/A with a reason. Complete the testing checkboxes and include the Review, Agent skill upstream boundary, Notes, and Checklist sections.
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: opening Markdown files from the operating system in the floating workspace.
Linked Issues check ✅ Passed The implementation satisfies the coding objectives in [#10138]. It registers Orca as a non-default Markdown handler, supports cold starts and already-running instances, buffers delivery until the rend…
Out of Scope Changes check ✅ Passed The changes are focused on [#10138]. The NSIS include rename, daemon cleanup relocation, shared Markdown-opening helper, and regression tests directly support the feature and its compatibility require…
Full details: Description check

Explanation

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 check

Explanation

The implementation satisfies the coding objectives in [#10138]. It registers Orca as a non-default Markdown handler, supports cold starts and already-running instances, buffers delivery until the renderer is ready, validates paths, and opens documents in the floating workspace.

Full details: Out of Scope Changes check

Explanation

The changes are focused on [#10138]. The NSIS include rename, daemon cleanup relocation, shared Markdown-opening helper, and regression tests directly support the feature and its compatibility requirements.

Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 91d003a3-653e-4839-b7fd-5697c2f8df16

📥 Commits

Reviewing files that changed from the base of the PR and between 5aa02ea and 9b252c5.

📒 Files selected for processing (21)
  • config/electron-builder.config.cjs
  • config/nsis/daemon-host-uninstall.nsh
  • config/nsis/orca-installer-hooks.nsh
  • config/scripts/electron-builder-markdown-associations.test.mjs
  • src/main/daemon/daemon-host-relocation.ts
  • src/main/index.ts
  • src/main/startup/main-process-ipc-bootstrap.ts
  • src/main/startup/main-process-state.ts
  • src/main/startup/os-opened-markdown-files.test.ts
  • src/main/startup/os-opened-markdown-files.ts
  • src/main/startup/os-opened-markdown-wiring.test.ts
  • src/preload/api/ui-bridge-part-1.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/components/floating-terminal/use-floating-terminal-create-actions.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.test.ts
  • src/renderer/src/hooks/ipc-events/os-markdown-file-open-bridge.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/open-markdown-in-floating-workspace.test.ts
  • src/renderer/src/lib/open-markdown-in-floating-workspace.ts
  • src/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
@nwparker
nwparker force-pushed the nwparker/feature-support-opening-markdown-files-from-the branch from 9b252c5 to 3fbbfc2 Compare September 2, 2026 00:11
@nwparker

nwparker commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressing the CodeRabbit review

Both 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. consume() ran before resolveOpenedMarkdownDocuments, so a rejection (e.g. ensureDefaultFloatingWorkspacePath throwing) dropped the paths and surfaced an error, with no retry. The push path already restored; the pull didn't. Now symmetric:

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 openMainWindow() creating the BrowserWindow and the renderer mounting its bridge, publishOsOpenedMarkdownFiles() would consume the queue and webContents.send into a void — Electron drops that silently — so the later pull returned [] and the file never opened. On a cold start that gap is seconds wide, and "double-click a .md while Orca is still launching" walks straight into it.

Fixed by making the renderer's own pull the proof that the listener is live, rather than inferring it from window existence:

  • state.markdownFileOpenListenerReady starts false; pushes return early and leave the buffer intact.
  • The consumePendingMarkdownFileOpens handler sets it true — that call only happens from inside the bridge, after ipcRenderer.on is attached.
  • did-finish-load resets it to false, so a reload can't push into the same gap again; the fresh renderer re-proves itself by pulling.

Regression coverage in src/main/startup/os-opened-markdown-delivery.test.ts (3 cases) for exactly these: the batch survives a rejected resolve, it is held while the listener is unattached and delivered once it attaches, and an undelivered batch is restored. Plus two new source-wiring assertions in os-opened-markdown-wiring.test.ts pinning the latch and the reload reset.

On the reorder/duplicate note in the summary: restore() puts the batch back at the front, so ordering is preserved, and duplicate delivery is already absorbed downstream — openFile dedupes on filePath + worktreeId (open-file-apply.ts:73) and focuses the existing tab rather than opening a second one.


On the two pre-merge check warnings

Docstring coverage (40%) — not acting on this. The functions it counts are mostly 3-line test helpers and arrow callbacks; the exported surface (markdownPathsFromArguments, OsOpenedMarkdownFileState, resolveOpenedMarkdownDocuments, openMarkdownDocumentInFloatingWorkspace, publishOsOpenedMarkdownFiles) all carry docstrings explaining why, which is what AGENTS.md asks for. Adding prose to function DefaultOf($p)-style helpers to clear a percentage would be noise.

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 rebased

The branch was ~63 commits behind and conflicting. src/main/index.ts (3831 → 110 lines) and src/preload/index.ts were both split into modules on main, so I reset onto origin/main and re-applied deliberately rather than trusting the rebase — git rerere had silently resolved the preload conflict by dropping my changes entirely. New homes: main-process-state.ts (buffer + latch), main-process-ipc-bootstrap.ts (pull handler), ui-bridge-state-and-menu-commands.ts (preload impl).

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

coderabbitai Bot commented Sep 2, 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.

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

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 — markdownFileOpenListenerReady in mainProcessState gates publishOsOpenedMarkdownFiles, so main only pushes buffered paths once the renderer has proven its ui:openMarkdownFiles listener 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 resolveOpenedMarkdownDocuments rejects, so an undelivered batch survives to the next mount.
  • Reload re-arm — did-finish-load in main-window-controller.ts resets the latch to false, 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.ts covers keep-on-reject, hold-while-not-attached, and restore-after-consumed, plus wiring assertions for the latch and both restore paths.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

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.

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.

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

ℹ️ 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 — openOsRequestedMarkdownFiles now bails on !Array.isArray(documents), so a stale or partial preload resolving null (the same shape the web client's consumePendingSkillShare stub returns) can no longer throw inside the promise chain.
  • IPC inventory registration — useIpcEvents-lifecycle.test.ts now lists ui.onOpenMarkdownFiles in both EXPECTED_DIRECT_CALLBACK_METHODS and EXPECTED_CALLBACK_REGISTRATION_SEQUENCE, closing the gap the new listener left in the lifecycle inventory.
  • Coverage — a new os-markdown-file-open-bridge.test.ts case asserts a non-array payload is ignored without opening, toasting, or leaking an unhandled rejection.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 4efc86a into main Sep 2, 2026
36 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
…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
OrcaWin pushed a commit that referenced this pull request Sep 6, 2026
…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.
OrcaWin pushed a commit that referenced this pull request Sep 6, 2026
… 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.
OrcaWin added a commit that referenced this pull request Sep 6, 2026
…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>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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>
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]: Support opening Markdown files from the OS (Finder / Explorer)

1 participant