a0b69f8cc7
Template tests / tests (push) Successful in 1m50s
Implements the architecture change from ai_prompts/prompt3.md: - New app/click-frames.js: shared timestamped frame ring + strict click-to-frame pairing (never a frame whose grab started after the click); legacy slack behavior kept behind capture.strictClickFrames=false. - New stream capture backend (app/stream-backend.js + hidden worker window): per-display desktop media streams sampled into ring buffers and PNG-encoded entirely off the main process, so click delivery is never starved by capture work. Auto-degrades to the legacy in-process frame loop when streams cannot start or the worker stops answering. - Clicks are paired with their frame at event time (eager pairing in enqueueClickCapture); only the storing is serialized, so slow encodes cannot skew later clicks in a fast burst. - Linux watcher: restored event-time root coordinates from xinput test-xi2 and merge raw/regular twin events structurally. - Replaced the 40ms time debounce with source-aware duplicate suppression: fast legitimate clicks are never dropped. - New app/coords.js: physical-to-DIP conversion with multi-monitor and scale-factor handling; Windows keeps screenToDipPoint. - STEPFORGE_CLICK_SELFTEST end-to-end hook: 3/3 clicks become steps via the stream backend with 0.00% marker offset on this host. - Tests rewritten/added: strict selection, coords, stream backend, Linux coordinate parsing, twin merge, burst clicking (126 passing). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('node:path');
|
|
const { writeJsonSync, readJsonIfExists, deepClone } = require('./util');
|
|
|
|
const DEFAULT_SETTINGS = {
|
|
schemaVersion: 1,
|
|
appearance: 'system', // system | light | dark
|
|
language: 'en',
|
|
spellcheck: true,
|
|
capture: {
|
|
delayMs: 0,
|
|
mode: 'fullscreen', // fullscreen | window | region
|
|
includeCursor: true,
|
|
clickMarker: true,
|
|
clickMarkerColor: '#E5484D',
|
|
hotkeyCapture: 'CommandOrControl+Shift+1',
|
|
hotkeyPauseResume: 'CommandOrControl+Shift+2',
|
|
captureOutsideClicks: true,
|
|
confirmSimpleCapture: false,
|
|
autoIntervalSec: 5, // session fallback when click capture is unavailable
|
|
// Strict click timing: a step never uses a frame whose grab started
|
|
// after the click. Turn off only if captures are too slow to keep a
|
|
// pre-click frame buffered (re-enables the legacy slack heuristics).
|
|
strictClickFrames: true,
|
|
// Off-main-process frame recorder (hidden worker window sampling a
|
|
// desktop media stream). Falls back to the in-process loop when false
|
|
// or when streams cannot start on this desktop.
|
|
streamCapture: true,
|
|
frameSampleMs: 100, // stream backend sampling cadence
|
|
},
|
|
editor: {
|
|
focusedViewDefaultForNewSteps: false,
|
|
autoTitleTemplate: '[[Mode]] capture [[Time]]',
|
|
},
|
|
exports: {
|
|
previewStepCount: 3,
|
|
openFolderAfterExport: true,
|
|
lastOutputDirs: {}, // format -> dir
|
|
},
|
|
library: {
|
|
sortBy: 'updatedAt',
|
|
},
|
|
backups: {
|
|
automatic: true,
|
|
keepLast: 10,
|
|
everyNSaves: 25,
|
|
},
|
|
};
|
|
|
|
class Settings {
|
|
constructor(settingsDir) {
|
|
this.file = path.join(settingsDir, 'app-settings.json');
|
|
this.globalPlaceholdersFile = path.join(settingsDir, 'placeholders.json');
|
|
this.data = this.load();
|
|
}
|
|
|
|
load() {
|
|
const stored = readJsonIfExists(this.file, {});
|
|
return mergeDeep(deepClone(DEFAULT_SETTINGS), stored);
|
|
}
|
|
|
|
save() {
|
|
writeJsonSync(this.file, this.data);
|
|
return this.data;
|
|
}
|
|
|
|
get(keyPath) {
|
|
return keyPath.split('.').reduce((o, k) => (o == null ? undefined : o[k]), this.data);
|
|
}
|
|
|
|
set(keyPath, value) {
|
|
const keys = keyPath.split('.');
|
|
let obj = this.data;
|
|
for (const k of keys.slice(0, -1)) {
|
|
if (typeof obj[k] !== 'object' || obj[k] === null) obj[k] = {};
|
|
obj = obj[k];
|
|
}
|
|
obj[keys[keys.length - 1]] = value;
|
|
return this.save();
|
|
}
|
|
|
|
getGlobalPlaceholders() {
|
|
return readJsonIfExists(this.globalPlaceholdersFile, {});
|
|
}
|
|
|
|
setGlobalPlaceholders(values) {
|
|
writeJsonSync(this.globalPlaceholdersFile, values);
|
|
return values;
|
|
}
|
|
}
|
|
|
|
function mergeDeep(base, extra) {
|
|
for (const [k, v] of Object.entries(extra || {})) {
|
|
if (v && typeof v === 'object' && !Array.isArray(v) && base[k] && typeof base[k] === 'object' && !Array.isArray(base[k])) {
|
|
mergeDeep(base[k], v);
|
|
} else {
|
|
base[k] = v;
|
|
}
|
|
}
|
|
return base;
|
|
}
|
|
|
|
module.exports = { Settings, DEFAULT_SETTINGS };
|