@openchamber/web 1.20.0 → 1.21.0

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 (119) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-C36E738Y.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
  2. package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
  3. package/dist/assets/DiffView-D5cvbEPb.js +4 -0
  4. package/dist/assets/FilesView-DPU8aNPL.js +17 -0
  5. package/dist/assets/GitView-Ct6xWrVH.js +6 -0
  6. package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-osju7J70.js} +1 -1
  7. package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
  8. package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
  9. package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
  10. package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-Dan3mADn.js} +1 -1
  11. package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
  12. package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
  13. package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
  14. package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
  15. package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
  16. package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-DrCa1JRk.js} +6 -6
  17. package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-B_tfvlNF.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
  19. package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
  20. package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
  21. package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-D9Q4lr5x.js} +2 -2
  22. package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-Gi1d5eU1.js} +2 -2
  23. package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
  24. package/dist/assets/de-B_LdJwEM.js +9 -0
  25. package/dist/assets/es-CubfsAYV.js +15 -0
  26. package/dist/assets/fr-5qJM0nFS.js +13 -0
  27. package/dist/assets/index-BW82eK5v.css +1 -0
  28. package/dist/assets/index-Brm3X9rs.js +1 -0
  29. package/dist/assets/index-rlLjZUM5.js +7 -0
  30. package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-pH9kAJQH.js} +1 -1
  31. package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-CVKy_dgB.js} +1 -1
  32. package/dist/assets/ja-DJYIBUlH.js +15 -0
  33. package/dist/assets/ko-DcUBkB7y.js +15 -0
  34. package/dist/assets/main-DLBxKIoX.js +926 -0
  35. package/dist/assets/main-vUCh0VB0.js +2 -0
  36. package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
  37. package/dist/assets/{miniChat-ldEghBLB.js → miniChat-BlzGEYgE.js} +2 -2
  38. package/dist/assets/mobile-CkX6H-IT.js +2 -0
  39. package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-BCTsE43U.js} +3 -3
  40. package/dist/assets/pl-rB6BLcio.js +15 -0
  41. package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
  42. package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
  43. package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
  44. package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
  45. package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
  46. package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-BgTPSITe.js} +1 -1
  47. package/dist/assets/uk-INZlFD9A.js +15 -0
  48. package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-Cll4gnsh.js} +170 -180
  49. package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
  50. package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-_6j2xOWl.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
  52. package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
  53. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
  54. package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
  55. package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
  56. package/dist/assets/{web-components-pcwCTWjC.js → web-components-DLnGY4fs.js} +4 -4
  57. package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
  58. package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
  59. package/dist/index.html +6 -6
  60. package/dist/mini-chat.html +5 -5
  61. package/dist/mobile.html +5 -5
  62. package/package.json +4 -4
  63. package/server/index.js +8 -0
  64. package/server/lib/client-auth/pairing.js +8 -7
  65. package/server/lib/client-auth/pairing.test.js +5 -1
  66. package/server/lib/client-auth/remote-clients.js +9 -1
  67. package/server/lib/client-auth/remote-clients.test.js +17 -0
  68. package/server/lib/github/pr-status.js +10 -1
  69. package/server/lib/quota/providers/index.js +4 -18
  70. package/server/lib/relay/DOCUMENTATION.md +1 -1
  71. package/server/lib/relay/service.js +34 -2
  72. package/server/lib/relay/service.test.js +69 -0
  73. package/server/lib/session-goal/runtime.js +2 -1
  74. package/server/lib/session-goal/runtime.test.js +4 -2
  75. package/server/lib/terminal/DOCUMENTATION.md +2 -0
  76. package/server/lib/terminal/runtime.js +29 -1
  77. package/server/lib/terminal/runtime.test.js +26 -0
  78. package/server/lib/ui-auth/ui-auth.js +2 -2
  79. package/server/lib/ui-auth/ui-auth.test.js +2 -2
  80. package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
  81. package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
  82. package/dist/assets/DiagramView-D0YNMix8.js +0 -1
  83. package/dist/assets/DiffView-BHWaMYCC.js +0 -4
  84. package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
  85. package/dist/assets/GitView-Rp8P1KEI.js +0 -6
  86. package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
  87. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
  88. package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
  89. package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
  90. package/dist/assets/PlanView-Czu1KMJa.js +0 -4
  91. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
  92. package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
  93. package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
  94. package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
  95. package/dist/assets/de-DFdX3ABv.js +0 -9
  96. package/dist/assets/es-iC-FKvV9.js +0 -15
  97. package/dist/assets/fr-BBbi_1AL.js +0 -13
  98. package/dist/assets/index-BiEgzzkg.js +0 -1
  99. package/dist/assets/index-Cwmuwk3V.js +0 -7
  100. package/dist/assets/index-GNm1wgUH.css +0 -1
  101. package/dist/assets/ja-DQLQJL2J.js +0 -15
  102. package/dist/assets/ko-BeElEB4Y.js +0 -15
  103. package/dist/assets/main-Dpzo18z7.js +0 -2
  104. package/dist/assets/main-WMjtYzJs.js +0 -921
  105. package/dist/assets/markdownCore--tDmyI_v.js +0 -2
  106. package/dist/assets/mobile-Dk-VGreF.js +0 -2
  107. package/dist/assets/pl-CLHt2_vV.js +0 -15
  108. package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
  109. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
  110. package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
  111. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
  112. package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
  113. package/dist/assets/uk-PhsC-c4-.js +0 -15
  114. package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
  115. package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
  116. package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
  117. package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
  118. package/server/lib/quota/providers/command-code.js +0 -90
  119. package/server/lib/quota/providers/command-code.test.js +0 -85
