@pi-chamber/web 1.0.1 → 1.0.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.
Files changed (58) hide show
  1. package/README.md +1 -1
  2. package/bin/lib/DOCUMENTATION.md +1 -1
  3. package/dist/assets/{DiagramView-COHSzZ9Z.js → DiagramView-C3jwAdba.js} +1 -1
  4. package/dist/assets/{DiffView-BA4LWExp.js → DiffView-CqPv7nw1.js} +1 -1
  5. package/dist/assets/{FileSaveConflictDialog-hRumcJ2e.js → FileSaveConflictDialog-BDHl1ERM.js} +1 -1
  6. package/dist/assets/{FilesView-CIx6Bq8l.js → FilesView-DjD5jjcd.js} +1 -1
  7. package/dist/assets/{GitView-3Hgk_pVS.js → GitView-D_TzczhS.js} +3 -3
  8. package/dist/assets/{JsonTreeView-CVLGj7jk.js → JsonTreeView-BTMtZylb.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl-CWeQW9_O.js → MarkdownRendererImpl-DnZhLsfY.js} +1 -1
  10. package/dist/assets/{PatchDiff-367QPDDL.js → PatchDiff-D4jQKTZA.js} +1 -1
  11. package/dist/assets/{SessionSwitcherContent-CbgywSHr.js → SessionSwitcherContent-BX6P7l8U.js} +1 -1
  12. package/dist/assets/{SessionSwitcherDropdown-BAHhqkBZ.js → SessionSwitcherDropdown-DGvRKfRw.js} +2 -2
  13. package/dist/assets/{SessionUnreadDot-CvIWGgIi.js → SessionUnreadDot-CPTTyo0r.js} +1 -1
  14. package/dist/assets/{SettingsView-BpGtnBKt.js → SettingsView-CD0EfMno.js} +2 -2
  15. package/dist/assets/{SettingsWindow-CN0wm-Fv.js → SettingsWindow-MrdvHysy.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-Bkh0DWJn.js → ToolOutputDialog-9UTlcthG.js} +1 -1
  17. package/dist/assets/{ToolPartDiffPreview-C_V9k2ob.js → ToolPartDiffPreview-D_HifNve.js} +1 -1
  18. package/dist/assets/{VirtualizedFileDiff-CFToyUp4.js → VirtualizedFileDiff-CvqZNzUR.js} +1 -1
  19. package/dist/assets/{collapsible-BXBoS1M4.js → collapsible-BencOwkW.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-BpbB2xiE.js → computeVirtualFileMetrics-B1Zc3P5v.js} +1 -1
  21. package/dist/assets/{contextFileOpenGuard-DsdrIBIY.js → contextFileOpenGuard-CJZHfvjH.js} +1 -1
  22. package/dist/assets/{gitStatusPredicates-KYx0Vs9h.js → gitStatusPredicates-C7tetvAB.js} +1 -1
  23. package/dist/assets/{index-DyeT2dc_.js → index-CpSdU-d4.js} +4 -4
  24. package/dist/assets/{index-CVZfC79h.js → index-DYXaDVnz.js} +1 -1
  25. package/dist/assets/index-Dwz16owi.css +1 -0
  26. package/dist/assets/{isDiffPlainText-dBQiDlRy.js → isDiffPlainText-DMMH-XmY.js} +1 -1
  27. package/dist/assets/{isFilePlainText-DWMzO-Ms.js → isFilePlainText-DcCgFOGI.js} +1 -1
  28. package/dist/assets/{main-DukaBOy3.js → main-BZu7VLeY.js} +2 -2
  29. package/dist/assets/{main-DkXvFwTR.js → main-DvtT25LM.js} +3 -3
  30. package/dist/assets/{markdownCore-BH61OrJ2.js → markdownCore-D6HZ46BO.js} +1 -1
  31. package/dist/assets/{miniChat-B1uBoxSn.js → miniChat-CLS1HbGi.js} +2 -2
  32. package/dist/assets/{mobile-DV_RYy3x.js → mobile-BuCJ5Obm.js} +2 -2
  33. package/dist/assets/{renderElectronMiniChatApp-CA6co_Lh.js → renderElectronMiniChatApp-BtREv0kE.js} +2 -2
  34. package/dist/assets/{renderMobileApp-CyhFZ_4g.js → renderMobileApp-UF8ITb8A.js} +3 -3
  35. package/dist/assets/runtimeEndpointReset-BcdDES-U.js +53 -0
  36. package/dist/assets/{runtimeSurface-CxbVCK7k.js → runtimeSurface-Bm6cRkok.js} +1 -1
  37. package/dist/assets/{useAppFontEffects-HCEusnq7.js → useAppFontEffects-SHxBpd4f.js} +34 -34
  38. package/dist/assets/{useFilesViewSearch-Cq7IOB7l.js → useFilesViewSearch-CJ6yYAoc.js} +1 -1
  39. package/dist/assets/{usePushVisibilityBeacon-Tvi9uL7v.js → usePushVisibilityBeacon-mnTxlkQZ.js} +1 -1
  40. package/dist/assets/{useSwitcherItems-DLA7kskG.js → useSwitcherItems-DWUNXYMV.js} +1 -1
  41. package/dist/assets/{vendor-codemirror-language-data-zF3O85ti.js → vendor-codemirror-language-data-B4enwgcI.js} +2 -2
  42. package/dist/assets/{web-components-C7g3Hi85.js → web-components-ldhQxnFE.js} +1 -1
  43. package/dist/index.html +4 -4
  44. package/dist/mini-chat.html +3 -3
  45. package/dist/mobile.html +3 -3
  46. package/package.json +1 -1
  47. package/server/index.js +10 -2
  48. package/server/lib/package-manager.js +3 -2
  49. package/server/lib/package-manager.test.js +7 -2
  50. package/server/lib/pi/routes.test.js +24 -0
  51. package/server/lib/pi/ui-settings-store.js +12 -0
  52. package/server/lib/pi/ui-settings-store.test.js +47 -1
  53. package/server/lib/server/core-routes.js +18 -0
  54. package/server/lib/server/linux-distribution.js +47 -0
  55. package/server/lib/server/linux-distribution.test.js +22 -0
  56. package/server/lib/server/tunnel-service.DOCUMENTATION.md +1 -1
  57. package/dist/assets/index-Ci9OMaKW.css +0 -1
  58. package/dist/assets/runtimeEndpointReset-CVoKFaRw.js +0 -53
