@openchamber/web 1.18.0 → 1.18.1

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 (53) hide show
  1. package/dist/assets/{DiagramView-1-LZVuzn.js → DiagramView-DZmf30ko.js} +1 -1
  2. package/dist/assets/{FilesView-BDRX8vU2.js → FilesView-cJPeFhDe.js} +6 -6
  3. package/dist/assets/{MarkdownRendererImpl-fZSdR7PD.js → MarkdownRendererImpl-DZezL90a.js} +1 -1
  4. package/dist/assets/{OnboardingScreen-D81UrlA4.js → OnboardingScreen-ChYr0xqs.js} +1 -1
  5. package/dist/assets/{SessionSwitcherDropdown-cSK3t3TR.js → SessionSwitcherDropdown-BV7FfPbT.js} +1 -1
  6. package/dist/assets/{SettingsWindow-CozowJLm.js → SettingsWindow-UybkBD1p.js} +1 -1
  7. package/dist/assets/{contextPanelEmbeddedChat-CQYNvKbk.js → contextPanelEmbeddedChat-DW3atb4h.js} +1 -1
  8. package/dist/assets/{de-C2n4oo1Z.js → de-rVJ-hXrd.js} +3 -3
  9. package/dist/assets/es-D7ZyOToq.js +15 -0
  10. package/dist/assets/{fr-DDFUp5jS.js → fr-hl5i-ZI0.js} +2 -2
  11. package/dist/assets/{index-BCCcokur.css → index-CL9MYe8V.css} +1 -1
  12. package/dist/assets/{ja-B7SxobKm.js → ja-DqakdvOp.js} +2 -2
  13. package/dist/assets/{ko-CWGq93SO.js → ko-dNl8A3Xf.js} +2 -2
  14. package/dist/assets/main-B5TIsU2y.js +209 -0
  15. package/dist/assets/{main-Cts0BwVk.js → main-_m6HD9-a.js} +2 -2
  16. package/dist/assets/{markdownCore-BqzEkymd.js → markdownCore-DpT1vbbv.js} +2 -2
  17. package/dist/assets/{miniChat-ChuQD2KK.js → miniChat-wYb8p9vG.js} +2 -2
  18. package/dist/assets/{mobile-c-CRD1Cz.js → mobile-ExXAVUcv.js} +2 -2
  19. package/dist/assets/{pl-DZmyxLo7.js → pl-C5HQx1Hf.js} +3 -3
  20. package/dist/assets/pt-BR-CNCoBDAM.js +15 -0
  21. package/dist/assets/{renderElectronMiniChatApp-9uaZAJjw.js → renderElectronMiniChatApp-DPDzIT8W.js} +2 -2
  22. package/dist/assets/{renderMobileApp-Dm1tmU2a.js → renderMobileApp-CzWvxR9e.js} +3 -3
  23. package/dist/assets/runtimeEndpointReset-DKzVWH1w.js +180 -0
  24. package/dist/assets/uk-Bn-3AMpk.js +15 -0
  25. package/dist/assets/{useAppFontEffects-pyTMaGQu.js → useAppFontEffects-DdvGxoPX.js} +133 -133
  26. package/dist/assets/zh-CN-BCwvQpZm.js +15 -0
  27. package/dist/assets/zh-TW-TRHrkN9l.js +15 -0
  28. package/dist/index.html +4 -4
  29. package/dist/mini-chat.html +3 -3
  30. package/dist/mobile.html +3 -3
  31. package/package.json +2 -2
  32. package/server/lib/openchamber-control/DOCUMENTATION.md +9 -1
  33. package/server/lib/openchamber-sessions/routes.js +117 -4
  34. package/server/lib/openchamber-sessions/routes.test.js +129 -16
  35. package/server/lib/opencode/DOCUMENTATION.md +2 -0
  36. package/server/lib/opencode/proxy.js +21 -3
  37. package/server/lib/small-model/DOCUMENTATION.md +11 -4
  38. package/server/lib/small-model/call.js +19 -3
  39. package/server/lib/small-model/call.test.js +9 -2
  40. package/server/lib/small-model/index.js +10 -1
  41. package/server/lib/small-model/index.test.js +20 -1
  42. package/server/lib/walkthrough/DOCUMENTATION.md +23 -0
  43. package/server/lib/walkthrough/index.js +17 -0
  44. package/server/lib/walkthrough/reproduce-2607.test.js +148 -0
  45. package/server/opencode-proxy.test.js +83 -0
  46. package/dist/assets/es-DP7jRKkr.js +0 -15
  47. package/dist/assets/main-Cqfcxvqq.js +0 -209
  48. package/dist/assets/pt-BR-BKR5oHQ7.js +0 -15
  49. package/dist/assets/runtimeEndpointReset-DL5z84w2.js +0 -180
  50. package/dist/assets/uk-D7oAI_Wc.js +0 -15
  51. package/dist/assets/zh-CN-Ddjz1_9w.js +0 -15
  52. package/dist/assets/zh-TW-D3X01YXj.js +0 -15
  53. /package/dist/assets/{index-ChZvuURI.js → index-DjZ4W8hy.js} +0 -0