package/dist/index.html CHANGED
@@ -509,16 +509,16 @@
509
509
  pointer-events: none;
510
510
  }
511
511
  </style>
512
- <script type="module" crossorigin src="/assets/main-Dpzo18z7.js"></script>
512
+ <script type="module" crossorigin src="/assets/main-vUCh0VB0.js"></script>
513
513
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
514
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
515
- <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
516
514
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
517
515
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
518
516
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
519
- <link rel="modulepreload" crossorigin href="/assets/index-Cwmuwk3V.js">
520
- <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-BEARQjgn.js">
521
- <link rel="stylesheet" crossorigin href="/assets/index-GNm1wgUH.css">
517
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
518
+ <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
519
+ <link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
520
+ <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-CpzVNWAv.js">
521
+ <link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
522
522
  </head>
523
523
  <body class="h-full bg-background text-foreground">
524
524
  <div id="root" class="h-full">
@@ -74,15 +74,15 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-ldEghBLB.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-BlzGEYgE.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
79
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
80
- <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
81
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
82
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
83
81
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
84
- <link rel="modulepreload" crossorigin href="/assets/index-Cwmuwk3V.js">
85
- <link rel="stylesheet" crossorigin href="/assets/index-GNm1wgUH.css">
82
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
83
+ <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
84
+ <link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
85
+ <link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
86
86
  </head>
87
87
  <body class="h-full bg-background text-foreground">
88
88
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,15 +63,15 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-Dk-VGreF.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-CkX6H-IT.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
68
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-C9ioTTSo.js">
69
- <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
70
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
71
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
72
70
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
73
- <link rel="modulepreload" crossorigin href="/assets/index-Cwmuwk3V.js">
74
- <link rel="stylesheet" crossorigin href="/assets/index-GNm1wgUH.css">
71
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
72
+ <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
75
75
  </head>
76
76
  <body class="h-full bg-background text-foreground">
77
77
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchamber/web",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "scripts": {
15
15
  "dev": "bun run build:watch",
16
- "dev:server": "bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
17
- "dev:server:watch": "nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
16
+ "dev:server": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
17
+ "dev:server:watch": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
18
18
  "build": "vite build",
19
19
  "build:watch": "vite build --watch",
20
20
  "type-check": "tsc --noEmit",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@clack/prompts": "^1.1.0",
27
27
  "@octokit/rest": "^22.0.1",
28
- "@opencode-ai/sdk": "1.18.21",
28
+ "@opencode-ai/sdk": "1.18.23",
29
29
  "@simplewebauthn/server": "13.3.1",
30
30
  "bun-pty": "^0.4.5",
31
31
  "compression": "^1.8.1",
package/server/index.js CHANGED
@@ -1815,6 +1815,14 @@ async function main(options = {}) {
1815
1815
  fs,
1816
1816
  process,
1817
1817
  }),
1818
+ // Dev/debug instances share the data dir (and thus the relay identity) with
1819
+ // the production instance, so they must not host the relay on their own —
1820
+ // paired devices would land on them. OPENCHAMBER_RELAY_HOST=off disables
1821
+ // passive hosting explicitly (dev scripts set it); the Electron dev shell is
1822
+ // covered via OPENCHAMBER_ELECTRON_DEV. OPENCHAMBER_RELAY_HOST=on overrides
1823
+ // both. Explicit enable/pairing on the instance still hosts regardless.
1824
+ allowPassiveHost: process.env.OPENCHAMBER_RELAY_HOST === 'on'
1825
+ || (process.env.OPENCHAMBER_RELAY_HOST !== 'off' && process.env.OPENCHAMBER_ELECTRON_DEV !== '1'),
1818
1826
  // Relay demand = any paired device or pending pairing session that uses the
1819
1827
  // relay transport. Drives the auto on/off lifecycle.