@@ -501,9 +501,11 @@ describe('update capability reporting', () => {
501
501
  };
502
502
 
503
503
  it('gives deployment-specific instructions for containers and source checkouts', () => {
504
- expect(getUpdateCapability({ isContainer: true })).toMatchObject({
504
+ expect(getUpdateCapability({ isContainer: true })).toEqual({
505
505
  supported: false,
506
506
  code: 'DOCKER_DEPLOYMENT',
507
+ error: 'PiChamber is running in a container and cannot replace its own image. In the directory with your compose file, pull the newer image and recreate the container. Config, sessions, SSH keys, and workspaces persist in the mounted volumes.',
508
+ commands: ['docker compose pull', 'docker compose up -d'],
507
509
  });
508
510
  expect(getUpdateCapability({
509
511
  isContainer: false,
@@ -674,7 +676,10 @@ describe('launchUpdateCommand', () => {
674
676
  });
675
677
 
676
678
  it('refuses container replacement without creating a job', async () => {
677
- await expect(launchUpdateCommand({ isContainer: true })).resolves.toMatchObject({ success: false });
679
+ await expect(launchUpdateCommand({ isContainer: true })).resolves.toEqual({
680
+ success: false,
681
+ error: 'Docker deployments must be updated by pulling a new image and recreating the container.',
682
+ });
678
683
  });
679
684
  });
680
685
 
@@ -233,6 +233,30 @@ describe('Pi runtime route', () => {
233
233
  });
234
234
  });
235
235
 
236
+ it('returns compose pull commands when the server is a Docker deployment', async () => {
237
+ const app = express();
238
+ registerPiRuntimeRoutes(app, {
239
+ getPiSessionDaemonRuntime: () => null,
240
+ updateCapabilityResolver: () => ({
241
+ supported: false,
242
+ code: 'DOCKER_DEPLOYMENT',
243
+ error: 'Pull the newer image and recreate the container.',
244
+ commands: ['docker compose pull', 'docker compose up -d'],
245
+ }),
246
+ updateLauncher: () => { throw new Error('must not run'); },
247
+ });
248
+ server = await listen(app);
249
+
250
+ const response = await fetch(`http://127.0.0.1:${server.address().port}/api/pi/update-install`, { method: 'POST' });
251
+ expect(response.status).toBe(409);
252
+ await expect(response.json()).resolves.toEqual({
253
+ success: false,
254
+ code: 'DOCKER_DEPLOYMENT',
255
+ error: 'Pull the newer image and recreate the container.',
256
+ commands: ['docker compose pull', 'docker compose up -d'],
257
+ });
258
+ });
259
+
236
260
  it('generates a task name with the configured small model without exposing model details', async () => {
237
261
  const calls = [];
238
262
  const app = express();
@@ -8,6 +8,7 @@ import { withCrossProcessLock } from '../server/cross-process-lock.js';
8
8
  const MAX_SETTINGS_BYTES = 2 * 1024 * 1024;
9
9
  const PORTABLE_SETTINGS_MARKER = '__pichamberSettingsScope';
10
10
  const PORTABLE_SETTINGS_VERSION = 'portable-v1';
11
+ const DOCKER_WORKSPACE = '/home/pichamber/workspaces';
11
12
 
12
13
  // Keep this list explicit. settings.json is intended to be copied between hosts.
13
14
  // Retired keys are intentionally absent so saved values cannot restore retired
@@ -104,6 +105,14 @@ const readRecord = async (file, fs) => {
104
105
  }
105
106
  };
106
107
 
108
+ export const createDockerInitialLocalSettings = () => {
109
+ const projectId = `path_${Buffer.from(DOCKER_WORKSPACE).toString('base64url')}`;
110
+ return {
111
+ projects: [{ id: projectId, path: DOCKER_WORKSPACE, label: 'Workspaces' }],
112
+ activeProjectId: projectId,
113
+ };
114
+ };
115
+
107
116
  const writeRecord = async (file, value, fs) => {
108
117
  const serialized = `${JSON.stringify(value, null, 2)}\n`;
109
118
  if (Buffer.byteLength(serialized) > MAX_SETTINGS_BYTES) throw new Error('UI_SETTINGS_INVALID');
@@ -118,6 +127,7 @@ const writeRecord = async (file, value, fs) => {
118
127
  export const createPiUiSettingsStore = ({
119
128
  file = join(resolvePiChamberDataDir(), 'settings.json'),
120
129
  runtimeFile = join(dirname(file), 'runtime-state.json'),
130
+ initialLocalSettings = {},
121
131
  fs = { chmod, mkdir, readFile, rename, writeFile },
122
132
  } = {}) => {
123
133
  let mutation = Promise.resolve();
@@ -128,7 +138,9 @@ export const createPiUiSettingsStore = ({
128
138
  const migrated = portableRoot[PORTABLE_SETTINGS_MARKER] === PORTABLE_SETTINGS_VERSION;
129
139
 
130
140
  if (!migrated) {
141
+ const isFreshStore = Object.keys(portableRoot).length === 0 && Object.keys(runtimeRoot).length === 0;
131
142
  const migratedRuntime = {
143
+ ...(isFreshStore ? selectFields(validateRecord(initialLocalSettings), LOCAL_FIELDS) : {}),
132
144
  ...selectFields(runtimeRoot, LOCAL_FIELDS),
133
145
  ...selectFields(portableRoot, LOCAL_FIELDS),
134
146
  };
@@ -3,7 +3,7 @@ import { mkdtemp, readFile, writeFile } from 'node:fs/promises';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
 
6
- import { createPiUiSettingsStore } from './ui-settings-store.js';
6
+ import { createDockerInitialLocalSettings, createPiUiSettingsStore } from './ui-settings-store.js';
7
7
 
8
8
  const makeStore = async () => {
9
9
  const root = await mkdtemp(join(tmpdir(), 'pichamber-ui-settings-'));
@@ -22,6 +22,52 @@ describe('Pi UI settings store', () => {
22
22
  await expect(store.read()).rejects.toThrow('UI_SETTINGS_INVALID');
23
23
  });
24
24
 
25
+ it('builds Docker initial settings with a stable path-derived project id', async () => {
26
+ const initialLocalSettings = createDockerInitialLocalSettings();
27
+ expect(initialLocalSettings).toEqual({
28
+ projects: [{
29
+ id: 'path_L2hvbWUvcGljaGFtYmVyL3dvcmtzcGFjZXM',
30
+ path: '/home/pichamber/workspaces',
31
+ label: 'Workspaces',
32
+ }],
33
+ activeProjectId: 'path_L2hvbWUvcGljaGFtYmVyL3dvcmtzcGFjZXM',
34
+ });
35
+
36
+ const root = await mkdtemp(join(tmpdir(), 'pichamber-ui-settings-'));
37
+ const store = createPiUiSettingsStore({
38
+ file: join(root, 'settings.json'),
39
+ runtimeFile: join(root, 'runtime-state.json'),
40
+ initialLocalSettings,
41
+ });
42
+ await expect(store.read()).resolves.toMatchObject(initialLocalSettings);
43
+ });
44
+
45
+ it('seeds initial local settings only for a fresh store', async () => {
46
+ const root = await mkdtemp(join(tmpdir(), 'pichamber-ui-settings-'));
47
+ const file = join(root, 'settings.json');
48
+ const runtimeFile = join(root, 'runtime-state.json');
49
+ const initialLocalSettings = {
50
+ projects: [{ id: 'workspaces', path: '/home/pichamber/workspaces', label: 'Workspaces' }],
51
+ activeProjectId: 'workspaces',
52
+ };
53
+ const store = createPiUiSettingsStore({ file, runtimeFile, initialLocalSettings });
54
+
55
+ await expect(store.read()).resolves.toMatchObject(initialLocalSettings);
56
+ await store.write({ projects: [], activeProjectId: null });
57
+ await expect(store.read()).resolves.toMatchObject({ projects: [], activeProjectId: null });
58
+
59
+ const existingRoot = await mkdtemp(join(tmpdir(), 'pichamber-ui-settings-'));
60
+ const existingFile = join(existingRoot, 'settings.json');
61
+ const existingRuntimeFile = join(existingRoot, 'runtime-state.json');
62
+ await writeFile(existingFile, JSON.stringify({ themeId: 'nord' }));
63
+ const existingStore = createPiUiSettingsStore({
64
+ file: existingFile,
65
+ runtimeFile: existingRuntimeFile,
66
+ initialLocalSettings,
67
+ });
68
+ await expect(existingStore.read()).resolves.toEqual({ themeId: 'nord' });
69
+ });
70
+
25
71
  it('migrates a flat settings file into portable and local allowlists', async () => {
26
72
  const { file, runtimeFile, store } = await makeStore();
27
73
  await writeFile(file, JSON.stringify({
@@ -64,6 +64,15 @@ export const registerServerStatusRoutes = (app, dependencies) => {
64
64
  process,
65
65
  pichamberVersion,
66
66
  runtimeName,
67
+ // Server origin metadata, reported verbatim on /health and /api/version
68
+ // so clients can adapt without probing. deploymentKind is 'docker' for
69
+ // the container image and 'host' otherwise; serverPlatform is
70
+ // process.platform ('linux', 'darwin', 'win32'); serverDistribution is
71
+ // the Linux distribution id (e.g. 'debian', 'nixos') or null when
72
+ // unknown or not Linux.
73
+ deploymentKind = 'host',
74
+ serverPlatform = 'unknown',
75
+ serverDistribution = null,
67
76
  serverStartedAt,
68
77
  gracefulShutdown,
69
78
  getHealthSnapshot,
@@ -245,6 +254,9 @@ export const registerServerStatusRoutes = (app, dependencies) => {
245
254
  timestamp: new Date().toISOString(),
246
255
  pichamberVersion,
247
256
  runtime: runtimeName,
257
+ deploymentKind,
258
+ serverPlatform,
259
+ ...(serverDistribution ? { serverDistribution } : {}),
248
260
  compatibility,
249
261
  ...(serverId ? { serverId } : {}),
250
262
  ...getHealthSnapshot(),
@@ -257,6 +269,9 @@ export const registerServerStatusRoutes = (app, dependencies) => {
257
269
  status: 'ok',
258
270
  pichamberVersion,
259
271
  runtime: runtimeName,
272
+ deploymentKind,
273
+ serverPlatform,
274
+ ...(serverDistribution ? { serverDistribution } : {}),
260
275
  startedAt: serverStartedAt,
261
276
  compatibility,
262
277
  ...(serverId ? { serverId } : {}),
@@ -360,6 +375,9 @@ export const registerServerStatusRoutes = (app, dependencies) => {
360
375
  res.json({
361
376
  pichamberVersion,
362
377
  runtime: runtimeName,
378
+ deploymentKind,
379
+ serverPlatform,
380
+ ...(serverDistribution ? { serverDistribution } : {}),
363
381
  pid: process.pid,
364
382
  startedAt: serverStartedAt,
365
383
  port: getServerPort(),
@@ -0,0 +1,47 @@
1
+ import { readFileSync } from 'node:fs';
2
+
3
+ const KNOWN_DISTRIBUTIONS = new Set(['ubuntu', 'arch', 'nixos', 'fedora', 'debian', 'centos']);
4
+
5
+ const DISTRIBUTION_ALIASES = new Map([
6
+ ['archlinux', 'arch'],
7
+ ['endeavouros', 'arch'],
8
+ ['manjaro', 'arch'],
9
+ ['pop', 'ubuntu'],
10
+ ['linuxmint', 'ubuntu'],
11
+ ['elementary', 'ubuntu'],
12
+ ['rhel', 'fedora'],
13
+ ['rocky', 'centos'],
14
+ ['almalinux', 'centos'],
15
+ ]);
16
+
17
+ const normalizeDistribution = (value) => {
18
+ const id = String(value || '').trim().toLowerCase();
19
+ return KNOWN_DISTRIBUTIONS.has(id) ? id : DISTRIBUTION_ALIASES.get(id) || null;
20
+ };
21
+
22
+ export const parseLinuxDistribution = (content) => {
23
+ const values = new Map();
24
+ for (const line of String(content || '').split(/\r?\n/)) {
25
+ const match = /^([A-Z_]+)=(.*)$/.exec(line.trim());
26
+ if (!match) continue;
27
+ const raw = match[2].trim();
28
+ values.set(match[1], raw.replace(/^(["'])(.*)\1$/, '$2'));
29
+ }
30
+
31
+ const direct = normalizeDistribution(values.get('ID'));
32
+ if (direct) return direct;
33
+ for (const related of String(values.get('ID_LIKE') || '').split(/\s+/)) {
34
+ const normalized = normalizeDistribution(related);
35
+ if (normalized) return normalized;
36
+ }
37
+ return null;
38
+ };
39
+
40
+ export const detectLinuxDistribution = ({ platform = process.platform, readFile = readFileSync } = {}) => {
41
+ if (platform !== 'linux') return null;
42
+ try {
43
+ return parseLinuxDistribution(readFile('/etc/os-release', 'utf8'));
44
+ } catch {
45
+ return null;
46
+ }
47
+ };
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { detectLinuxDistribution, parseLinuxDistribution } from './linux-distribution.js';
4
+
5
+ describe('Linux distribution detection', () => {
6
+ it('reads known distribution IDs and aliases', () => {
7
+ expect(parseLinuxDistribution('ID=ubuntu\n')).toBe('ubuntu');
8
+ expect(parseLinuxDistribution('ID="archlinux"\n')).toBe('arch');
9
+ expect(parseLinuxDistribution('ID=nixos\n')).toBe('nixos');
10
+ expect(parseLinuxDistribution('ID=fedora\n')).toBe('fedora');
11
+ });
12
+
13
+ it('uses ID_LIKE for recognized derivatives', () => {
14
+ expect(parseLinuxDistribution('ID=custom\nID_LIKE="debian ubuntu"\n')).toBe('debian');
15
+ });
16
+
17
+ it('returns null for unknown, unavailable, and non-Linux systems', () => {
18
+ expect(parseLinuxDistribution('ID=gentoo\n')).toBeNull();
19
+ expect(detectLinuxDistribution({ platform: 'win32' })).toBeNull();
20
+ expect(detectLinuxDistribution({ platform: 'linux', readFile: () => { throw new Error('missing'); } })).toBeNull();
21
+ });
22
+ });
@@ -57,7 +57,7 @@ The PiChamber `pichamber.service` itself already supports both user (`~/.config/
57
57
 
58
58
  ## Upgrade considerations
59
59
 
60
- `pichamber update` detects the owning package manager, upgrades the global package, and restarts the relevant systemd service (`systemctl --user restart pichamber.service` or `systemctl restart pichamber.service` when running as root). The tunnel token file and PiChamber `pi/settings.json` sidecar are preserved across upgrades because they live under `PICHAMBER_DATA_DIR` (or `~/.pichamber`), not in the package directory. A Docker deployment is not upgraded in-place; it must be redeployed via `docker pull`.
60
+ `pichamber update` detects the owning package manager, upgrades the global package, and restarts the relevant systemd service (`systemctl --user restart pichamber.service` or `systemctl restart pichamber.service` when running as root). The tunnel token file and PiChamber `pi/settings.json` sidecar are preserved across upgrades because they live under `PICHAMBER_DATA_DIR` (or `~/.pichamber`), not in the package directory. A Docker deployment is not upgraded in-place; pull a newer image and recreate the container (`docker compose pull` then `docker compose up -d`) so volume-mounted config and tunnel tokens survive.
61
61
 
62
62
  ## Testing
63
63