@@ -171,14 +171,21 @@ describe('callSmallModel — custom provider config', () => {
171
171
  provider: { custom: { options: { baseURL: 'https://proxy.example.test/v1' } } },
172
172
  });
173
173
 
174
- await expect(callSmallModel({
174
+ const error = await callSmallModel({
175
175
  auth: {},
176
176
  catalog: {},
177
177
  workingDirectory: '/proj',
178
178
  providerID: 'custom',
179
179
  modelID: 'gpt-4o-mini',
180
180
  prompt: 'hi',
181
- })).rejects.toThrow('No OpenCode login found for provider "custom"');
181
+ }).then(() => null, (e) => e);
182
+
183
+ expect(error).toMatchObject({
184
+ message: 'No OpenCode login found for provider "custom"',
185
+ code: 'no-provider-login',
186
+ statusCode: 401,
187
+ providerID: 'custom',
188
+ });
182
189
 
183
190
  // The credential gate fires before any network call.
184
191
  expect(fetchMock).not.toHaveBeenCalled();
@@ -5,7 +5,7 @@ import { readAuthFile } from '../opencode/auth.js';
5
5
  import { readConfigLayers } from '../opencode/shared.js';
6
6
  import { getModelCatalog } from './catalog.js';
7
7
  import { resolveSmallModel, parseModelRef, isUsableAuthEntry, getAuthEntryForProvider } from './resolve.js';
8
- import { callSmallModel } from './call.js';
8
+ import { callSmallModel, resolveProviderLogin } from './call.js';
9
9
 
10
10
  const OPENCHAMBER_SETTINGS_FILE = path.join(
11
11
  process.env.OPENCHAMBER_DATA_DIR
@@ -252,8 +252,17 @@ export async function describeSmallModel({ directory, preferredProviderID, prefe
252
252
  outputReserveTokens: reserveTokens,
253
253
  });
254
254
 
255
+ // Settings/config/request overrides can name a provider with no usable login.
256
+ // Report that here so readiness can refuse before the user pays for a 401.
257
+ const hasLogin = Boolean(resolveProviderLogin({
258
+ auth,
259
+ workingDirectory: directory,
260
+ providerID: resolved.providerID,
261
+ }));
262
+
255
263
  return {
256
264
  ...resolved,
265
+ hasLogin,
257
266
  inputCharBudget: maxChars,
258
267
  contextTokens,
259
268
  contextKnown,
@@ -18,7 +18,13 @@ vi.mock('./catalog.js', () => ({
18
18
  getModelCatalog: vi.fn(),
19
19
  getCatalogProvider: vi.fn(),
20
20
  }));
21
- vi.mock('./call.js', () => ({ callSmallModel: vi.fn() }));
21
+ vi.mock('./call.js', () => ({
22
+ callSmallModel: vi.fn(),
23
+ resolveProviderLogin: vi.fn(({ auth, providerID }) => {
24
+ const entry = auth?.[providerID];
25
+ return entry && typeof entry === 'object' ? entry : null;
26
+ }),
27
+ }));
22
28
 
23
29
  const { generateSmallModelText, describeSmallModel } = await import('./index.js');
24
30
  const { readAuthFile } = await import('../opencode/auth.js');
@@ -126,6 +132,19 @@ describe('describeSmallModel — capability reporting', () => {
126
132
  contextTokens: 8_000,
127
133
  contextKnown: true,
128
134
  structuredOutput: true,
135
+ hasLogin: true,
136
+ });
137
+ });
138
+
139
+ it('reports hasLogin false when the resolved provider has no usable credential', async () => {
140
+ readAuthFile.mockReturnValue({});
141
+
142
+ const described = await describeSmallModel({ directory: '/proj' });
143
+
144
+ expect(described).toMatchObject({
145
+ providerID: 'anthropic',
146
+ modelID: 'claude-haiku-4-5',
147
+ hasLogin: false,
129
148
  });
130
149
  });
