@pi-chamber/web 0.7.1 → 0.7.2
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/README.md +2 -1
- package/bin/cli.js +2 -2
- package/bin/cli.test.js +98 -1
- package/bin/lib/DOCUMENTATION.md +2 -1
- package/bin/lib/cli-args.js +8 -5
- package/bin/lib/cli-startup.js +10 -7
- package/bin/lib/cli-startup.test.js +28 -0
- package/bin/lib/commands-startup.js +152 -6
- package/dist/assets/{CommitSection-DuGkZ_bm.js → CommitSection-DfAlM30E.js} +1 -1
- package/dist/assets/{DiagramEditor-C7xe1Brl.js → DiagramEditor-TeJ1G_NN.js} +1 -1
- package/dist/assets/{DiagramView-BTqROEWP.js → DiagramView-DKLIwNth.js} +1 -1
- package/dist/assets/{DiffView-hcqXTjEc.js → DiffView-CZyqSs5W.js} +1 -1
- package/dist/assets/{FilesView-GadyKxta.js → FilesView-rftA7fEL.js} +1 -1
- package/dist/assets/{GitView-BKy-hYUN.js → GitView-D5LMTT2M.js} +3 -3
- package/dist/assets/{JsonTreeView-CGc4eTGI.js → JsonTreeView-DMI3-Smy.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CqfEAhPM.js → MarkdownRendererImpl-gdd-5n9J.js} +1 -1
- package/dist/assets/{PatchDiff-P17-Byb8.js → PatchDiff-GNB1NlAN.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BbUCO4IF.js → PierreDiffViewer-DmJv2AoJ.js} +1 -1
- package/dist/assets/{SessionSwitcherContent-j6KFBSe0.js → SessionSwitcherContent-CWdDPll7.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-DSVeuuVL.js → SessionSwitcherDropdown-Cx-Jfmvo.js} +2 -2
- package/dist/assets/{SessionUnreadDot-BVBBEBTg.js → SessionUnreadDot-CKe4uVcf.js} +1 -1
- package/dist/assets/{SettingsView-FnmtcWZc.js → SettingsView-DaxkNy5C.js} +3 -3
- package/dist/assets/{SettingsWindow-Bascj0V3.js → SettingsWindow-D1M_rRDo.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CPMzJ27S.js → ToolOutputDialog-CUKcp77A.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-BZSRKHHM.js → ToolPartDiffPreview-CkzwXAC5.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-DFx8xsmh.js → VirtualizedFileDiff-sRc4lN0B.js} +1 -1
- package/dist/assets/{WindowsWindowControls-DIqnZ2uU.js → WindowsWindowControls-CCnU0ckO.js} +121 -121
- package/dist/assets/{collapsible-DlqZyxEY.js → collapsible-B0cIItyf.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-elCbdk6U.js → computeVirtualFileMetrics-B1uVA58l.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-BmQ7Zu-L.js → contextFileOpenGuard-BuedQ5EQ.js} +1 -1
- package/dist/assets/{index-BerHSX92.js → index-BA67uOfZ.js} +1 -1
- package/dist/assets/index-CcbDTf8Q.js +8 -0
- package/dist/assets/index-Cl3XbCeC.css +1 -0
- package/dist/assets/{isDiffPlainText-CvfRfc7h.js → isDiffPlainText-DLDFLL6P.js} +1 -1
- package/dist/assets/{isFilePlainText-_vq9Ghu3.js → isFilePlainText-B2wwrpRU.js} +1 -1
- package/dist/assets/{main-DYs-nZO6.js → main-B5k0qpHJ.js} +4 -4
- package/dist/assets/{main-DTCOwPr3.js → main-Bepu8Jr9.js} +2 -2
- package/dist/assets/{markdownCore-CzWR_p3k.js → markdownCore-BfuFM7mg.js} +1 -1
- package/dist/assets/{miniChat-C2XxEA3N.js → miniChat-Co0Snpgl.js} +2 -2
- package/dist/assets/{mobile-BQhAOqV7.js → mobile-CSvL_Zyu.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-M2bY1WKA.js → renderElectronMiniChatApp-DrMJ1RXX.js} +2 -2
- package/dist/assets/{renderMobileApp-BnpHUUhY.js → renderMobileApp-B2toAnMW.js} +4 -4
- package/dist/assets/{runtimeSurface-OhCUGSKg.js → runtimeSurface-DF3VwUlO.js} +1 -1
- package/dist/assets/{useInlineCommentController-DC0iNSYX.js → useInlineCommentController-CxMP78jg.js} +1 -1
- package/dist/assets/{usePanelSlide-aeAIo1cp.js → usePanelSlide-DUuoQt5X.js} +3 -3
- package/dist/assets/{usePushVisibilityBeacon-om5Qlrt6.js → usePushVisibilityBeacon-CSPdFBaA.js} +1 -1
- package/dist/assets/{useSwitcherItems-Bln2r_Q2.js → useSwitcherItems-zOeC2Cta.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Dv4zaHRN.js → vendor-codemirror-language-data-C7_BPMCr.js} +2 -2
- package/dist/assets/{web-components-BOt08OHk.js → web-components-BYNCGylQ.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/package-manager.js +32 -1
- package/server/lib/package-manager.test.js +21 -0
- package/server/lib/pi/attachment-store.js +95 -22
- package/server/lib/pi/attachment-store.test.js +23 -0
- package/server/lib/pi/routes.js +120 -43
- package/server/lib/pi/routes.test.js +63 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +2 -0
- package/server/lib/pi/session-daemon/session-daemon.js +7 -0
- package/dist/assets/index-ChFxkws4.js +0 -8
- package/dist/assets/index-DZ-f_hCQ.css +0 -1
package/README.md
CHANGED
|
@@ -22,7 +22,8 @@ Use `--api-only` for a host intended to be paired from a PiChamber desktop or mo
|
|
|
22
22
|
## Runtime contract
|
|
23
23
|
|
|
24
24
|
- Pi session state and actions are served only through `/api/pi/*`.
|
|
25
|
-
-
|
|
25
|
+
- `POST /api/pi/attachments` accepts raw `application/octet-stream` bodies with bounded `X-PiChamber-Filename` and `X-PiChamber-Mime` metadata. It returns opaque attachment metadata plus `expiresAt`; filesystem paths remain private. The legacy base64 JSON body remains available for persisted clients. `DELETE /api/pi/attachments/:id` removes an unused upload. Prompt routes accept at most 20 attachment IDs and retire accepted uploads from the active 32-upload map while retaining their files until the one-hour expiry.
|
|
26
|
+
- PiChamber-owned UI settings, custom themes, and updates use `/api/pi/ui-settings`, `/api/pi/themes`, `/api/pi/update-check`, and `/api/pi/update-install`; removed `/api/config/*` and `/api/pichamber/*` aliases are not required.
|
|
26
27
|
- Final-only speech-to-text uses authenticated `/api/stt/*` routes and `/api/stt/ws`. Local model inference runs in a forked worker, while remote provider credentials remain in server configuration.
|
|
27
28
|
- Browser and paired clients authenticate with UI sessions or scoped client credentials.
|
|
28
29
|
- `connect-url` creates a one-time pairing link; credentials are not written to URLs or logs.
|
package/bin/cli.js
CHANGED
|
@@ -195,7 +195,7 @@ async function main() {
|
|
|
195
195
|
const { command, subcommand, tunnelAction, startupAction, options, removedFlagErrors, helpRequested, versionRequested } = parsed;
|
|
196
196
|
activeCommandOptions = options;
|
|
197
197
|
|
|
198
|
-
if (versionRequested) {
|
|
198
|
+
if (versionRequested || command === 'version') {
|
|
199
199
|
if (isJsonMode(options)) {
|
|
200
200
|
printJson({ version: PACKAGE_JSON.version });
|
|
201
201
|
} else {
|
|
@@ -245,7 +245,7 @@ async function main() {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
if (!commands[command]) {
|
|
248
|
-
const knownCommands = ['serve', 'stop', 'restart', 'status', 'tunnel', 'startup', 'logs', 'update'];
|
|
248
|
+
const knownCommands = ['serve', 'stop', 'restart', 'status', 'tunnel', 'startup', 'logs', 'update', 'version'];
|
|
249
249
|
const suggestion = findClosestMatch(command, knownCommands);
|
|
250
250
|
const hint = suggestion ? ` Did you mean '${suggestion}'?` : '';
|
|
251
251
|
if (isJsonMode(options)) {
|
package/bin/cli.test.js
CHANGED
|
@@ -4,7 +4,7 @@ import os from 'os';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { createServer } from 'http';
|
|
6
6
|
import net from 'net';
|
|
7
|
-
import { spawn } from 'child_process';
|
|
7
|
+
import { spawn, spawnSync } from 'child_process';
|
|
8
8
|
import { pathToFileURL } from 'url';
|
|
9
9
|
|
|
10
10
|
import { isModuleCliExecution, normalizeCliEntryPath } from './cli-entry.js';
|
|
@@ -331,6 +331,79 @@ describe('cli args', () => {
|
|
|
331
331
|
});
|
|
332
332
|
|
|
333
333
|
describe('startup enable command helper', () => {
|
|
334
|
+
it('collects LAN, port, and generated-password choices interactively', async () => {
|
|
335
|
+
const { collectInteractiveStartupOptions } = await import('./lib/commands-startup.js');
|
|
336
|
+
const answers = ['lan', '8080', 'generate', true];
|
|
337
|
+
const prompts = {
|
|
338
|
+
select: async () => answers.shift(),
|
|
339
|
+
text: async () => answers.shift(),
|
|
340
|
+
password: async () => answers.shift(),
|
|
341
|
+
confirm: async () => answers.shift(),
|
|
342
|
+
isCancel: () => false,
|
|
343
|
+
cancel: () => {},
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const result = await collectInteractiveStartupOptions({ port: 3000 }, prompts);
|
|
347
|
+
|
|
348
|
+
expect(result).toMatchObject({
|
|
349
|
+
host: '0.0.0.0',
|
|
350
|
+
lan: true,
|
|
351
|
+
port: 8080,
|
|
352
|
+
explicitPort: true,
|
|
353
|
+
uiPassword: '',
|
|
354
|
+
explicitUiPassword: true,
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('collects and confirms a user-entered password', async () => {
|
|
359
|
+
const { collectInteractiveStartupOptions } = await import('./lib/commands-startup.js');
|
|
360
|
+
const answers = ['local', '3000', 'enter', 'secret', 'secret', true];
|
|
361
|
+
const prompts = {
|
|
362
|
+
select: async () => answers.shift(),
|
|
363
|
+
text: async () => answers.shift(),
|
|
364
|
+
password: async () => answers.shift(),
|
|
365
|
+
confirm: async () => answers.shift(),
|
|
366
|
+
isCancel: () => false,
|
|
367
|
+
cancel: () => {},
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const result = await collectInteractiveStartupOptions({ port: 3000 }, prompts);
|
|
371
|
+
|
|
372
|
+
expect(result).toMatchObject({
|
|
373
|
+
port: 3000,
|
|
374
|
+
uiPassword: 'secret',
|
|
375
|
+
explicitUiPassword: true,
|
|
376
|
+
});
|
|
377
|
+
expect(result.host).toBe('127.0.0.1');
|
|
378
|
+
expect(result.lan).toBe(false);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('cancels interactive setup without returning service options', async () => {
|
|
382
|
+
const { collectInteractiveStartupOptions } = await import('./lib/commands-startup.js');
|
|
383
|
+
const cancelled = Symbol('cancelled');
|
|
384
|
+
let cancellationMessage = '';
|
|
385
|
+
const prompts = {
|
|
386
|
+
select: async () => cancelled,
|
|
387
|
+
text: async () => '',
|
|
388
|
+
password: async () => '',
|
|
389
|
+
confirm: async () => false,
|
|
390
|
+
isCancel: (value) => value === cancelled,
|
|
391
|
+
cancel: (message) => { cancellationMessage = message; },
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
await expect(collectInteractiveStartupOptions({ port: 3000 }, prompts)).resolves.toBeNull();
|
|
395
|
+
expect(cancellationMessage).toBe('Startup setup cancelled.');
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('keeps flag-driven startup enable non-interactive', async () => {
|
|
399
|
+
const { hasExplicitStartupConfiguration } = await import('./lib/commands-startup.js');
|
|
400
|
+
|
|
401
|
+
expect(hasExplicitStartupConfiguration({ explicitPort: true })).toBe(true);
|
|
402
|
+
expect(hasExplicitStartupConfiguration({ lan: true })).toBe(true);
|
|
403
|
+
expect(hasExplicitStartupConfiguration({ explicitUiPassword: true })).toBe(true);
|
|
404
|
+
expect(hasExplicitStartupConfiguration({ port: 3000 })).toBe(false);
|
|
405
|
+
});
|
|
406
|
+
|
|
334
407
|
it('formats stored serve flags for a local port', async () => {
|
|
335
408
|
const { formatStartupServeCommand } = await import('./lib/cli-startup.js');
|
|
336
409
|
expect(formatStartupServeCommand({ port: 8080 })).toBe('pichamber serve --foreground --port 8080');
|
|
@@ -367,6 +440,30 @@ describe('startup enable command helper', () => {
|
|
|
367
440
|
});
|
|
368
441
|
});
|
|
369
442
|
|
|
443
|
+
describe('version command', () => {
|
|
444
|
+
it('prints the installed package version', () => {
|
|
445
|
+
const packageJson = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
446
|
+
const result = spawnSync(process.execPath, [new URL('./cli.js', import.meta.url).pathname, 'version'], {
|
|
447
|
+
encoding: 'utf8',
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
expect(result.status).toBe(0);
|
|
451
|
+
expect(result.stdout.trim()).toBe(packageJson.version);
|
|
452
|
+
expect(result.stderr).toBe('');
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('prints the installed package version as JSON', () => {
|
|
456
|
+
const packageJson = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
457
|
+
const result = spawnSync(process.execPath, [new URL('./cli.js', import.meta.url).pathname, 'version', '--json'], {
|
|
458
|
+
encoding: 'utf8',
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
expect(result.status).toBe(0);
|
|
462
|
+
expect(JSON.parse(result.stdout)).toMatchObject({ status: 'ok', version: packageJson.version });
|
|
463
|
+
expect(result.stderr).toBe('');
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
|
|
370
467
|
describe('cli API target resolution', () => {
|
|
371
468
|
it('uses an explicit port without discovery', async () => {
|
|
372
469
|
await expect(resolveTargetPort(
|
package/bin/lib/DOCUMENTATION.md
CHANGED
|
@@ -8,8 +8,9 @@ This directory contains non-entrypoint PiChamber CLI implementation. `../cli.js`
|
|
|
8
8
|
- `commands-lifecycle.js`: stop and restart behavior.
|
|
9
9
|
- `commands-status.js`: running-instance and tunnel status presentation.
|
|
10
10
|
- `commands-logs.js`: log discovery, tailing, and follow behavior.
|
|
11
|
-
- `commands-startup.js`: native startup service management. `startup enable` stores serve flags (`--port`, `--lan`/`--host`, `--ui-password`, `--api-only`) in the
|
|
11
|
+
- `commands-startup.js`: native startup service management. Interactive `startup enable` walks through access, port, authentication, and confirmation when no setup flags are supplied. Flag-driven, non-TTY, `--quiet`, and `--json` runs remain non-interactive. The command stores serve flags (`--port`, `--lan`/`--host`, `--ui-password`, `--api-only`) in the native service. Re-running enable rewrites and restarts a systemd unit so the new settings take effect immediately. LAN binds require a UI password, matching `pichamber serve`.
|
|
12
12
|
- `commands-connect-url.js`: authenticated direct/relay pairing links.
|
|
13
|
+
- `pichamber version` and `pichamber --version`: print the installed package version; `--json` returns the same value as JSON.
|
|
13
14
|
- `commands-update.js`: package update and restart coordination. Updates only a global install owned by the running CLI. A Linux user systemd unit is restarted in place; the command does not spawn a replacement server on the same port.
|
|
14
15
|
- `commands-tunnel.js`: tunnel lifecycle and profile management.
|
|
15
16
|
|
package/bin/lib/cli-args.js
CHANGED
|
@@ -492,6 +492,7 @@ COMMANDS:
|
|
|
492
492
|
logs Tail PiChamber logs
|
|
493
493
|
connect-url Generate URL/QR for connecting another client
|
|
494
494
|
update Check for and install updates
|
|
495
|
+
version Show the installed PiChamber version
|
|
495
496
|
|
|
496
497
|
OPTIONS:
|
|
497
498
|
-p, --port Web server port (default: ${DEFAULT_PORT})
|
|
@@ -526,6 +527,7 @@ EXAMPLES:
|
|
|
526
527
|
# Login service on LAN at 0.0.0.0:3002
|
|
527
528
|
pichamber tunnel help # Show tunnel lifecycle help
|
|
528
529
|
pichamber logs # Follow logs for latest running instance
|
|
530
|
+
pichamber version # Show the installed version
|
|
529
531
|
`);
|
|
530
532
|
}
|
|
531
533
|
|
|
@@ -537,14 +539,15 @@ USAGE:
|
|
|
537
539
|
pichamber startup <SUBCOMMAND> [OPTIONS]
|
|
538
540
|
|
|
539
541
|
DESCRIPTION:
|
|
540
|
-
Installs a
|
|
541
|
-
|
|
542
|
-
|
|
542
|
+
Installs a native startup service that runs pichamber serve --foreground.
|
|
543
|
+
In an interactive terminal, enable walks through access, port, and password
|
|
544
|
+
setup. Supplied flags keep the command non-interactive. Re-run enable to
|
|
545
|
+
replace the stored command.
|
|
543
546
|
|
|
544
547
|
SUBCOMMANDS:
|
|
545
548
|
status Show startup integration status
|
|
546
|
-
enable
|
|
547
|
-
disable Stop and remove native
|
|
549
|
+
enable Configure, install, and start native startup integration
|
|
550
|
+
disable Stop and remove native startup integration
|
|
548
551
|
|
|
549
552
|
ENABLE FLAGS:
|
|
550
553
|
These become the serve command the login service runs.
|
package/bin/lib/cli-startup.js
CHANGED
|
@@ -317,6 +317,14 @@ function runStartupCommand(command, args, options = {}) {
|
|
|
317
317
|
return result;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
function activateSystemdStartupService(isRoot, run = runStartupCommand) {
|
|
321
|
+
const userArgs = isRoot ? [] : ['--user'];
|
|
322
|
+
run('systemctl', [...userArgs, 'daemon-reload']);
|
|
323
|
+
run('systemctl', [...userArgs, 'enable', 'pichamber.service']);
|
|
324
|
+
// restart also starts an inactive unit and guarantees rewritten settings take effect.
|
|
325
|
+
run('systemctl', [...userArgs, 'restart', 'pichamber.service']);
|
|
326
|
+
}
|
|
327
|
+
|
|
320
328
|
function getStartupStatus() {
|
|
321
329
|
const paths = getStartupServicePaths();
|
|
322
330
|
if (!paths.servicePath) {
|
|
@@ -389,13 +397,7 @@ function enableStartupService(options = {}) {
|
|
|
389
397
|
writeStartupEnvFile(serveOptions, { quoteValue: systemdEnvFileQuote });
|
|
390
398
|
fs.mkdirSync(path.dirname(paths.servicePath), { recursive: true, mode: 0o700 });
|
|
391
399
|
fs.writeFileSync(paths.servicePath, buildSystemdUserService(serveOptions), { mode: 0o600 });
|
|
392
|
-
|
|
393
|
-
runStartupCommand('systemctl', ['daemon-reload']);
|
|
394
|
-
runStartupCommand('systemctl', ['enable', '--now', 'pichamber.service']);
|
|
395
|
-
} else {
|
|
396
|
-
runStartupCommand('systemctl', ['--user', 'daemon-reload']);
|
|
397
|
-
runStartupCommand('systemctl', ['--user', 'enable', '--now', 'pichamber.service']);
|
|
398
|
-
}
|
|
400
|
+
activateSystemdStartupService(isRoot);
|
|
399
401
|
return finish(getStartupStatus());
|
|
400
402
|
}
|
|
401
403
|
|
|
@@ -453,6 +455,7 @@ function disableStartupService() {
|
|
|
453
455
|
|
|
454
456
|
export {
|
|
455
457
|
getStartupServicePaths,
|
|
458
|
+
activateSystemdStartupService,
|
|
456
459
|
getStartupStatus,
|
|
457
460
|
enableStartupService,
|
|
458
461
|
disableStartupService,
|
|
@@ -4,6 +4,34 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { mkdtempSync, rmSync } from 'node:fs';
|
|
6
6
|
|
|
7
|
+
describe('systemd startup activation', () => {
|
|
8
|
+
it('enables and restarts a system service so updated settings take effect', async () => {
|
|
9
|
+
const { activateSystemdStartupService } = await import('./cli-startup.js');
|
|
10
|
+
const calls = [];
|
|
11
|
+
|
|
12
|
+
activateSystemdStartupService(true, (command, args) => calls.push([command, args]));
|
|
13
|
+
|
|
14
|
+
expect(calls).toEqual([
|
|
15
|
+
['systemctl', ['daemon-reload']],
|
|
16
|
+
['systemctl', ['enable', 'pichamber.service']],
|
|
17
|
+
['systemctl', ['restart', 'pichamber.service']],
|
|
18
|
+
]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('enables and restarts a user service so updated settings take effect', async () => {
|
|
22
|
+
const { activateSystemdStartupService } = await import('./cli-startup.js');
|
|
23
|
+
const calls = [];
|
|
24
|
+
|
|
25
|
+
activateSystemdStartupService(false, (command, args) => calls.push([command, args]));
|
|
26
|
+
|
|
27
|
+
expect(calls).toEqual([
|
|
28
|
+
['systemctl', ['--user', 'daemon-reload']],
|
|
29
|
+
['systemctl', ['--user', 'enable', 'pichamber.service']],
|
|
30
|
+
['systemctl', ['--user', 'restart', 'pichamber.service']],
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
7
35
|
describe('startup service paths', () => {
|
|
8
36
|
const originalPlatform = process.platform;
|
|
9
37
|
const originalGetuid = process.getuid;
|
|
@@ -1,14 +1,150 @@
|
|
|
1
1
|
import { EXIT_CODE, TunnelCliError } from './cli-errors.js';
|
|
2
|
-
import { getStartupStatus, enableStartupService, disableStartupService, formatStartupServeCommand } from './cli-startup.js';
|
|
2
|
+
import { getStartupStatus, enableStartupService, disableStartupService, formatStartupServeCommand, getStartupServicePaths } from './cli-startup.js';
|
|
3
|
+
import { hasUiPasswordConfigured } from './cli-network.js';
|
|
3
4
|
import {
|
|
4
5
|
intro as clackIntro,
|
|
5
6
|
outro as clackOutro,
|
|
7
|
+
cancel as clackCancel,
|
|
8
|
+
isCancel,
|
|
9
|
+
select,
|
|
10
|
+
text,
|
|
11
|
+
password as passwordPrompt,
|
|
12
|
+
confirm,
|
|
13
|
+
canPrompt,
|
|
6
14
|
isJsonMode,
|
|
7
15
|
isQuietMode,
|
|
8
16
|
printJson,
|
|
9
17
|
logStatus,
|
|
10
18
|
} from '../cli-output.js';
|
|
11
19
|
|
|
20
|
+
const promptApi = { select, text, password: passwordPrompt, confirm, isCancel, cancel: clackCancel };
|
|
21
|
+
|
|
22
|
+
function validatePort(value) {
|
|
23
|
+
const normalized = String(value ?? '').trim();
|
|
24
|
+
if (!/^\d+$/.test(normalized)) return 'Enter a port between 1 and 65535.';
|
|
25
|
+
const port = Number(normalized);
|
|
26
|
+
return port >= 1 && port <= 65535 ? undefined : 'Enter a port between 1 and 65535.';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function hasExplicitStartupConfiguration(options) {
|
|
30
|
+
return options.explicitPort === true
|
|
31
|
+
|| options.lan === true
|
|
32
|
+
|| typeof options.host === 'string'
|
|
33
|
+
|| options.explicitUiPassword === true
|
|
34
|
+
|| options.apiOnly === true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function collectInteractiveStartupOptions(options, prompts = promptApi) {
|
|
38
|
+
const ask = async (method, config) => {
|
|
39
|
+
const answer = await prompts[method](config);
|
|
40
|
+
if (prompts.isCancel(answer)) {
|
|
41
|
+
prompts.cancel('Startup setup cancelled.');
|
|
42
|
+
return { cancelled: true };
|
|
43
|
+
}
|
|
44
|
+
return { answer };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const accessResult = await ask('select', {
|
|
48
|
+
message: 'Where should PiChamber be accessible?',
|
|
49
|
+
options: [
|
|
50
|
+
{ value: 'local', label: 'This machine only', hint: 'recommended' },
|
|
51
|
+
{ value: 'lan', label: 'Local network', hint: 'other devices on your LAN or Wi-Fi' },
|
|
52
|
+
{ value: 'custom', label: 'Custom bind address' },
|
|
53
|
+
],
|
|
54
|
+
initialValue: 'local',
|
|
55
|
+
});
|
|
56
|
+
if (accessResult.cancelled) return null;
|
|
57
|
+
|
|
58
|
+
let host = '127.0.0.1';
|
|
59
|
+
let lan = false;
|
|
60
|
+
if (accessResult.answer === 'lan') {
|
|
61
|
+
host = '0.0.0.0';
|
|
62
|
+
lan = true;
|
|
63
|
+
} else if (accessResult.answer === 'custom') {
|
|
64
|
+
const hostResult = await ask('text', {
|
|
65
|
+
message: 'Bind address',
|
|
66
|
+
placeholder: '127.0.0.1',
|
|
67
|
+
initialValue: '127.0.0.1',
|
|
68
|
+
validate: (value) => String(value ?? '').trim().length > 0 ? undefined : 'Enter a bind address.',
|
|
69
|
+
});
|
|
70
|
+
if (hostResult.cancelled) return null;
|
|
71
|
+
host = String(hostResult.answer).trim();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const portResult = await ask('text', {
|
|
75
|
+
message: 'Port',
|
|
76
|
+
initialValue: String(options.port),
|
|
77
|
+
validate: validatePort,
|
|
78
|
+
});
|
|
79
|
+
if (portResult.cancelled) return null;
|
|
80
|
+
const port = Number(String(portResult.answer).trim());
|
|
81
|
+
|
|
82
|
+
const networkExposed = accessResult.answer !== 'local';
|
|
83
|
+
const configuredPassword = hasUiPasswordConfigured(options.uiPassword);
|
|
84
|
+
const authOptions = [
|
|
85
|
+
...(configuredPassword ? [{ value: 'configured', label: 'Use the configured password' }] : []),
|
|
86
|
+
{ value: 'enter', label: 'Enter a password' },
|
|
87
|
+
{ value: 'generate', label: 'Generate a secure password' },
|
|
88
|
+
...(!networkExposed && !configuredPassword ? [{ value: 'none', label: 'No password', hint: 'local access only' }] : []),
|
|
89
|
+
];
|
|
90
|
+
const authResult = await ask('select', {
|
|
91
|
+
message: networkExposed ? 'Choose a required UI password' : 'Protect the UI with a password?',
|
|
92
|
+
options: authOptions,
|
|
93
|
+
initialValue: configuredPassword ? 'configured' : (networkExposed ? 'generate' : 'none'),
|
|
94
|
+
});
|
|
95
|
+
if (authResult.cancelled) return null;
|
|
96
|
+
|
|
97
|
+
let uiPassword = configuredPassword ? options.uiPassword : undefined;
|
|
98
|
+
let explicitUiPassword = false;
|
|
99
|
+
if (authResult.answer === 'enter') {
|
|
100
|
+
const passwordResult = await ask('password', {
|
|
101
|
+
message: 'UI password',
|
|
102
|
+
validate: (value) => String(value ?? '').length > 0 ? undefined : 'Enter a password.',
|
|
103
|
+
});
|
|
104
|
+
if (passwordResult.cancelled) return null;
|
|
105
|
+
uiPassword = String(passwordResult.answer);
|
|
106
|
+
const confirmationResult = await ask('password', {
|
|
107
|
+
message: 'Confirm UI password',
|
|
108
|
+
validate: (value) => value === uiPassword ? undefined : 'Passwords do not match.',
|
|
109
|
+
});
|
|
110
|
+
if (confirmationResult.cancelled) return null;
|
|
111
|
+
explicitUiPassword = true;
|
|
112
|
+
} else if (authResult.answer === 'generate') {
|
|
113
|
+
uiPassword = '';
|
|
114
|
+
explicitUiPassword = true;
|
|
115
|
+
} else if (authResult.answer === 'none') {
|
|
116
|
+
uiPassword = undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const paths = getStartupServicePaths();
|
|
120
|
+
logStatus('info', 'Review startup service', [
|
|
121
|
+
`Access: ${accessResult.answer === 'local' ? 'this machine only' : host}`,
|
|
122
|
+
`Port: ${port}`,
|
|
123
|
+
`Authentication: ${authResult.answer === 'none' ? 'disabled' : authResult.answer === 'generate' ? 'generated password' : 'enabled'}`,
|
|
124
|
+
`Service: ${paths.scope === 'system' ? 'system' : paths.scope === 'user' ? 'user' : paths.platform}`,
|
|
125
|
+
].join('\n'));
|
|
126
|
+
|
|
127
|
+
const confirmResult = await ask('confirm', {
|
|
128
|
+
message: 'Install and start this service?',
|
|
129
|
+
initialValue: true,
|
|
130
|
+
});
|
|
131
|
+
if (confirmResult.cancelled) return null;
|
|
132
|
+
if (confirmResult.answer !== true) {
|
|
133
|
+
prompts.cancel('Startup setup cancelled.');
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
...options,
|
|
139
|
+
port,
|
|
140
|
+
explicitPort: true,
|
|
141
|
+
host,
|
|
142
|
+
lan,
|
|
143
|
+
uiPassword,
|
|
144
|
+
explicitUiPassword,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
12
148
|
async function startupCommand(options, action = 'status') {
|
|
13
149
|
const normalized = typeof action === 'string' ? action.trim().toLowerCase() : 'status';
|
|
14
150
|
if (!['status', 'enable', 'disable'].includes(normalized)) {
|
|
@@ -18,9 +154,16 @@ async function startupCommand(options, action = 'status') {
|
|
|
18
154
|
);
|
|
19
155
|
}
|
|
20
156
|
|
|
157
|
+
let resolvedOptions = options;
|
|
158
|
+
if (normalized === 'enable' && canPrompt(options) && !hasExplicitStartupConfiguration(options)) {
|
|
159
|
+
clackIntro('PiChamber Startup Setup');
|
|
160
|
+
resolvedOptions = await collectInteractiveStartupOptions(options);
|
|
161
|
+
if (!resolvedOptions) return;
|
|
162
|
+
}
|
|
163
|
+
|
|
21
164
|
let status;
|
|
22
165
|
if (normalized === 'enable') {
|
|
23
|
-
status = enableStartupService(
|
|
166
|
+
status = enableStartupService(resolvedOptions);
|
|
24
167
|
} else if (normalized === 'disable') {
|
|
25
168
|
status = disableStartupService();
|
|
26
169
|
} else {
|
|
@@ -32,7 +175,7 @@ async function startupCommand(options, action = 'status') {
|
|
|
32
175
|
: undefined;
|
|
33
176
|
const { generatedUiPassword: _generatedUiPassword, ...publicStatus } = status;
|
|
34
177
|
void _generatedUiPassword;
|
|
35
|
-
const serveCommand = normalized === 'enable' ? formatStartupServeCommand(
|
|
178
|
+
const serveCommand = normalized === 'enable' ? formatStartupServeCommand(resolvedOptions) : undefined;
|
|
36
179
|
const result = {
|
|
37
180
|
action: normalized,
|
|
38
181
|
...publicStatus,
|
|
@@ -46,8 +189,11 @@ async function startupCommand(options, action = 'status') {
|
|
|
46
189
|
);
|
|
47
190
|
}
|
|
48
191
|
if (normalized === 'enable' && result.activeState === 'failed') {
|
|
192
|
+
const journalCommand = result.scope === 'system'
|
|
193
|
+
? 'journalctl -u pichamber.service -n 80 --no-pager'
|
|
194
|
+
: 'journalctl --user -u pichamber.service -n 80 --no-pager';
|
|
49
195
|
throw new TunnelCliError(
|
|
50
|
-
|
|
196
|
+
`Startup service was installed but failed to start. Run \`${journalCommand}\` for details.`,
|
|
51
197
|
EXIT_CODE.GENERAL_ERROR
|
|
52
198
|
);
|
|
53
199
|
}
|
|
@@ -61,7 +207,7 @@ async function startupCommand(options, action = 'status') {
|
|
|
61
207
|
return;
|
|
62
208
|
}
|
|
63
209
|
|
|
64
|
-
clackIntro('PiChamber Startup');
|
|
210
|
+
if (resolvedOptions === options) clackIntro('PiChamber Startup');
|
|
65
211
|
logStatus(result.enabled ? 'success' : 'info', `startup ${result.enabled ? 'enabled' : 'disabled'}`, result.servicePath || undefined);
|
|
66
212
|
if (typeof result.activeState === 'string') {
|
|
67
213
|
logStatus(result.active ? 'success' : result.activeState === 'failed' ? 'error' : 'warning', `service ${result.activeState}`);
|
|
@@ -76,4 +222,4 @@ async function startupCommand(options, action = 'status') {
|
|
|
76
222
|
clackOutro(normalized === 'status' ? 'status complete' : `${normalized} complete`);
|
|
77
223
|
}
|
|
78
224
|
|
|
79
|
-
export { startupCommand };
|
|
225
|
+
export { startupCommand, collectInteractiveStartupOptions, hasExplicitStartupConfiguration, validatePort };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as C,j as e}from"./vendor-react-DYyjh7Q0.js";import{T as y,l as _,B as c,I as a,m as v,aJ as z}from"./WindowsWindowControls-
|
|
1
|
+
import{R as C,j as e}from"./vendor-react-DYyjh7Q0.js";import{T as y,l as _,B as c,I as a,m as v,aJ as z}from"./WindowsWindowControls-CCnU0ckO.js";import{u as I,m as H}from"./index-CcbDTf8Q.js";const N=38,h=200,k=({value:t,onChange:o,placeholder:m,disabled:i=!1,hasTouchInput:r=!1,isMobile:u=!1})=>{const n=C.useRef(null),j=I(s=>s.inputSpellcheckEnabled);return C.useLayoutEffect(()=>{const s=n.current;if(!s)return;const l=document.activeElement===s,d=()=>{s.style.height=`${N}px`;const p=s.scrollHeight,x=Math.min(Math.max(p,N),h);s.style.height=`${x}px`,s.style.overflowY=p>h?"auto":"hidden",p>h&&!l&&(s.scrollTop=s.scrollHeight)};d();const f=window.requestAnimationFrame(d);return()=>{window.cancelAnimationFrame(f)}},[t]),e.jsx("textarea",{ref:n,value:t,onChange:s=>o(s.target.value),placeholder:m??"Commit message",rows:1,disabled:i,autoCorrect:r?"on":"off",autoCapitalize:r?"sentences":"off",spellCheck:u||j,className:H("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i&&"opacity-50"),style:{minHeight:N,maxHeight:h}})},F=({highlights:t,onInsert:o})=>{if(t.length===0)return null;const m=()=>{o(t)};return e.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Highlights"}),e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":"Insert aria label",children:e.jsx(a,{name:"arrow-down",className:"size-4"})})}),e.jsx(v,{sideOffset:8,children:"Insert tooltip"})]})]}),e.jsx("ul",{className:"space-y-1",children:t.map((i,r)=>e.jsx("li",{className:"typography-meta text-foreground",children:i},`${i}-${r}`))})]})},q=({stagedCount:t,commitMessage:o,onCommitMessageChange:m,generatedHighlights:i,onInsertHighlights:r,onGenerateMessage:u,isGeneratingMessage:n,onCommit:j,onCommitAndPush:s,commitAction:l,hasPendingIndexMutation:d=!1,gitmojiEnabled:f,onOpenGitmojiPicker:p})=>{const x=t>0,b=o.trim()&&x&&l===null&&!d,{isMobile:g,hasTouchInput:w}=z();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),x?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(F,{highlights:i,onInsert:r}),e.jsx(k,{value:o,onChange:m,placeholder:"Commit message",disabled:l!==null,hasTouchInput:w,isMobile:g}),f&&e.jsxs(c,{variant:"outline",size:"sm",onClick:p,className:"w-fit",type:"button",children:[e.jsx(a,{name:"emotion-happy",className:"size-4"}),"Add gitmoji"]}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:u,disabled:n||l!==null||d||t===0,type:"button","aria-label":"Generate commit message",className:"commit-actions__btn",children:[n?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"ai-generate-2",className:"size-4 text-primary"}),e.jsx("span",{className:"commit-actions__label",children:"Generate"})]}),e.jsx("div",{className:"flex-1"}),e.jsx(c,{size:"sm",variant:"outline",onClick:j,disabled:!b||n,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:l==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),g?e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"default",size:"sm",onClick:()=>s(),disabled:!b||n,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(v,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(c,{size:"sm",variant:"default",onClick:()=>s(),disabled:!b||n,className:"commit-actions__btn","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})};export{q as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,j as h}from"./vendor-react-DYyjh7Q0.js";import{D as E}from"./vendor-react-drawio-Boqanm0j.js";import{m as x}from"./index-
|
|
1
|
+
import{R as e,j as h}from"./vendor-react-DYyjh7Q0.js";import{D as E}from"./vendor-react-drawio-Boqanm0j.js";import{m as x}from"./index-CcbDTf8Q.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as r,j as t}from"./vendor-react-DYyjh7Q0.js";import{u as a}from"./index-
|
|
1
|
+
import{R as r,j as t}from"./vendor-react-DYyjh7Q0.js";import{u as a}from"./index-CcbDTf8Q.js";import{w as v,I as m}from"./WindowsWindowControls-CCnU0ckO.js";import{D as j}from"./DiagramEditor-TeJ1G_NN.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-DL8r2fgQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./runtimeSurface-DF3VwUlO.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C7_BPMCr.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-CW8w438f.js";import"./vendor-react-drawio-Boqanm0j.js";function Kt(){const{files:o}=v(),[e,d]=r.useState(null),[s,p]=r.useState(""),[x,n]=r.useState(!0),l=r.useRef(null),c=a(i=>i.pendingDiagramFile),u=r.useCallback(async i=>{n(!0),d(i);try{const f=await o?.readFile?.(i);f&&p(f.content)}catch{p("")}finally{n(!1)}},[o]);r.useEffect(()=>{if(!c)return;const i=a.getState().consumePendingDiagramFile();i&&u(i)},[u,c]);const g=r.useCallback(async()=>{const i=l.current?.getXml();e&&o?.writeFile&&i&&i!==s&&(await o.writeFile(e,i),p(i))},[e,o,s]),h=e?e.split("/").pop()||e:"";return e?x?t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[t.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:h}),t.jsx("button",{type:"button",onClick:()=>{g()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:t.jsx(m,{name:"save-3",className:"size-4"})}),t.jsx("button",{type:"button",onClick:()=>a.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:t.jsx(m,{name:"close",className:"size-4"})})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(j,{ref:l,xml:s,className:"h-full"})})]}):t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{Kt as DiagramView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as o,j as n}from"./vendor-react-DYyjh7Q0.js";import{u as _,a as ut,m as B}from"./index-
|
|
1
|
+
import{R as o,j as n}from"./vendor-react-DYyjh7Q0.js";import{u as _,a as ut,m as B}from"./index-CcbDTf8Q.js";import{cQ as Bt,cR as Wt,cS as Ot,w as dt,x as zt,aJ as Gt,z as Ht,y as Ut,A as Vt,C as Q,g as Kt,av as qt,cT as Xt,cU as Qt,aQ as Jt,N as ve,t as ft,B as Ne,I as A,T as Yt,l as Zt,m as en,cV as mt,cP as tn,am as nn,an as sn,ao as rn,cW as on,cX as je,ar as pt,F as ht,M as an}from"./WindowsWindowControls-CCnU0ckO.js";import{P as ln}from"./PierreDiffViewer-DmJv2AoJ.js";import{v as cn,g as un}from"./contextFileOpenGuard-BuedQ5EQ.js";import{p as dn}from"./VirtualizedFileDiff-sRc4lN0B.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-base-ui-DL8r2fgQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./runtimeSurface-DF3VwUlO.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-C7_BPMCr.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-CW8w438f.js";import"./web-components-BYNCGylQ.js";import"./computeVirtualFileMetrics-B1uVA58l.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./usePanelSlide-DUuoQt5X.js";import"./SessionUnreadDot-CKe4uVcf.js";import"./permissionStore-BRcQ9Jgt.js";import"./useInlineCommentController-CxMP78jg.js";import"./collapsible-B0cIItyf.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./isDiffPlainText-DLDFLL6P.js";import"./vendor-diff-C3JhlQdm.js";function fn(t,e=10){const a=[];let i;for(const u of t.split(`
|
|
2
2
|
`)){const x=u.match(Bt);if(x!=null){i!=null&&(i.hunkLines.length>0&&(Me(i,e,"trailing"),Ge(i,a)),i=void 0);const b=parseInt(x[3]),N=parseInt(x[1]),v=parseInt(x[4]??"1"),h=parseInt(x[2]??"1");isNaN(b)||isNaN(N)||isNaN(v)||isNaN(h)?a.push(u):i={additionStart:b,deletionStart:N,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){a.push(u);continue}if(u.startsWith(" "))i.contextLines.push(u);else if(u!==""){if(i.hunkLines.length>0&&i.contextLines.length>e*2){const b=i.contextLines.length-e*2,N=i.contextLines.slice(-e);Me(i,e,"trailing");const{additionCount:v,deletionCount:h}=i;Ge(i,a),i={additionStart:i.additionStart+v+b,deletionStart:i.deletionStart+h+b,deletionCount:0,additionCount:0,contextLines:N,hunkLines:[]}}Me(i,e,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(u),u.startsWith("+")?i.additionCount+=1:u.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Me(i,e,"trailing"),Ge(i,a));const c=a.join(`
|
|
3
3
|
`);return t.endsWith(`
|
|
4
4
|
`)?`${c}
|