logancyang_obsidian-copilot/scripts
Logan Yang 775d832ee5
fix(mobile): guard Agent Mode off the mobile load path (#2577)
* fix(mobile): shim `process` so the bundle survives module-eval on mobile

Follow-up to #2576 (preview issue #125). After the EventEmitter fix, mobile now
crashes at load with "ReferenceError: Can't find variable: process".

Cause: Agent Mode is desktop-only but its modules are statically imported, so
they're evaluated on every platform. Several read the Node global `process` at
module scope (e.g. `InstallCommandRow.tsx`'s `const DEFAULT_LABEL =
process.platform === "win32" ? ...`, the codex/claude/opencode descriptors),
and bundled Node deps read `process.env` at init. Mobile's WebView has no
`process`, so evaluating any of them throws during import and kills the plugin.

Fix: prepend a minimal `process` shim in the esbuild banner —
`var process = globalThis.process || { env:{}, platform:"", ... }`. Desktop
(Electron) has a real `globalThis.process` and uses it unchanged; mobile gets
the stub, so module evaluation no longer throws. The desktop-only code paths
that actually use `process` never run on mobile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore(test-vault): copy-deploy into iCloud-synced vaults for mobile testing

`npm run test:vault` symlinks main.js/styles.css by default, but iCloud syncs
file contents, not link targets, so a symlinked build never reaches the phone.
Detect iCloud vaults (path under "/Mobile Documents/") and copy real files
instead, so deploying to an iCloud vault makes the build testable on Obsidian
mobile. Mirrors the existing WSL copy-mode rule.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(mobile): keep agent mode off load path

* test(mobile): add load smoke check

* fix(mobile): share agent chat mode constant

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-06 21:56:58 -07:00
..
stubs chore(eslint): enable no-explicit-any; fix ~395 violations (#2452) 2026-05-14 02:08:45 -07:00
test-fixtures introduce model migration script 2026-05-28 16:03:46 -07:00
mobile-load-smoke.cjs fix(mobile): guard Agent Mode off the mobile load path (#2577) 2026-06-06 21:56:58 -07:00
patchRendererUnsafeUnref.js feat(agent-mode): introduce Agent Mode feature 2026-05-20 19:05:41 -07:00
printPromptDebug.js chore(lint): enable no-unsanitized/method and property (#2418) 2026-05-13 01:56:00 -07:00
printPromptDebugEntry.ts chore(eslint): enable no-explicit-any; fix ~395 violations (#2452) 2026-05-14 02:08:45 -07:00
seed-skills-scenarios.sh feat(skills): redesign skills discovery — discover in place, lazy migration (#2519) 2026-05-28 16:29:52 -07:00
test-reset-data.sh Add vault test with test fixture 2026-05-28 16:02:48 -07:00
test-vault.sh fix(mobile): guard Agent Mode off the mobile load path (#2577) 2026-06-06 21:56:58 -07:00