131
150
 
@@ -118,6 +118,14 @@ model picker, only shows providers with a usable login. The in-panel picker on a
118
118
  blocked walkthrough writes this setting too, so recovering from a refusal never
119
119
  silently changes the model behind commit messages.
120
120
 
121
+ A settings or `opencode.json` `small_model` override can still name a provider
122
+ with no usable login (neither `auth.json` nor `provider.<id>.options.apiKey`).
123
+ `describeSmallModel` reports that as `hasLogin: false`, readiness refuses with
124
+ `reason: 'no-provider-login'` and omits the unusable model so the panel cannot
125
+ present it as selected, and generation maps the same code to HTTP 401. The UI
126
+ disables Generate and keeps the picker on authenticated providers only — it does
127
+ not surface a raw auth error or a special login blocker for this case.
128
+
121
129
  ## Output language
122
130
 
123
131
  A walkthrough its reader cannot read is worth nothing, so the prose language is
@@ -369,6 +377,21 @@ endpoint nothing calls is a maintenance surface that rots untested.
369
377
  Registered lazily from `feature-routes-runtime.js`. `/api/walkthrough` is in the
370
378
  JSON body-parser allowlist in `core-routes.js`.
371
379
 
380
+ ## A server that does not have these routes
381
+
382
+ An `/api/*` path no OpenChamber route claims reaches the OpenCode proxy, and
383
+ OpenCode answers any path it does not know with its embedded web UI — HTML, with
384
+ status **200**. So a client newer than the server it is connected to is not told
385
+ "no such route"; it is handed a web page. Parsing that as JSON is where
386
+ `Unexpected token '<', "<!doctype "...` came from, a message that names neither
387
+ the cause nor the remedy.
388
+
389
+ The client therefore checks the content type before parsing. A non-JSON answer
390
+ on 2xx or 404 becomes `server-unsupported`, which the panel renders as "this
391
+ server is older than the app, update it". A non-JSON **5xx** keeps its own
392
+ failure: a server that answered badly is not a server missing the feature, and
393
+ telling someone to upgrade would send them after the wrong thing.
394
+
372
395
  ## Runtime availability
373
396
 
374
397
  Web, desktop, and hosted mobile reach these routes normally. VS Code serves Git
