logancyang_obsidian-copilot/scripts
Zero Liu ee870b4dce
fix(mobile): keep Agent Mode off the emulated-mobile load path (#2587)
* fix(mobile): keep Agent Mode off the emulated-mobile load path

`app.emulateMobile(true)` flips Platform.isMobile to true (stubbing Node's
built-ins to null) but leaves Platform.isDesktopApp true — so gating Agent Mode
on isDesktopApp still imported the @/agentMode barrel, whose module-scope
`promisify(execFile)` then crashed the whole plugin with
"Cannot read properties of null (reading 'promisify')". Add isDesktopRuntime()
(Platform.isDesktopApp && !Platform.isMobile) and gate every Agent Mode
load/registration on it so the barrel is never imported on a Node-less runtime.
Update the mobile-load smoke gate rule to enforce the new gate and add a unit test.

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

* chore(lint): ban Platform.isDesktopApp; route desktop gating through isDesktopRuntime()

Platform.isDesktopApp stays true under app.emulateMobile(true) (which stubs Node),
so it doesn't keep desktop-only/Node code off the emulated-mobile path. Add a
no-restricted-properties ESLint rule banning it (the canonical check in
src/utils/desktopRuntime.ts is exempt via an inline disable), and migrate all 14
existing usages — web viewer, encryption/keychain, Miyo discovery, web-tab and
@-mention chat hooks, and main.ts's web-viewer gates — to isDesktopRuntime().
Behavior is unchanged on real desktop and mobile; only emulateMobile now faithfully
hides these desktop-only features.

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

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 14:18:30 +08: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): keep Agent Mode off the emulated-mobile load path (#2587) 2026-06-10 14:18:30 +08: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