Template tests / tests (pull_request) Failing after 33s
Phase 3 groundwork of the improvement plan (PR 7 of the sequence). The Linux
work is a platform rewrite, so this first establishes the interface boundary
and moves an OS-specific piece behind it with Windows behavior preserved — no
new process.platform branches in shared code.
- app/platform/index.js is the single factory that selects a platform
implementation; shared code asks it for adapters and never inspects
process.platform itself.
- app/platform/interfaces.js documents the adapter contracts
(WindowContextProvider, ClickSource, PowerPolicy) and the explicit click-
source vocabulary.
- Extracted the foreground-window/element detection into per-OS adapters,
verbatim from text-intel.js:
app/platform/windows/window-context.js (PowerShell UIAutomation)
app/platform/linux/window-context.js (xprop)
app/platform/darwin/window-context.js (AppleScript)
text-intel.js now delegates to the injected provider and its three
platform-branching methods (and the now-dead child_process import) are gone.
- app/platform/linux/diagnostics.js detects session type, portal/PipeWire,
xinput, readable input devices, and the resulting click/screen-capture
profile, returning actionable messages for the UI. Exposed via a new
platform:capabilities IPC + preload method.
This is behavior-preserving: the Windows/macOS/Linux window-context code is
the same, just relocated behind the factory, and the capture pipeline is
untouched.
Tests: platform selection for every OS, provider validity + null-object for
unsupported OS, the shared service delegating to an injected provider, Linux
capability detection (x11/xinput, Wayland-without-PipeWire messaging, no-click
fallback, evdev), the capability facade, and a guard that text-intel no longer
branches on process.platform. 268 unit tests pass; startup smoke passes and
the click self-test is unchanged (stream source, markers 3/3, burst 8/8).
Co-Authored-By: Claude Fable 5 <[email protected]>
115 lines
3.6 KiB
JavaScript
115 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
/**
|
|
* The complete privileged API exposed to the sandboxed renderer. Every call
|
|
* is an explicit invoke; no raw ipcRenderer or Node access leaks through.
|
|
*/
|
|
|
|
const invoke = (channel) => (args) => ipcRenderer.invoke(channel, args);
|
|
|
|
const api = {
|
|
library: {
|
|
list: invoke('library:list'),
|
|
create: invoke('library:create'),
|
|
duplicate: invoke('library:duplicate'),
|
|
delete: invoke('library:delete'),
|
|
setFavorite: invoke('library:setFavorite'),
|
|
trashList: invoke('library:trash:list'),
|
|
trashRestore: invoke('library:trash:restore'),
|
|
trashPurge: invoke('library:trash:purge'),
|
|
},
|
|
folders: {
|
|
create: invoke('folders:create'),
|
|
rename: invoke('folders:rename'),
|
|
delete: invoke('folders:delete'),
|
|
moveGuide: invoke('folders:moveGuide'),
|
|
},
|
|
guide: {
|
|
get: invoke('guide:get'),
|
|
save: invoke('guide:save'),
|
|
},
|
|
step: {
|
|
add: invoke('step:add'),
|
|
save: invoke('step:save'),
|
|
delete: invoke('step:delete'),
|
|
restore: invoke('step:restore'),
|
|
reorder: invoke('steps:reorder'),
|
|
imagePath: invoke('step:imagePath'),
|
|
setWorkingImage: invoke('step:setWorkingImage'),
|
|
resetWorkingImage: invoke('step:resetWorkingImage'),
|
|
fromClipboard: invoke('step:fromClipboard'),
|
|
importImage: invoke('step:importImage'),
|
|
},
|
|
search: {
|
|
query: invoke('search:query'),
|
|
titles: invoke('search:titles'),
|
|
},
|
|
settings: {
|
|
all: invoke('settings:all'),
|
|
set: invoke('settings:set'),
|
|
globalPlaceholders: invoke('placeholders:globals:get'),
|
|
setGlobalPlaceholders: invoke('placeholders:globals:set'),
|
|
},
|
|
ai: {
|
|
test: invoke('ai:test'),
|
|
fillStep: invoke('ai:fillStep'),
|
|
rewriteText: invoke('ai:rewriteText'),
|
|
cancel: invoke('ai:cancel'),
|
|
},
|
|
capture: {
|
|
shoot: invoke('capture:shoot'),
|
|
region: invoke('capture:region'),
|
|
session: invoke('capture:session'),
|
|
state: invoke('capture:state'),
|
|
onAdded: (fn) => ipcRenderer.on('capture:added', (e, payload) => fn(payload)),
|
|
onState: (fn) => ipcRenderer.on('capture:state', (e, payload) => fn(payload)),
|
|
onStepUpdated: (fn) => ipcRenderer.on('step:updated', (e, payload) => fn(payload)),
|
|
},
|
|
archive: {
|
|
export: invoke('archive:export'),
|
|
open: invoke('archive:open'),
|
|
saveLinked: invoke('archive:saveLinked'),
|
|
},
|
|
snapshots: {
|
|
list: invoke('snapshots:list'),
|
|
create: invoke('snapshots:create'),
|
|
restore: invoke('snapshots:restore'),
|
|
},
|
|
recovery: {
|
|
status: invoke('recovery:status'),
|
|
},
|
|
templates: {
|
|
list: invoke('templates:list'),
|
|
load: invoke('templates:load'),
|
|
save: invoke('templates:save'),
|
|
delete: invoke('templates:delete'),
|
|
rename: invoke('templates:rename'),
|
|
duplicate: invoke('templates:duplicate'),
|
|
export: invoke('templates:export'),
|
|
import: invoke('templates:import'),
|
|
},
|
|
export: {
|
|
formats: invoke('export:formats'),
|
|
defaults: invoke('export:defaults'),
|
|
run: invoke('export:run'),
|
|
chooseDir: invoke('export:chooseDir'),
|
|
preview: invoke('export:preview'),
|
|
cleanupPreviews: invoke('preview:cleanup'),
|
|
},
|
|
shell: {
|
|
// Intent-specific shell access only: files the main process produced,
|
|
// the guide's linked archive, and scheme-validated external links.
|
|
openProduced: invoke('shell:openProduced'),
|
|
revealLinkedArchive: invoke('shell:revealLinkedArchive'),
|
|
openExternal: invoke('shell:openExternal'),
|
|
},
|
|
app: {
|
|
info: invoke('app:info'),
|
|
platformCapabilities: invoke('platform:capabilities'),
|
|
},
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld('stepforge', api);
|