@@ -333,6 +333,13 @@ function computeReadiness({ model, digest, files, fileCount, hunkCount, generate
333
333
  return { ready: false, reason, model, generatedFileCount };
334
334
  }
335
335
 
336
+ // A resolved override/config model can still have no usable login. Refuse up
337
+ // front and omit the model — offering an unauthenticated selection in the
338
+ // picker is what made the old raw auth error feel like a product bug.
339
+ if (model.hasLogin === false) {
340
+ return { ready: false, reason: 'no-provider-login' };
341
+ }
342
+
336
343
  // Built with the same language the generation would use: the instruction is
337
344
  // part of the prompt, so a readiness answer computed without it would be
338
345
  // measuring a request nobody is going to send.
@@ -392,6 +399,13 @@ async function runGeneration({ directory, source, repoRoot, key, force, explicit
392
399
  if (!model) {
393
400
  throw fail('No model is available — sign in to a provider first', 404, { code: 'no-model' });
394
401
  }
402
+ if (model.hasLogin === false) {
403
+ throw fail(
404
+ `No OpenCode login found for provider "${model.providerID}" — sign in or choose a different model`,
405
+ 401,
406
+ { code: 'no-provider-login', model },
407
+ );
408
+ }
395
409
 
396
410
  const { digest, files, idByAlias, fileCount, hunkCount, generatedFileCount } = await loadCurrentDiff(directory, source, deps);
397
411
  setStage(repoRoot, key, 'asking');
@@ -494,6 +508,9 @@ async function runGeneration({ directory, source, repoRoot, key, force, explicit
494
508
  if (error?.code === 'output-exhausted') {
495
509
  return fail(error.message, 409, { code: 'output-exhausted', model });
496
510
  }
511
+ if (error?.code === 'no-provider-login') {
512
+ return fail(error.message, 401, { code: 'no-provider-login', model });
513
+ }
497
514
  return null;
498
515
  };
499
516
 
@@ -0,0 +1,148 @@
1
+ import { execFileSync } from 'child_process';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import express from 'express';
6
+ import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // Regression for https://github.com/openchamber/openchamber/issues/2607
10
+ // "[Bug] Why say so?" (walkthrough panel)
11
+ //
12
+ // Before the fix, a walkthrough small model whose provider had no usable login
13
+ // reported readiness ready:true, then generation returned HTTP 500 with the raw
14
+ // message `No OpenCode login found for provider "deepseek"` — shown in the
15
+ // error banner above the "No walkthrough yet" empty state.
16
+ //
17
+ // After the fix: readiness refuses with `no-provider-login`, and generation
18
+ // answers 401 with the same structured code so the UI can show a blocker.
19
+ // ---------------------------------------------------------------------------
20
+
21
+ const TEMP_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-home-2607-'));
22
+ process.env.HOME = TEMP_HOME;
23
+ process.env.OPENCHAMBER_DATA_DIR = path.join(TEMP_HOME, '.config', 'openchamber');
24
+
25
+ const CATALOG = {
26
+ deepseek: {
27
+ id: 'deepseek',
28
+ name: 'DeepSeek',
29
+ api: 'https://api.deepseek.com',
30
+ models: {
31
+ 'deepseek-v4-flash': {
32
+ id: 'deepseek-v4-flash',
33
+ name: 'DeepSeek V4 Flash',
34
+ family: 'deepseek-flash',
35
+ limit: { context: 128_000 },
36
+ },
37
+ },
38
+ },
39
+ };
40
+
41
+ vi.mock('../../opencode/models-metadata.js', () => ({
42
+ getModelsMetadata: vi.fn(async () => ({ metadata: CATALOG, fromCache: false })),
43
+ }));
44
+
45
+ const SOURCE = { kind: 'working-tree', scope: 'all' };
46
+ const REPO_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-repo-2607-'));
47
+
48
+ const setupGitRepo = () => {
49
+ const run = (args) => {
50
+ try {
51
+ return execFileSync('git', args, { cwd: REPO_DIR, encoding: 'utf8' });
52
+ } catch (error) {
53
+ throw new Error(`git ${args.join(' ')} failed: ${error.stderr?.toString() ?? error.message}`);
54
+ }
55
+ };
56
+
57
+ run(['init', '-b', 'main']);
58
+ run(['config', 'user.email', 'test@example.com']);
59
+ run(['config', 'user.name', 'Test']);
60
+ fs.mkdirSync(path.join(REPO_DIR, 'src'), { recursive: true });
61
+ fs.writeFileSync(path.join(REPO_DIR, 'src', 'a.ts'), 'export const a = 1;\n', 'utf8');
62
+ run(['add', 'src/a.ts']);
63
+ run(['commit', '-m', 'init']);
64
+ fs.writeFileSync(path.join(REPO_DIR, 'src', 'a.ts'), 'export const a = 1;\nexport const b = 2;\n', 'utf8');
65
+ };
66
+
67
+ let walkthrough;
68
+ let callSmallModel;
69
+
70
+ describe('issue 2607 — walkthrough blocks unauthenticated providers', () => {
71
+ beforeAll(async () => {
72
+ setupGitRepo();
73
+ fs.writeFileSync(
74
+ path.join(REPO_DIR, 'opencode.json'),
75
+ JSON.stringify({ small_model: 'deepseek/deepseek-v4-flash' }, null, 2),
76
+ 'utf8',
77
+ );
78
+
79
+ walkthrough = await import('./index.js');
80
+ callSmallModel = await import('../small-model/call.js');
81
+ });
82
+
83
+ afterAll(() => {
84
+ fs.rmSync(TEMP_HOME, { recursive: true, force: true });
85
+ fs.rmSync(REPO_DIR, { recursive: true, force: true });
86
+ });
87
+
88
+ it('resolves the deepseek model but reports not ready without a login', async () => {
89
+ const result = await walkthrough.getWalkthrough({ directory: REPO_DIR, source: SOURCE });
90
+
91
+ expect(result.readiness.ready).toBe(false);
92
+ expect(result.readiness.reason).toBe('no-provider-login');
93
+ // Unusable models must not be offered as the current selection.
94
+ expect(result.readiness.model).toBeUndefined();
95
+ });
96
+
97
+ it('callSmallModel throws a structured no-provider-login error', async () => {
98
+ const error = await callSmallModel.callSmallModel({
99
+ auth: {},
100
+ catalog: CATALOG,
101
+ workingDirectory: REPO_DIR,
102
+ providerID: 'deepseek',
103
+ modelID: 'deepseek-v4-flash',
104
+ prompt: 'x',
105
+ }).then(() => null, (e) => e);
106
+
107
+ expect(error).toBeInstanceOf(Error);
108
+ expect(error.message).toBe('No OpenCode login found for provider "deepseek"');
109
+ expect(error.code).toBe('no-provider-login');
110
+ expect(error.statusCode).toBe(401);
111
+ });
112
+
113
+ it('generateWalkthrough rejects with structured no-provider-login', async () => {
114
+ const error = await walkthrough.generateWalkthrough({ directory: REPO_DIR, source: SOURCE })
115
+ .then(() => null, (e) => e);
116
+
117
+ expect(error).toBeInstanceOf(Error);
118
+ expect(error.code).toBe('no-provider-login');
119
+ expect(error.statusCode).toBe(401);
120
+ expect(error.model).toMatchObject({ providerID: 'deepseek', modelID: 'deepseek-v4-flash' });
121
+ });
122
+
123
+ it('answers the generate route with HTTP 401 and code no-provider-login', async () => {
124
+ const service = { ...walkthrough, getPullRequestDiff: async () => { throw new Error('not used'); } };
125
+ const app = express();
126
+ app.use(express.json());
127
+ const { registerWalkthroughRoutes } = await import('./routes.js');
128
+ registerWalkthroughRoutes(app, { getWalkthroughService: async () => service });
129
+
130
+ const server = app.listen(0);
131
+ await new Promise((resolve) => server.once('listening', resolve));
132
+ const base = `http://127.0.0.1:${server.address().port}`;
133
+ try {
134
+ const response = await fetch(`${base}/api/walkthrough/generate`, {
135
+ method: 'POST',
136
+ headers: { 'Content-Type': 'application/json' },
137
+ body: JSON.stringify({ directory: REPO_DIR, source: SOURCE }),
138
+ });
139
+ const body = await response.json();
140
+
141
+ expect(response.status).toBe(401);
142
+ expect(body.code).toBe('no-provider-login');
143
+ expect(body.model).toMatchObject({ providerID: 'deepseek', modelID: 'deepseek-v4-flash' });
144
+ } finally {
145
+ await new Promise((resolve) => server.close(resolve));
146
+ }
147
+ });
148
+ });
@@ -623,4 +623,87 @@ describe('OpenCode proxy SSE forwarding', () => {
623
623
  expect(response.status).toBe(504);
624
624
  await expect(response.json()).resolves.toMatchObject({ error: 'OpenCode upstream timed out' });
625
625
  });
626
+
627
+ it('exempts interactive provider OAuth callbacks from the request deadline', async () => {
628
+ const upstream = express();
629
+ // Stands in for upstream blocking until the user finishes signing in.
630
+ upstream.post('/provider/:providerID/oauth/callback', async (_req, res) => {
631
+ await new Promise((resolve) => setTimeout(resolve, 250));
632
+ res.json(true);
633
+ });
634
+ upstreamServer = await listen(upstream);
635
+ const upstreamPort = upstreamServer.address().port;
636
+ const externalBaseUrl = `http://127.0.0.1:${upstreamPort}`;
637
+
638
+ const app = express();
639
+ registerOpenCodeProxy(app, {
640
+ fs: {},
641
+ os: {},
642
+ path,
643
+ OPEN_CODE_READY_GRACE_MS: 0,
644
+ LONG_REQUEST_TIMEOUT_MS: 50,
645
+ getRuntime: () => ({
646
+ openCodePort: upstreamPort,
647
+ openCodeBaseUrl: externalBaseUrl,
648
+ isOpenCodeReady: true,
649
+ openCodeNotReadySince: 0,
650
+ isRestartingOpenCode: false,
651
+ }),
652
+ getOpenCodeAuthHeaders: () => ({}),
653
+ buildOpenCodeUrl: (requestPath) => `${externalBaseUrl}${requestPath}`,
654
+ ensureOpenCodeApiPrefix: () => {},
655
+ });
656
+ proxyServer = await listen(app);
657
+ const proxyPort = proxyServer.address().port;
658
+
659
+ const response = await fetch(`http://127.0.0.1:${proxyPort}/api/provider/github-copilot/oauth/callback`, {
660
+ method: 'POST',
661
+ headers: { 'content-type': 'application/json' },
662
+ body: JSON.stringify({ method: 0 }),
663
+ signal: AbortSignal.timeout(5000),
664
+ });
665
+
666
+ expect(response.status).toBe(200);
667
+ await expect(response.json()).resolves.toBe(true);
668
+ });
669
+
670
+ it('still applies the request deadline to the OAuth authorize call', async () => {
671
+ const upstream = express();
672
+ upstream.post('/provider/:providerID/oauth/authorize', (_req, _res) => {
673
+ // Leave the response open so the proxy timeout path is exercised.
674
+ });
675
+ upstreamServer = await listen(upstream);
676
+ const upstreamPort = upstreamServer.address().port;
677
+ const externalBaseUrl = `http://127.0.0.1:${upstreamPort}`;
678
+
679
+ const app = express();
680
+ registerOpenCodeProxy(app, {
681
+ fs: {},
682
+ os: {},
683
+ path,
684
+ OPEN_CODE_READY_GRACE_MS: 0,
685
+ LONG_REQUEST_TIMEOUT_MS: 50,
686
+ getRuntime: () => ({
687
+ openCodePort: upstreamPort,
688
+ openCodeBaseUrl: externalBaseUrl,
689
+ isOpenCodeReady: true,
690
+ openCodeNotReadySince: 0,
691
+ isRestartingOpenCode: false,
692
+ }),
693
+ getOpenCodeAuthHeaders: () => ({}),
694
+ buildOpenCodeUrl: (requestPath) => `${externalBaseUrl}${requestPath}`,
695
+ ensureOpenCodeApiPrefix: () => {},
696
+ });
697
+ proxyServer = await listen(app);
698
+ const proxyPort = proxyServer.address().port;
699
+
700
+ const response = await fetch(`http://127.0.0.1:${proxyPort}/api/provider/github-copilot/oauth/authorize`, {
701
+ method: 'POST',
702
+ headers: { 'content-type': 'application/json' },
703
+ body: JSON.stringify({ method: 0 }),
704
+ signal: AbortSignal.timeout(2000),
705
+ });
706
+
707
+ expect(response.status).toBe(504);
708
+ });
626
709
  });