1820
1828
  hasRelayDemand: async () => {
@@ -262,14 +262,15 @@ export const createClientPairingRuntime = ({
262
262
  if (!constantTimeEqual(session.secretHash, hashSecret(normalizedSecret), crypto)) throw redeemError();
263
263
 
264
264
  // The operator's typed pairing label is THIS server's name for the device
265
- // (shown in the device list). It wins over the device's self-reported
266
- // label; fall back to that only when no pairing label was set.
267
- const label = normalizeOptionalString(session.label)
268
- || normalizeOptionalString(clientLabel)
269
- || normalizeOptionalString(deviceName)
270
- || 'Remote client';
265
+ // (shown in the device list) and wins outright. The device's self-reported
266
+ // label is only a fallback: on a re-pair with the same dedupeKey,
267
+ // createClient keeps the replaced record's label over it, so a rescan
268
+ // without a typed name does not reset the device to the app default.
271
269
  const result = await remoteClientAuthRuntime.createClient({
272
- label,
270
+ label: normalizeOptionalString(session.label),
271
+ fallbackLabel: normalizeOptionalString(clientLabel)
272
+ || normalizeOptionalString(deviceName)
273
+ || 'Remote client',
273
274
  clientKind: normalizedKind,
274
275
  dedupeKey: normalizeOptionalString(dedupeKey) || `pairing:${session.id}`,
275
276
  authMethod: 'pairing',
@@ -13,7 +13,7 @@ const makeRuntime = async (options = {}) => {
13
13
  createClient: vi.fn(async (input) => {
14
14
  const client = {
15
15
  id: `client-${createdClients.length + 1}`,
16
- label: input.label,
16
+ label: input.label ?? input.fallbackLabel,
17
17
  clientKind: input.clientKind,
18
18
  authMethod: input.authMethod,
19
19
  pairingId: input.pairingId,
@@ -61,6 +61,10 @@ describe('client auth pairing runtime', () => {
61
61
  pairingId: created.pairing.id,
62
62
  clientKind: 'mobile',
63
63
  dedupeKey: 'device-key',
64
+ // No operator-typed pairing label: the app-reported name is only a
65
+ // fallback so a re-pair keeps the existing device record's label.
66
+ label: null,
67
+ fallbackLabel: 'Iryna iPhone',
64
68
  }));
65
69
 
66
70
  await expect(runtime.redeemPairingSession({
@@ -157,6 +157,7 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
157
157
 
158
158
  const createClient = async ({
159
159
  label,
160
+ fallbackLabel,
160
161
  expiresAt,
161
162
  clientKind,
162
163
  dedupeKey,
@@ -172,9 +173,16 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
172
173
  const store = await readStore();
173
174
  const normalizedDedupeKey = normalizeOptionalString(dedupeKey);
174
175
  const token = generateToken();
176
+ // A dedupe-keyed mint REPLACES the previous record for the same device,
177
+ // so an operator-visible name must survive the replacement: an explicit
178
+ // label wins, otherwise the replaced record's label is kept, and only a
179
+ // first-ever mint falls back to the client-reported default.
180
+ const existing = normalizedDedupeKey
181
+ ? store.clients.find((entry) => entry.dedupeKey === normalizedDedupeKey)
182
+ : null;
175
183
  const client = {
176
184
  id: generateId(),
177
- label: normalizeLabel(label),
185
+ label: normalizeLabel(normalizeOptionalString(label) || existing?.label || fallbackLabel),
178
186
  tokenHash: hashToken(token),
179
187
  createdAt: nowIso(),
180
188
  lastUsedAt: null,
@@ -83,6 +83,23 @@ describe('remote client auth runtime', () => {
83
83
  }
84
84
  });
85
85
 
86
+ it('keeps the replaced record label on a dedupe re-mint without an explicit label', async () => {
87
+ const { dir, runtime } = await createRuntime();
88
+ try {
89
+ await runtime.createClient({ label: 'Iryna iPhone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
90
+ const remint = await runtime.createClient({ dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
91
+ expect(remint.client.label).toBe('Iryna iPhone');
92
+
93
+ const renamed = await runtime.createClient({ label: 'Work phone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
94
+ expect(renamed.client.label).toBe('Work phone');
95
+
96
+ const fresh = await runtime.createClient({ dedupeKey: 'mobile:device-2', fallbackLabel: 'OpenChamber Mobile' });
97
+ expect(fresh.client.label).toBe('OpenChamber Mobile');
98
+ } finally {
99
+ await fs.rm(dir, { recursive: true, force: true });
100
+ }
101
+ });
102
+
86
103
  it('keeps the token store private on disk', async () => {
87
104
  const { dir, runtime } = await createRuntime();
88
105
  try {
@@ -674,7 +674,16 @@ export async function resolveGitHubPrStatus({ octokit, directory, branch, remote
674
674
  };
675
675
  }
676
676
 
677
- const sourceCandidates = resolvedTargets.slice();
677
+ // Only the repo this branch actually pushes to (the ranked-first remote)
678
+ // and its fork network can be the SOURCE of the branch's PRs. Other
679
+ // configured remotes — a maintainer's checkout often carries contributor
680
+ // forks — are places to look for an open PR, but their `owner:branch`
681
+ // heads are unrelated branches that merely share a name; treating them as
682
+ // sources made a fork's closed `main` PR show up on the local main.
683
+ const primaryRemoteName = resolvedTargets[0]?.remoteName ?? null;
684
+ const sourceCandidates = resolvedTargets.filter(
685
+ (target) => target.remoteName === primaryRemoteName,
686
+ );
678
687
  // When every consulted repo list was complete, a no-PR result is
679
688
  // authoritative and the expensive Search API fallback is pointless.
680
689
  const coverage = { authoritative: true };
@@ -9,7 +9,6 @@ import { buildResult } from '../utils/index.js';
9
9
 
10
10
  import * as claude from './claude/index.js';
11
11
  import * as codex from './codex.js';
12
- import * as commandCode from './command-code.js';
13
12
  import * as copilot from './copilot.js';
14
13
  import * as crof from './crof.js';
15
14
  import * as cursor from './cursor.js';
@@ -30,12 +29,6 @@ import * as opencodeGo from './opencode-go.js';
30
29
  import * as xai from './xai.js';
31
30
 
32
31
  const registry = {
33
- 'command-code': {
34
- providerId: commandCode.providerId,
35
- providerName: commandCode.providerName,
36
- isConfigured: commandCode.isConfigured,
37
- fetchQuota: commandCode.fetchQuota
38
- },
39
32
  claude: {
40
33
  providerId: claude.providerId,
41
34
  providerName: claude.providerName,
@@ -160,12 +153,6 @@ const registry = {
160
153
 
161
154
  const pendingFetches = new Map();
162
155
 
163
- const normalizeQuotaProviderId = (providerId) => {
164
- if (typeof providerId !== 'string') return providerId;
165
- return ['command-code', 'commandcode', 'command_code', 'command code'].includes(providerId.trim().toLowerCase())
166
- ? 'command-code'
167
- : providerId;
168
- };
169
156
 
170
157
  export const listConfiguredQuotaProviders = () => {
171
158
  const configured = [];
@@ -210,14 +197,13 @@ const fetchQuotaForProviderUncoalesced = async (providerId) => {
210
197
  };
211
198
 
212
199
  export const fetchQuotaForProvider = (providerId) => {
213
- const normalizedProviderId = normalizeQuotaProviderId(providerId);
214
- const existing = pendingFetches.get(normalizedProviderId);
200
+ const existing = pendingFetches.get(providerId);
215
201
  if (existing) return existing;
216
202
 
217
- const pending = fetchQuotaForProviderUncoalesced(normalizedProviderId).finally(() => {
218
- if (pendingFetches.get(normalizedProviderId) === pending) pendingFetches.delete(normalizedProviderId);
203
+ const pending = fetchQuotaForProviderUncoalesced(providerId).finally(() => {
204
+ if (pendingFetches.get(providerId) === pending) pendingFetches.delete(providerId);
219
205
  });
220
- pendingFetches.set(normalizedProviderId, pending);
206
+ pendingFetches.set(providerId, pending);
221
207
  return pending;
222
208
  };
223
209
 
@@ -23,7 +23,7 @@ Host side (`packages/web/server/lib/relay/`):
23
23
  - `identity.js` — the host's stable identity: the long-lived signing keypair (shared with the push relay, defines the routing id) plus a long-lived encryption keypair (the E2EE trust anchor). Reused across restarts; never rotated implicitly.
24
24
  - `signing-key.js` — storage/derivation of the signing keypair and the routing id, shared with the notifications runtime.
25
25
  - `host-client.js` — the long-lived connection manager: one outbound control connection to the relay, a per-client data connection for each connected device, reconnect/backoff, and the E2EE responder handshake per connection.
26
- - `host-lock.js` — the per-machine host claim. Every local instance sharing the data dir shares the relay identity (same serverId), so concurrent relay hosts evict each other at the relay worker (`4001: Control replaced`) and paired devices land on whichever local process won last. The claim file (`<data-dir>/relay-host.lock`, `{ pid }`) makes this deterministic: `service.js` only starts the host when no LIVE process holds the claim (stale claims from dead pids are ignored), goes to `standby` otherwise, and a 30s watcher both takes over when the claimant dies and stands down when another process claims. Explicit user intent — creating a pairing link or hitting `/relay/enable` — force-claims; the previous holder's watcher sees the takeover and backs off instead of fighting. The claim is cooperative (the relay worker still enforces the single host slot); it only decides which process keeps retrying.
26
+ - `host-lock.js` — the per-machine host claim. Every local instance sharing the data dir shares the relay identity (same serverId), so concurrent relay hosts evict each other at the relay worker (`4001: Control replaced`) and paired devices land on whichever local process won last. The claim file (`<data-dir>/relay-host.lock`, `{ pid }`) makes this deterministic: `service.js` only starts the host when no LIVE process holds the claim (stale claims from dead pids are ignored), goes to `standby` otherwise, and a 30s watcher both takes over when the claimant dies and stands down when another process claims. A standby watcher waits a 2-minute grace after the claim frees before taking over, so a cleanly restarting host (app update/relaunch) — which reclaims at boot with no wait — always wins the restart window over a bystander instance. Explicit user intent — creating a pairing link or hitting `/relay/enable` — force-claims; the previous holder's watcher sees the takeover and backs off instead of fighting. Instances created with `allowPassiveHost: false` (dev servers via `OPENCHAMBER_RELAY_HOST=off`, the Electron dev shell via `OPENCHAMBER_ELECTRON_DEV`; `OPENCHAMBER_RELAY_HOST=on` overrides) never start the host passively at all — boot, demand reconcile, and watcher takeover leave them in `standby`; only explicit enable/pairing hosts there. The claim is cooperative (the relay worker still enforces the single host slot); it only decides which process keeps retrying.
27
27
  - `tunnel-host.js` — the per-connection dispatcher: decrypts tunnel frames and forwards HTTP/SSE/WS to the local server over loopback, then streams responses back. Enforces a path allowlist and never injects credentials.
28
28
  - `e2ee.js`, `tunnel-codec.js` — host-side (JS) mirrors of the shared crypto and framing (see "Two implementations" below).
29
29
 
@@ -70,6 +70,11 @@ export const createRelayService = ({
70
70
  // evict each other at the relay worker ("Control replaced") and devices land
71
71
  // on a random instance. Optional: without it, behavior is pre-lock.
72
72
  hostLock = null,
73
+ // When false, this instance never starts the relay host on its own (boot,
74
+ // demand reconcile, or claim-watch takeover) — only an explicit user action
75
+ // (enable, pairing) force-claims. Dev/debug instances set this so they do not
76
+ // capture paired devices from the production instance sharing the data dir.
77
+ allowPassiveHost = true,
73
78
  logger = console,
74
79
  }) => {
75
80
  const identityRuntime = createRelayIdentityRuntime({ crypto, readSettingsFromDiskMigrated, writeSettingsToDisk, readSettingsStrict });
@@ -80,6 +85,13 @@ export const createRelayService = ({
80
85
  // claimant dies; a running host stands down when another process claims.
81
86
  let claimWatchTimer = null;
82
87
  const CLAIM_WATCH_INTERVAL_MS = 30_000;
88
+ // A standby instance does not grab a freed claim immediately: a clean restart
89
+ // of the previous host (app update, relaunch) releases the claim for a short
90
+ // while, and taking it during that window strands the devices on this —
91
+ // possibly older — instance. The restarting host reclaims at boot without any
92
+ // wait, so it always wins the window.
93
+ const CLAIM_TAKEOVER_GRACE_MS = 120_000;
94
+ let claimFreeSinceMs = null;
83
95
 
84
96
  const readConfig = async () => {
85
97
  const settings = await readSettingsFromDiskMigrated();
@@ -133,8 +145,19 @@ export const createRelayService = ({
133
145
  }
134
146
  return;
135
147
  }
136
- if (status.state === 'standby' && hostLock.tryClaim()) {
137
- logger.warn('[Relay] host claim is free — taking over the relay host');
148
+ if (status.state !== 'standby' || !allowPassiveHost) return;
149
+ if (hostLock.liveClaimantPid() !== null) {
150
+ claimFreeSinceMs = null;
151
+ return;
152
+ }
153
+ if (claimFreeSinceMs === null) {
154
+ claimFreeSinceMs = Date.now();
155
+ return;
156
+ }
157
+ if (Date.now() - claimFreeSinceMs < CLAIM_TAKEOVER_GRACE_MS) return;
158
+ if (hostLock.tryClaim()) {
159
+ claimFreeSinceMs = null;
160
+ logger.warn('[Relay] host claim stayed free — taking over the relay host');
138
161
  await start(relayUrl);
139
162
  }
140
163
  } catch (error) {
@@ -149,10 +172,19 @@ export const createRelayService = ({
149
172
  if (!claimWatchTimer) return;
150
173
  clearInterval(claimWatchTimer);
151
174
  claimWatchTimer = null;
175
+ claimFreeSinceMs = null;
152
176
  };
153
177
 
154
178
  const start = async (relayUrl, { claim = 'try' } = {}) => {
155
179
  if (hostClient) return;
180
+ if (claim !== 'force' && !allowPassiveHost) {
181
+ status = {
182
+ state: 'standby',
183
+ lastError: 'passive relay hosting is disabled on this instance — enable the relay or create a pairing link to host here',
184
+ connectedClients: 0,
185
+ };
186
+ return;
187
+ }
156
188
  if (hostLock) {
157
189
  const claimed = claim === 'force' ? hostLock.forceClaim() : hostLock.tryClaim();
158
190
  if (!claimed) {
@@ -0,0 +1,69 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import crypto from 'node:crypto';
3
+
4
+ import { createRelayService } from './service.js';
5
+
6
+ const makeService = (options = {}) => {
7
+ // In-memory settings store with a pre-seeded relay identity so the service
8
+ // never regenerates a signing key during the test.
9
+ const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', { namedCurve: 'P-256' });
10
+ let settings = {
11
+ relaySigningKey: {
12
+ privateJwk: privateKey.export({ format: 'jwk' }),
13
+ publicJwk: publicKey.export({ format: 'jwk' }),
14
+ },
15
+ privateRelay: { enabled: true, relayUrl: 'wss://relay.example.test/ws' },
16
+ ...options.settings,
17
+ };
18
+ const hostLock = {
19
+ tryClaim: vi.fn(() => true),
20
+ forceClaim: vi.fn(() => true),
21
+ holdsClaim: vi.fn(() => true),
22
+ liveClaimantPid: vi.fn(() => null),
23
+ release: vi.fn(),
24
+ };
25
+ const service = createRelayService({
26
+ crypto,
27
+ readSettingsFromDiskMigrated: async () => settings,
28
+ writeSettingsToDisk: async (next) => { settings = next; },
29
+ readSettingsStrict: async () => settings,
30
+ getLocalPort: () => 0,
31
+ hasRelayDemand: options.hasRelayDemand ?? (async () => true),
32
+ hostLock,
33
+ allowPassiveHost: options.allowPassiveHost,
34
+ logger: { warn: () => {} },
35
+ });
36
+ return { service, hostLock, getSettings: () => settings };
37
+ };
38
+
39
+ describe('relay service passive hosting', () => {
40
+ it('never claims or starts the host passively when passive hosting is disabled', async () => {
41
+ const { service, hostLock } = makeService({ allowPassiveHost: false });
42
+ try {
43
+ await service.startIfEnabled();
44
+ let status = await service.getStatus();
45
+ expect(status.state).toBe('standby');
46
+ expect(hostLock.tryClaim).not.toHaveBeenCalled();
47
+ expect(hostLock.forceClaim).not.toHaveBeenCalled();
48
+
49
+ await service.reconcile();
50
+ status = await service.getStatus();
51
+ expect(status.state).toBe('standby');
52
+ expect(status.lastError).toContain('passive relay hosting is disabled');
53
+ expect(hostLock.tryClaim).not.toHaveBeenCalled();
54
+ } finally {
55
+ service.stop();
56
+ }
57
+ });
58
+
59
+ it('force-claims for an explicit pairing even when passive hosting is disabled', async () => {
60
+ const { service, hostLock } = makeService({ allowPassiveHost: false });
61
+ try {
62
+ const candidate = await service.ensureEnabledForPairing();
63
+ expect(candidate?.type).toBe('relay');
64
+ expect(hostLock.forceClaim).toHaveBeenCalled();
65
+ } finally {
66
+ service.stop();
67
+ }
68
+ });
69
+ });
@@ -249,6 +249,7 @@ export const createSessionGoalRuntime = ({
249
249
  getOpenCodeAuthHeaders,
250
250
  getSmallModelService,
251
251
  emitGoalNotification,
252
+ isEnabled = isSessionGoalEnabled,
252
253
  idleQuietMs = IDLE_QUIET_MS,
253
254
  kickoffQuietMs = KICKOFF_QUIET_MS,
254
255
  maxAutoTurns = MAX_AUTO_TURNS,
@@ -444,7 +445,7 @@ export const createSessionGoalRuntime = ({
444
445
  };
445
446
 
446
447
  const tick = async (sessionId, directory) => {
447
- if (!isSessionGoalEnabled()) return;
448
+ if (!isEnabled()) return;
448
449
 
449
450
  const session = await openCodeFetch(`/session/${encodeURIComponent(sessionId)}`, { directory })
450
451
  .catch((error) => {
@@ -35,13 +35,14 @@ const startIdleTick = async (fetchImpl) => {
35
35
  buildOpenCodeUrl: (pathname) => `http://opencode.test${pathname}`,
36
36
  getOpenCodeAuthHeaders: () => ({}),
37
37
  getSmallModelService,
38
+ isEnabled: () => true,
38
39
  idleQuietMs: 10,
39
40
  });
40
41
  runtime.processPayload({
41
42
  type: 'session.status',
42
43
  properties: { sessionID: SESSION_ID, status: { type: 'idle' }, directory: DIRECTORY },
43
44
  });
44
- await vi.advanceTimersByTimeAsync(10);
45
+ await vi.runOnlyPendingTimersAsync();
45
46
  return { runtime, getSmallModelService };
46
47
  };
47
48
 
@@ -156,6 +157,7 @@ describe('session goal live activity gate', () => {
156
157
  buildOpenCodeUrl: (pathname) => `http://opencode.test${pathname}`,
157
158
  getOpenCodeAuthHeaders: () => ({}),
158
159
  getSmallModelService: async () => service,
160
+ isEnabled: () => true,
159
161
  idleQuietMs: 10,
160
162
  });
161
163
 
@@ -163,7 +165,7 @@ describe('session goal live activity gate', () => {
163
165
  type: 'session.status',
164
166
  properties: { sessionID: SESSION_ID, status: { type: 'idle' }, directory: DIRECTORY },
165
167
  });
166
- await vi.advanceTimersByTimeAsync(10);
168
+ await vi.runOnlyPendingTimersAsync();
167
169
 
168
170
  expect(service.generateSmallModelText).toHaveBeenCalledOnce();
169
171
  const patch = requests.find((request) => request.pathname === `/session/${SESSION_ID}` && request.method === 'PATCH');
@@ -19,6 +19,8 @@
19
19
 
20
20
  HTTP remains the authenticated command plane for create, resize, appearance updates, restart, close, and force-kill. There is no SSE output or HTTP input compatibility path.
21
21
 
22
+ `GET /api/terminal/sessions` enumerates live sessions (optionally filtered by resolved `cwd`) so clients can adopt terminals their local tab projection does not know about — another device, a new browser tab, or cleared storage. `POST /api/terminal/touch` refreshes `lastActivity` for the listed session ids; open clients call it periodically so background tabs, which hold no WebSocket attachment, are not idle-reaped while a client still shows them.
23
+
22
24
  ## PTY Lifecycle
23
25
 
24
26
  - IDs are client-provided or generated with `randomUUID()`.
@@ -228,7 +228,7 @@ export function createTerminalRuntime({
228
228
  }
229
229
  if (!existing && sessions.size + pendingSessionCreates.size >= MAX_SESSIONS) throw new Error('Maximum terminal sessions reached');
230
230
  const creation = (async () => {
231
- const session = existing ?? { id, sequence: 0, history: '', pendingHistoryControlSequence: '', pendingThemeControlSequence: '', eventQueue: [], draining: false };
231
+ const session = existing ?? { id, sequence: 0, history: '', pendingHistoryControlSequence: '', pendingThemeControlSequence: '', eventQueue: [], draining: false, createdAt: Date.now() };
232
232
  await startSession(session, { cwd, cols, rows, themeMode, terminalBackground, terminalForeground, shell: normalizedShell, loginShell });
233
233
  sessions.set(id, session);
234
234
  return session;
@@ -297,6 +297,34 @@ export function createTerminalRuntime({
297
297
  res.status(500).json({ error: error?.message || 'Failed to list terminal shells' });
298
298
  }
299
299
  });
300
+ app.get('/api/terminal/sessions', (req, res) => {
301
+ const rawCwd = typeof req.query?.cwd === 'string' ? req.query.cwd.trim() : '';
302
+ const cwdFilter = rawCwd ? path.resolve(rawCwd) : null;
303
+ const list = [];
304
+ for (const session of sessions.values()) {
305
+ if (cwdFilter && path.resolve(session.cwd) !== cwdFilter) continue;
306
+ list.push({
307
+ sessionId: session.id,
308
+ cwd: session.cwd,
309
+ status: session.status,
310
+ createdAt: Number.isInteger(session.createdAt) ? session.createdAt : null,
311
+ });
312
+ }
313
+ res.json({ sessions: list });
314
+ });
315
+ app.post('/api/terminal/touch', (req, res) => {
316
+ const rawIds = Array.isArray(req.body?.sessionIds) ? req.body.sessionIds : [];
317
+ const now = Date.now();
318
+ let touched = 0;
319
+ for (const id of rawIds) {
320
+ if (typeof id !== 'string') continue;
321
+ const session = sessions.get(id);
322
+ if (!session) continue;
323
+ session.lastActivity = now;
324
+ touched += 1;
325
+ }
326
+ res.json({ touched });
327
+ });
300
328
  app.post('/api/terminal/create', async (req, res) => {
301
329
  try { const session = await createSession(req.body ?? {}); res.json({ sessionId: session.id, cols: session.cols, rows: session.rows, status: session.status }); }
302
330
  catch (error) { res.status(error?.message === 'Maximum terminal sessions reached' ? 429 : 400).json({ error: error?.message || 'Failed to create terminal session' }); }
@@ -179,6 +179,32 @@ describe('terminal runtime', () => {
179
179
  } finally { await harness.runtime.shutdown(); }
180
180
  });
181
181
 
182
+ it('lists sessions scoped to a working directory and refreshes activity via touch', async () => {
183
+ const harness = createHarness();
184
+ try {
185
+ await harness.routes.post.get('/api/terminal/create')({ body: { sessionId: 'term-a', cwd: '/repo' } }, createResponse());
186
+ await harness.routes.post.get('/api/terminal/create')({ body: { sessionId: 'term-b', cwd: '/other' } }, createResponse());
187
+
188
+ const all = createResponse();
189
+ harness.routes.get.get('/api/terminal/sessions')({ query: {} }, all);
190
+ expect(all.body.sessions.map((s) => s.sessionId).sort()).toEqual(['term-a', 'term-b']);
191
+
192
+ const scoped = createResponse();
193
+ harness.routes.get.get('/api/terminal/sessions')({ query: { cwd: '/repo' } }, scoped);
194
+ expect(scoped.body.sessions).toEqual([
195
+ { sessionId: 'term-a', cwd: '/repo', status: 'running', createdAt: expect.any(Number) },
196
+ ]);
197
+
198
+ const touch = createResponse();
199
+ harness.routes.post.get('/api/terminal/touch')({ body: { sessionIds: ['term-a', 'missing', 42] } }, touch);
200
+ expect(touch.body).toEqual({ touched: 1 });
201
+
202
+ const malformed = createResponse();
203
+ harness.routes.post.get('/api/terminal/touch')({ body: {} }, malformed);
204
+ expect(malformed.body).toEqual({ touched: 0 });
205
+ } finally { await harness.runtime.shutdown(); }
206
+ });
207
+
182
208
  it('strips AppImage ARGV0 from PTY child environments', async () => {
183
209
  const previousArgv0 = process.env.ARGV0;
184
210
  process.env.ARGV0 = '/path/to/OpenChamber/OpenChamber-1.17.2-linux-x86_64.AppImage';
@@ -839,7 +839,7 @@ export const createUiAuth = ({
839
839
  let clientTokenResult = null;
840
840
  if (req.body?.issueClientToken === true && typeof clientAuthController?.createClient === 'function') {
841
841
  clientTokenResult = await clientAuthController.createClient({
842
- label: req.body?.clientLabel,
842
+ fallbackLabel: req.body?.clientLabel,
843
843
  expiresAt: new Date(Date.now() + ttlMs).toISOString(),
844
844
  clientKind: req.body?.clientKind,
845
845
  dedupeKey: req.body?.dedupeKey,
@@ -907,7 +907,7 @@ export const createUiAuth = ({
907
907
  let clientTokenResult = null;
908
908
  if (req.body?.issueClientToken === true && typeof clientAuthController?.createClient === 'function') {
909
909
  clientTokenResult = await clientAuthController.createClient({
910
- label: req.body?.clientLabel,
910
+ fallbackLabel: req.body?.clientLabel,
911
911
  expiresAt: new Date(Date.now() + ttlMs).toISOString(),
912
912
  clientKind: req.body?.clientKind,
913
913
  dedupeKey: req.body?.dedupeKey,
@@ -269,7 +269,7 @@ describe('ui auth client credential seam', () => {
269
269
  token: 'client-token',
270
270
  client: {
271
271
  id: 'device-1',
272
- label: input.label,
272
+ label: input.label ?? input.fallbackLabel,
273
273
  createdAt: new Date().toISOString(),
274
274
  lastUsedAt: null,
275
275
  revokedAt: null,
@@ -295,7 +295,7 @@ describe('ui auth client credential seam', () => {
295
295
  await auth.handleSessionCreate(req, res);
296
296
 
297
297
  expect(res.body.clientToken).toBe('client-token');
298
- expect(createClientInput.label).toBe('OpenChamber Desktop');
298
+ expect(createClientInput.fallbackLabel).toBe('OpenChamber Desktop');
299
299
  const expiresAt = Date.parse(createClientInput.expiresAt);
300
300
  expect(expiresAt).toBeGreaterThanOrEqual(before + 122_000);
301
301
  expect(expiresAt).toBeLessThanOrEqual(Date.now() + 124_000);