@sirenodeck/sirenodeck 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.mjs CHANGED
@@ -7,7 +7,7 @@ import { basename, dirname, extname, isAbsolute, join, normalize, resolve, sep }
7
7
  import { Writable } from "node:stream";
8
8
  import { cancel, confirm, intro, isCancel, log, log as log$1, note, outro, select, spinner } from "@clack/prompts";
9
9
  import pino from "pino";
10
- import { chmodSync, closeSync, copyFileSync, cpSync, createWriteStream, existsSync, fchmodSync, fsyncSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
10
+ import { chmodSync, closeSync, copyFileSync, cpSync, createWriteStream, existsSync, fchmodSync, fsyncSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
11
11
  import { createHash, randomBytes } from "node:crypto";
12
12
  import { arch, homedir, hostname, networkInterfaces, platform, tmpdir, userInfo } from "node:os";
13
13
  import { getuid, platform as platform$1 } from "node:process";
@@ -328,7 +328,7 @@ const levelNameFromNumber = (level) => {
328
328
  };
329
329
  //#endregion
330
330
  //#region package.json
331
- var version$1 = "0.2.6";
331
+ var version$1 = "0.2.7";
332
332
  //#endregion
333
333
  //#region src/version.ts
334
334
  const PACKAGE_NAME = "@sirenodeck/sirenodeck";
@@ -1066,8 +1066,8 @@ const findConfigPath = (options) => {
1066
1066
  };
1067
1067
  //#endregion
1068
1068
  //#region src/cli/commands/pipeline/helpers.ts
1069
- const resolveXdgConfigHome$1 = (options) => options.xdgConfigHome ?? process.env["XDG_CONFIG_HOME"] ?? `${options.homeDir ?? homedir()}/.config`;
1070
- const resolveXdgConfigPath = (options) => resolve(resolveXdgConfigHome$1(options), XDG_CONFIG_SUBDIR, "config.yml");
1069
+ const resolveXdgConfigHome$2 = (options) => options.xdgConfigHome ?? process.env["XDG_CONFIG_HOME"] ?? `${options.homeDir ?? homedir()}/.config`;
1070
+ const resolveXdgConfigPath = (options) => resolve(resolveXdgConfigHome$2(options), XDG_CONFIG_SUBDIR, "config.yml");
1071
1071
  const resolveRunFolderConfigPath = () => resolve(getOriginalCwd(), "config.yml");
1072
1072
  const resolveConfigPath$1 = (options) => {
1073
1073
  if (options.config !== void 0) {
@@ -61206,7 +61206,6 @@ const pushBlackFrame = async (device, logger) => {
61206
61206
  try {
61207
61207
  const buf = buildBlackBuffer(device.getKeyCount());
61208
61208
  for (let i = 0; i < device.getKeyCount(); i++) await device.fillKeyBuffer(i, buf.subarray(0, 192));
61209
- await device.setBrightness(0);
61210
61209
  await new Promise((r) => setTimeout(r, 200));
61211
61210
  logger.info("black-frame: pushed");
61212
61211
  } catch (err) {
@@ -61806,6 +61805,8 @@ var RealOutputClient = class {
61806
61805
  let frontendSupervisor = null;
61807
61806
  let configUiSupervisor = null;
61808
61807
  try {
61808
+ this.deviceBrightness = opts.runtime.getBrightness();
61809
+ await device.setBrightness(this.deviceBrightness);
61809
61810
  const logoCandidates = [new URL("../assets/logo72x72.png", import.meta.url), new URL("../src/assets/logo72x72.png", import.meta.url)].map((url) => fileURLToPath(url));
61810
61811
  await pushStartupScreen({
61811
61812
  logoPath: logoCandidates.find(existsSync) ?? logoCandidates[0],
@@ -62057,6 +62058,121 @@ const selectOutputClient = (options) => {
62057
62058
  return new RealOutputClient({ xdgConfigHome: options.xdgConfigHome });
62058
62059
  };
62059
62060
  //#endregion
62061
+ //#region src/core/settings.ts
62062
+ const settingsSchema = z.object({
62063
+ brightness: z.number().int().min(10).max(100),
62064
+ activeDeck: z.string().min(1)
62065
+ }).strict();
62066
+ const DEFAULT_SETTINGS = {
62067
+ brightness: 50,
62068
+ activeDeck: "main"
62069
+ };
62070
+ const SETTINGS_DIR = "sirenodeck";
62071
+ const SETTINGS_FILE = "settings.json";
62072
+ const resolveXdgConfigHome$1 = () => process.env["XDG_CONFIG_HOME"] ?? join(homedir(), ".config");
62073
+ const resolveSettingsPath = (xdgConfigHome = resolveXdgConfigHome$1()) => {
62074
+ const dir = join(xdgConfigHome, SETTINGS_DIR);
62075
+ return join(dir, SETTINGS_FILE);
62076
+ };
62077
+ const loadSettings = (path = resolveSettingsPath(), logger) => {
62078
+ if (!existsSync(path)) return DEFAULT_SETTINGS;
62079
+ let raw;
62080
+ try {
62081
+ raw = readFileSync(path, "utf8");
62082
+ } catch (err) {
62083
+ logger?.warn({
62084
+ err,
62085
+ path
62086
+ }, "settings: read failed; using defaults");
62087
+ return DEFAULT_SETTINGS;
62088
+ }
62089
+ let parsed;
62090
+ try {
62091
+ parsed = JSON.parse(raw);
62092
+ } catch (err) {
62093
+ logger?.warn({
62094
+ err,
62095
+ path
62096
+ }, "settings: corrupt JSON; using defaults");
62097
+ return DEFAULT_SETTINGS;
62098
+ }
62099
+ const result = settingsSchema.safeParse(parsed);
62100
+ if (!result.success) {
62101
+ logger?.warn({
62102
+ err: result.error.message,
62103
+ path
62104
+ }, "settings: schema mismatch; using defaults");
62105
+ return DEFAULT_SETTINGS;
62106
+ }
62107
+ return result.data;
62108
+ };
62109
+ const atomicWriteJson = (path, data) => {
62110
+ mkdirSync(dirname(path), { recursive: true });
62111
+ const tmpPath = `${path}.${randomBytes(6).toString("hex")}.tmp`;
62112
+ const fd = openSync(tmpPath, "w", 384);
62113
+ try {
62114
+ writeSync(fd, JSON.stringify(data, null, 2));
62115
+ } finally {
62116
+ closeSync(fd);
62117
+ }
62118
+ renameSync(tmpPath, path);
62119
+ };
62120
+ const DEBOUNCE_MS = 500;
62121
+ const createSettingsStore = ({ path = resolveSettingsPath(), logger, writeJson = atomicWriteJson } = {}) => {
62122
+ let current = loadSettings(path, logger);
62123
+ let timer = null;
62124
+ let pending = false;
62125
+ const writeNow = () => {
62126
+ try {
62127
+ writeJson(path, current);
62128
+ } catch (err) {
62129
+ logger?.warn({
62130
+ err,
62131
+ path
62132
+ }, "settings: write failed");
62133
+ }
62134
+ };
62135
+ const schedule = () => {
62136
+ pending = true;
62137
+ if (timer !== null) return;
62138
+ timer = setTimeout(() => {
62139
+ timer = null;
62140
+ if (pending) {
62141
+ pending = false;
62142
+ writeNow();
62143
+ }
62144
+ }, DEBOUNCE_MS);
62145
+ };
62146
+ return {
62147
+ get: () => ({ ...current }),
62148
+ update: (partial) => {
62149
+ current = {
62150
+ ...current,
62151
+ ...partial
62152
+ };
62153
+ schedule();
62154
+ },
62155
+ flush: () => {
62156
+ if (timer !== null) {
62157
+ clearTimeout(timer);
62158
+ timer = null;
62159
+ }
62160
+ pending = false;
62161
+ writeNow();
62162
+ },
62163
+ close: () => {
62164
+ if (timer !== null) {
62165
+ clearTimeout(timer);
62166
+ timer = null;
62167
+ }
62168
+ if (pending) {
62169
+ pending = false;
62170
+ writeNow();
62171
+ }
62172
+ }
62173
+ };
62174
+ };
62175
+ //#endregion
62060
62176
  //#region src/cli/commands/addon-decks.ts
62061
62177
  const resolveTriggerProcessNames = (trigger) => {
62062
62178
  if (typeof trigger !== "object" || trigger === null) return void 0;
@@ -62702,7 +62818,7 @@ const buildRuntime = (options, loaded, keyCount, lockActive = false) => {
62702
62818
  const allDecsWithSystemButtons = injectSystemButtons(sourceDecks, keyCount, { lockActive });
62703
62819
  const { decks: allDecks, errorsByDeck } = applyConfigErrorReplacements(allDecsWithSystemButtons, config, registry, logger);
62704
62820
  const token = process.env["SIRENO_TOKEN"] ?? "";
62705
- const configUiUrl = new URL(`http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`);
62821
+ const configUiUrl = new URL(options.configUiUrl ?? `http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`);
62706
62822
  if (token.length > 0) configUiUrl.searchParams.set("token", token);
62707
62823
  configUiUrl.hash = "/config";
62708
62824
  const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString());
@@ -63055,7 +63171,7 @@ const buildExternalAddonDirs = (addonEntries, configPath, addonEntryPaths = /* @
63055
63171
  };
63056
63172
  const runPipeline = async (options) => {
63057
63173
  const { logger } = options;
63058
- const xdgConfigHome = resolveXdgConfigHome$1(options);
63174
+ const xdgConfigHome = resolveXdgConfigHome$2(options);
63059
63175
  let loadedConfig = null;
63060
63176
  let outputClient = null;
63061
63177
  let providers = null;
@@ -63077,6 +63193,8 @@ const runPipeline = async (options) => {
63077
63193
  let configWatcher = null;
63078
63194
  let outputHandle = null;
63079
63195
  let currentOutputHandle = null;
63196
+ let settingsStore = null;
63197
+ let unsubscribeBrightnessSettings = null;
63080
63198
  let unregisterSignal = null;
63081
63199
  let unregisterReload = null;
63082
63200
  let unsubscribeLockMode = null;
@@ -63090,6 +63208,10 @@ const runPipeline = async (options) => {
63090
63208
  resolveDoneForCrash = resolve;
63091
63209
  });
63092
63210
  try {
63211
+ settingsStore = createSettingsStore({
63212
+ path: resolveSettingsPath(xdgConfigHome),
63213
+ logger
63214
+ });
63093
63215
  loadedConfig = await validateAndLoadConfig(options);
63094
63216
  outputClient = selectOutputClient({
63095
63217
  emulator: options.emulator === true,
@@ -63105,8 +63227,10 @@ const runPipeline = async (options) => {
63105
63227
  decks = loaded.decks;
63106
63228
  pubSub = loaded.pubSub;
63107
63229
  runtime = loaded.runtime;
63230
+ runtime.setBrightness(settingsStore.get().brightness);
63108
63231
  methods = loaded.methods;
63109
63232
  store = loaded.store;
63233
+ unsubscribeBrightnessSettings = pubSub.subscribe("methods:adjustBrightness", ({ value }) => settingsStore?.update({ brightness: value }));
63110
63234
  providers = await startSystemProviders(options, methods);
63111
63235
  hostPolicy = createHostPolicyCoordinator({
63112
63236
  runtime,
@@ -63235,6 +63359,7 @@ const runPipeline = async (options) => {
63235
63359
  logger
63236
63360
  });
63237
63361
  addonServicesDispose = () => addonServices?.dispose();
63362
+ pubSub.publish("sireno:settings:brightness", { value: runtime.getBrightness() });
63238
63363
  for (const deck of decks) {
63239
63364
  registerDeckIcon(deck, resolverOptions, logger);
63240
63365
  registerIconForDeck(deck.buttons ?? [], resolverOptions, logger);
@@ -63281,6 +63406,7 @@ const runPipeline = async (options) => {
63281
63406
  resolveDoneForCrash();
63282
63407
  },
63283
63408
  ...options.frontendUrl !== void 0 ? { frontendUrl: options.frontendUrl } : {},
63409
+ ...options.configUiUrl !== void 0 ? { configUiUrl: options.configUiUrl } : {},
63284
63410
  ...options.port !== void 0 ? { port: options.port } : {},
63285
63411
  ...options.intervalMs !== void 0 ? { intervalMs: options.intervalMs } : {},
63286
63412
  remote: options.remote === true,
@@ -63386,6 +63512,8 @@ const runPipeline = async (options) => {
63386
63512
  });
63387
63513
  await done;
63388
63514
  } finally {
63515
+ unsubscribeBrightnessSettings?.();
63516
+ settingsStore?.close();
63389
63517
  if (unregisterSignal !== null) unregisterSignal();
63390
63518
  if (unregisterReload !== null) unregisterReload();
63391
63519
  if (bridgeSignal !== null) bridgeSignal.abort();
@@ -63418,7 +63546,7 @@ const preflight = async (options) => {
63418
63546
  await validateAndLoadConfig(options);
63419
63547
  const outputClient = selectOutputClient({
63420
63548
  emulator: options.emulator === true,
63421
- xdgConfigHome: resolveXdgConfigHome$1(options)
63549
+ xdgConfigHome: resolveXdgConfigHome$2(options)
63422
63550
  });
63423
63551
  if (outputClient.kind === "real") {
63424
63552
  if ((await outputClient.listDevices()).length === 0) throw new Error("No Stream Deck devices found. Connect a device and try again. On Linux, udev rules for vendor 0fd9 may be required — see packages/cli/src/device/linux-udev.ts for the rule file template.");
@@ -65211,6 +65339,30 @@ const saveOfferChoice = (choice) => {
65211
65339
  } catch {}
65212
65340
  };
65213
65341
  //#endregion
65342
+ //#region src/cli/install-root.ts
65343
+ /**
65344
+ * Resolve the install root of the distributed bundle:
65345
+ * <root>/sirenodeck, <root>/lib/cli/main.mjs, <root>/frontend/dist, <root>/etc/install.json
65346
+ *
65347
+ * Priority: SIRENO_INSTALL_ROOT (set by the launcher/installer) → walk up from
65348
+ * this module looking for the install markers (`etc/install.json`,
65349
+ * `frontend/dist/index.html`). Returns null in the dev checkout so callers
65350
+ * fall back to the monorepo layout.
65351
+ */
65352
+ const resolveInstallRoot = () => {
65353
+ const env = process.env["SIRENO_INSTALL_ROOT"];
65354
+ if (env !== void 0 && env.length > 0) return env;
65355
+ let dir = dirname(fileURLToPath(import.meta.url));
65356
+ for (let i = 0; i < 8; i += 1) {
65357
+ if (existsSync(join(dir, "etc", "install.json"))) return dir;
65358
+ if (existsSync(join(dir, "frontend", "dist", "index.html"))) return dir;
65359
+ const parent = dirname(dir);
65360
+ if (parent === dir) break;
65361
+ dir = parent;
65362
+ }
65363
+ return null;
65364
+ };
65365
+ //#endregion
65214
65366
  //#region src/cli/commands/start.ts
65215
65367
  const toRunOptions = (options, onChildren, onAddonsUpdate) => ({
65216
65368
  logger: options.logger,
@@ -65220,6 +65372,7 @@ const toRunOptions = (options, onChildren, onAddonsUpdate) => ({
65220
65372
  remote: options.remote,
65221
65373
  deviceModel: options.deviceModel,
65222
65374
  frontendUrl: options.frontendUrl,
65375
+ configUiUrl: options.configUiUrl,
65223
65376
  intervalMs: options.intervalMs,
65224
65377
  xdgConfigHome: options.xdgConfigHome,
65225
65378
  homeDir: options.homeDir,
@@ -65229,6 +65382,8 @@ const toRunOptions = (options, onChildren, onAddonsUpdate) => ({
65229
65382
  onAddonsUpdate
65230
65383
  });
65231
65384
  const resolveFrontendDist = () => {
65385
+ const installRoot = resolveInstallRoot();
65386
+ if (installRoot !== null) return join(installRoot, "frontend", "dist");
65232
65387
  const here = dirname(fileURLToPath(import.meta.url));
65233
65388
  return resolve(here, "../../../frontend/dist");
65234
65389
  };
@@ -65571,6 +65726,7 @@ const runInProcessSetup = async (options, logger, releaseLock) => {
65571
65726
  source: resolved.source
65572
65727
  }, `start: using config ${configPath}`);
65573
65728
  const runtimeFlags = buildRuntimeFlags(options);
65729
+ const installedFrontendUrl = resolveInstallRoot() !== null && runtimeFlags.emulator !== true ? `http://127.0.0.1:${runtimeFlags.httpPort}` : void 0;
65574
65730
  writeConfigPath(configPath);
65575
65731
  writeFlags(runtimeFlags);
65576
65732
  const allScanned = [...(await collectBuiltinAddonRegistry()).scanned];
@@ -65581,7 +65737,11 @@ const runInProcessSetup = async (options, logger, releaseLock) => {
65581
65737
  emulator: runtimeFlags.emulator,
65582
65738
  remote: runtimeFlags.remote,
65583
65739
  deviceModel: runtimeFlags.deviceModel,
65584
- httpPort: runtimeFlags.httpPort
65740
+ httpPort: runtimeFlags.httpPort,
65741
+ ...options.frontendUrl === void 0 && installedFrontendUrl !== void 0 ? {
65742
+ frontendUrl: installedFrontendUrl,
65743
+ configUiUrl: installedFrontendUrl
65744
+ } : {}
65585
65745
  }, (pids) => {
65586
65746
  writeChildren({ pids: [...pids] });
65587
65747
  logger.info({ pids }, "daemon: tracked children");
@@ -65991,7 +66151,7 @@ const tryBind = (port) => new Promise((resolve) => {
65991
66151
  cleanup(false);
65992
66152
  }
65993
66153
  });
65994
- const formatFeaturesList = (items) => ["Features", ...items.map((it) => `│ ${it.available ? color.green("✓") : color.red("✗")} ${it.name}${!it.available && it.reason ? ` — ${it.reason}` : ""}`)];
66154
+ const formatFeaturesList = (items) => ["Features", ...items.map((it) => `│ ${it.available ? color.green("✓") : color.red("✗")} ${it.name}${!it.available && it.reason ? ` — ${it.reason}` : ""}`)];
65995
66155
  const printFeaturesList = (items, write = (text) => process.stdout.write(text)) => {
65996
66156
  const lines = formatFeaturesList(items);
65997
66157
  write(`${lines.slice(1).join("\n")}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sirenodeck/sirenodeck",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "CLI for managing Elgato Stream Deck devices via a config-driven deck system.",
5
5
  "homepage": "https://deck.sireno.dev",
6
6
  "bugs": {
@@ -110,6 +110,11 @@ import {
110
110
  } from "@/outputClient"
111
111
  import type { AddonInventoryEntry } from "@/api/protocol-internal"
112
112
  import { loadDeviceConfig } from "@/util/device-config"
113
+ import {
114
+ createSettingsStore,
115
+ resolveSettingsPath,
116
+ type SettingsStore,
117
+ } from "@/core/settings"
113
118
  import {
114
119
  collectAddonDefaultButtonConfig,
115
120
  materializeAddonDecks,
@@ -163,6 +168,7 @@ export interface RunOptions {
163
168
  readonly remote?: boolean
164
169
  readonly deviceModel?: string
165
170
  readonly frontendUrl?: string
171
+ readonly configUiUrl?: string
166
172
  readonly intervalMs?: number
167
173
  readonly xdgConfigHome?: string
168
174
  readonly homeDir?: string
@@ -902,7 +908,9 @@ const buildRuntime = (
902
908
  logger,
903
909
  )
904
910
  const token = process.env["SIRENO_TOKEN"] ?? ""
905
- const configUiUrl = new URL(`http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`)
911
+ const configUiUrl = new URL(
912
+ options.configUiUrl ?? `http://127.0.0.1:${DEFAULT_CONFIG_UI_PORT}/`,
913
+ )
906
914
  if (token.length > 0) configUiUrl.searchParams.set("token", token)
907
915
  configUiUrl.hash = "/config"
908
916
  const runtimeDecks = injectConfigUiButton(allDecks, configUiUrl.toString())
@@ -1505,6 +1513,8 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
1505
1513
  let configWatcher: ConfigWatcher | null = null
1506
1514
  let outputHandle: OutputHandle | null = null
1507
1515
  let currentOutputHandle: OutputHandle | null = null
1516
+ let settingsStore: SettingsStore | null = null
1517
+ let unsubscribeBrightnessSettings: (() => void) | null = null
1508
1518
  let unregisterSignal: (() => void) | null = null
1509
1519
  let unregisterReload: (() => void) | null = null
1510
1520
  let unsubscribeLockMode: (() => void) | null = null
@@ -1521,6 +1531,10 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
1521
1531
  })
1522
1532
 
1523
1533
  try {
1534
+ settingsStore = createSettingsStore({
1535
+ path: resolveSettingsPath(xdgConfigHome),
1536
+ logger,
1537
+ })
1524
1538
  // Validate config first so a broken YAML exits before we ever touch
1525
1539
  // hardware or spawn an emulator.
1526
1540
  loadedConfig = await validateAndLoadConfig(options)
@@ -1544,8 +1558,13 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
1544
1558
  decks = loaded.decks
1545
1559
  pubSub = loaded.pubSub
1546
1560
  runtime = loaded.runtime
1561
+ runtime.setBrightness(settingsStore.get().brightness)
1547
1562
  methods = loaded.methods
1548
1563
  store = loaded.store
1564
+ unsubscribeBrightnessSettings = pubSub.subscribe<{ value: number }>(
1565
+ "methods:adjustBrightness",
1566
+ ({ value }) => settingsStore?.update({ brightness: value }),
1567
+ )
1549
1568
 
1550
1569
  providers = await startSystemProviders(options, methods)
1551
1570
  hostPolicy = createHostPolicyCoordinator({
@@ -1775,6 +1794,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
1775
1794
  logger,
1776
1795
  })
1777
1796
  addonServicesDispose = () => addonServices?.dispose()
1797
+ pubSub.publish("sireno:settings:brightness", {
1798
+ value: runtime.getBrightness(),
1799
+ })
1778
1800
 
1779
1801
  for (const deck of decks) {
1780
1802
  registerDeckIcon(deck, resolverOptions, logger)
@@ -1856,6 +1878,9 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
1856
1878
  ...(options.frontendUrl !== undefined
1857
1879
  ? { frontendUrl: options.frontendUrl }
1858
1880
  : {}),
1881
+ ...(options.configUiUrl !== undefined
1882
+ ? { configUiUrl: options.configUiUrl }
1883
+ : {}),
1859
1884
  ...(options.port !== undefined ? { port: options.port } : {}),
1860
1885
  ...(options.intervalMs !== undefined
1861
1886
  ? { intervalMs: options.intervalMs }
@@ -2082,6 +2107,8 @@ export const runPipeline = async (options: RunOptions): Promise<void> => {
2082
2107
 
2083
2108
  await done
2084
2109
  } finally {
2110
+ unsubscribeBrightnessSettings?.()
2111
+ settingsStore?.close()
2085
2112
  if (unregisterSignal !== null) unregisterSignal()
2086
2113
  if (unregisterReload !== null) unregisterReload()
2087
2114
  if (bridgeSignal !== null) bridgeSignal.abort()
@@ -75,6 +75,7 @@ import { buildStandardProbeDeps } from "@/cli/probe-deps"
75
75
  import { onboardCodingAgents } from "@/cli/coding-agents-onboarding"
76
76
  import { resolveUserPath } from "@/cli/cwd"
77
77
  import { offerConfigSkillOnFirstRun } from "@/cli/skills-first-run"
78
+ import { resolveInstallRoot } from "../install-root"
78
79
 
79
80
  export interface StartOptions {
80
81
  readonly config?: string
@@ -83,6 +84,7 @@ export interface StartOptions {
83
84
  readonly remote?: boolean
84
85
  readonly deviceModel?: string
85
86
  readonly frontendUrl?: string
87
+ readonly configUiUrl?: string
86
88
  readonly intervalMs?: number
87
89
  readonly xdgConfigHome?: string
88
90
  readonly homeDir?: string
@@ -106,6 +108,7 @@ const toRunOptions = (
106
108
  remote: options.remote,
107
109
  deviceModel: options.deviceModel,
108
110
  frontendUrl: options.frontendUrl,
111
+ configUiUrl: options.configUiUrl,
109
112
  intervalMs: options.intervalMs,
110
113
  xdgConfigHome: options.xdgConfigHome,
111
114
  homeDir: options.homeDir,
@@ -116,6 +119,8 @@ const toRunOptions = (
116
119
  })
117
120
 
118
121
  const resolveFrontendDist = (): string => {
122
+ const installRoot = resolveInstallRoot()
123
+ if (installRoot !== null) return join(installRoot, "frontend", "dist")
119
124
  const here = dirname(fileURLToPath(import.meta.url))
120
125
  return resolvePath(here, "../../../frontend/dist")
121
126
  }
@@ -590,6 +595,11 @@ const runInProcessSetup = async (
590
595
  // letting it also override a fresh invocation made one past `--emulator`
591
596
  // run force every later plain `p dev start` into emulator mode.
592
597
  const runtimeFlags = buildRuntimeFlags(options)
598
+ const installRoot = resolveInstallRoot()
599
+ const installedFrontendUrl =
600
+ installRoot !== null && runtimeFlags.emulator !== true
601
+ ? `http://127.0.0.1:${runtimeFlags.httpPort}`
602
+ : undefined
593
603
  writeConfigPath(configPath)
594
604
  writeFlags(runtimeFlags)
595
605
 
@@ -605,6 +615,13 @@ const runInProcessSetup = async (
605
615
  remote: runtimeFlags.remote,
606
616
  deviceModel: runtimeFlags.deviceModel,
607
617
  httpPort: runtimeFlags.httpPort,
618
+ ...(options.frontendUrl === undefined &&
619
+ installedFrontendUrl !== undefined
620
+ ? {
621
+ frontendUrl: installedFrontendUrl,
622
+ configUiUrl: installedFrontendUrl,
623
+ }
624
+ : {}),
608
625
  },
609
626
  (pids) => {
610
627
  writeChildren({ pids: [...pids] })
@@ -188,7 +188,7 @@ export const formatFeaturesList = (
188
188
  "Features",
189
189
  ...items.map(
190
190
  (it) =>
191
- `│ ${it.available ? color.green("✓") : color.red("✗")} ${it.name}${!it.available && it.reason ? ` — ${it.reason}` : ""}`,
191
+ `│ ${it.available ? color.green("✓") : color.red("✗")} ${it.name}${!it.available && it.reason ? ` — ${it.reason}` : ""}`,
192
192
  ),
193
193
  ]
194
194
 
@@ -34,9 +34,10 @@ const SETTINGS_FILE = "settings.json"
34
34
  const resolveXdgConfigHome = (): string =>
35
35
  process.env["XDG_CONFIG_HOME"] ?? join(homedir(), ".config")
36
36
 
37
- export const resolveSettingsPath = (): string => {
38
- const dir = join(resolveXdgConfigHome(), SETTINGS_DIR)
39
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
37
+ export const resolveSettingsPath = (
38
+ xdgConfigHome: string = resolveXdgConfigHome(),
39
+ ): string => {
40
+ const dir = join(xdgConfigHome, SETTINGS_DIR)
40
41
  return join(dir, SETTINGS_FILE)
41
42
  }
42
43
 
@@ -71,6 +72,7 @@ export const loadSettings = (
71
72
  }
72
73
 
73
74
  export const atomicWriteJson = (path: string, data: unknown): void => {
75
+ mkdirSync(dirname(path), { recursive: true })
74
76
  const tmpPath = `${path}.${randomBytes(6).toString("hex")}.tmp`
75
77
  const fd = openSync(tmpPath, "w", 0o600)
76
78
  try {
@@ -23,13 +23,8 @@ export const pushBlackFrame = async (
23
23
  for (let i = 0; i < device.getKeyCount(); i++) {
24
24
  await device.fillKeyBuffer(i, buf.subarray(0, 3 * 8 * 8))
25
25
  }
26
- // ponytail: brightness is a feature report processed synchronously by the
27
- // device firmware, so dimming to 0 is a guaranteed "off" signal even if the
28
- // queued image writes above are dropped at USB disconnect.
29
- await device.setBrightness(0)
30
- // ponytail: give the queued USB writes a moment to drain before the caller
31
- // closes the device; otherwise node-hid may flush to a closed handle and
32
- // the panel keeps the last fully-rendered frame.
26
+ // ponytail: allow queued image writes to drain before the caller closes
27
+ // the device; brightness is intentionally left unchanged.
33
28
  await new Promise<void>((r) => setTimeout(r, 200))
34
29
  logger.info("black-frame: pushed")
35
30
  } catch (err) {
@@ -147,6 +147,8 @@ export class RealOutputClient implements OutputClient {
147
147
  let configUiSupervisor: SuperviseHandle | null = null
148
148
 
149
149
  try {
150
+ this.deviceBrightness = opts.runtime.getBrightness()
151
+ await device.setBrightness(this.deviceBrightness)
150
152
  // ponytail: paint the waiting state directly to hardware before Vite or
151
153
  // Playwright starts; the deck must remain useful when its frontend is down.
152
154
  const logoCandidates = [