@kabmo-labs/kabmo 0.23.0 → 0.24.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 (151) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +679 -679
  3. package/dist/client/static/js/{index-ph0q59rs.js → index-jcr5twtp.js} +769 -767
  4. package/dist/client/static/js/index-z3w7n85q.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/Modal.tsx +2 -6
  7. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  8. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
  9. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +23 -7
  10. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  11. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +27 -11
  12. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
  13. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
  14. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  15. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  16. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
  17. package/src/client/components/workspace/chat-timeline/index.tsx +2 -1
  18. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
  19. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  20. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  21. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  22. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  23. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  24. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  25. package/src/client/components/workspace/file-explorer/index.tsx +9 -3
  26. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
  27. package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
  28. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  29. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
  30. package/src/client/data/settings/omp-schema.json +4 -4
  31. package/src/client/hooks/chat/timeline/actions.ts +2 -2
  32. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  33. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  34. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  35. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  36. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  37. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
  38. package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
  39. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  40. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  41. package/src/client/hooks/chat/timeline/send-execute.test.ts +17 -0
  42. package/src/client/hooks/chat/timeline/send-props.ts +5 -3
  43. package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -3
  44. package/src/client/hooks/chat/timeline/send.test-util.ts +1 -1
  45. package/src/client/hooks/chat/timeline/send.test.ts +1 -3
  46. package/src/client/hooks/chat/timeline/send.ts +8 -3
  47. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  48. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  49. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  50. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  51. package/src/client/hooks/models/harness-catalog.ts +114 -0
  52. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  53. package/src/client/hooks/models/provider-writes.ts +10 -3
  54. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  55. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  56. package/src/client/hooks/models/use-harnesses.test.ts +2 -1
  57. package/src/client/hooks/models/use-harnesses.ts +48 -114
  58. package/src/client/tailwind.css +9 -1
  59. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  60. package/src/server/lib/harness/acp/activation.ts +72 -0
  61. package/src/server/lib/harness/acp/frames.test.ts +50 -1
  62. package/src/server/lib/harness/acp/frames.ts +17 -5
  63. package/src/server/lib/harness/acp/mapper.ts +6 -4
  64. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  65. package/src/server/lib/harness/acp/session-config.ts +87 -6
  66. package/src/server/lib/harness/acp/session-handshake.ts +9 -2
  67. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  68. package/src/server/lib/harness/acp/session-notifications.ts +19 -3
  69. package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
  70. package/src/server/lib/harness/acp/session-options.ts +33 -0
  71. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  72. package/src/server/lib/harness/acp/session.test-util.ts +31 -2
  73. package/src/server/lib/harness/acp/session.test.ts +65 -3
  74. package/src/server/lib/harness/acp/session.ts +20 -20
  75. package/src/server/lib/harness/acp/turn.ts +31 -7
  76. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  77. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  78. package/src/server/lib/harness/config.server.test.ts +1 -1
  79. package/src/server/lib/harness/config.server.ts +1 -1
  80. package/src/server/lib/harness/launch-table.ts +195 -0
  81. package/src/server/lib/harness/launch.test.ts +37 -0
  82. package/src/server/lib/harness/launch.ts +13 -115
  83. package/src/server/lib/harness/provider-entry.ts +32 -0
  84. package/src/server/lib/harness/provider-file.server.ts +3 -0
  85. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  86. package/src/server/lib/harness/provider-sources.server.ts +26 -2
  87. package/src/server/lib/harness/provider-write.server.ts +21 -32
  88. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  89. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  90. package/src/server/lib/harness/update-state.server.ts +15 -20
  91. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  92. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  93. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  94. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  95. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  96. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  97. package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
  98. package/src/server/lib/omp/session/delete.server.ts +12 -0
  99. package/src/server/routes/chat/rewind.test.ts +147 -0
  100. package/src/server/routes/chat/rewind.ts +29 -7
  101. package/src/server/routes/chat/session.test.ts +165 -10
  102. package/src/server/routes/chat/session.ts +60 -7
  103. package/src/server/routes/harness/import-action.ts +18 -4
  104. package/src/server/routes/harness/root.ts +8 -49
  105. package/src/server/routes/harness/toggle.test.ts +20 -0
  106. package/src/server/routes/harness/update.ts +49 -7
  107. package/src/server/routes/harness/versions.ts +5 -1
  108. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  109. package/src/server/routes/settings/model-override.ts +5 -2
  110. package/src/server/routes/settings/provider-entry.ts +2 -2
  111. package/src/server/routes/settings/provider-model.ts +2 -2
  112. package/src/server/routes/settings/provider-models.ts +2 -2
  113. package/src/server/routes/settings/provider-refresh.ts +6 -4
  114. package/src/server/routes/settings/providers.ts +3 -1
  115. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  116. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  117. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  118. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  119. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  120. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  121. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  122. package/src/shared/lib/chat/ask-questions.ts +51 -145
  123. package/src/shared/lib/chat/ask-results.ts +198 -0
  124. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  125. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  126. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  127. package/src/shared/lib/harness/catalog.test.ts +1 -1
  128. package/src/shared/lib/harness/config-fields.test.ts +4 -0
  129. package/src/shared/lib/harness/config-fields.ts +19 -4
  130. package/src/shared/lib/harness/dialects.test.ts +8 -0
  131. package/src/shared/lib/harness/dialects.ts +12 -0
  132. package/src/shared/lib/harness/provider-facts.test.ts +32 -8
  133. package/src/shared/lib/harness/provider-facts.ts +46 -11
  134. package/src/shared/lib/harness/providers.ts +9 -0
  135. package/src/shared/lib/harness/rewind.ts +24 -0
  136. package/src/shared/lib/harness/update-plan.test.ts +51 -1
  137. package/src/shared/lib/harness/update-plan.ts +47 -7
  138. package/src/shared/lib/harness/updates.test.ts +22 -0
  139. package/src/shared/lib/harness/updates.ts +24 -1
  140. package/src/shared/lib/models/client.ts +10 -1
  141. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  142. package/src/shared/lib/theme/css.ts +2 -0
  143. package/src/shared/lib/theme/ink-scale.ts +21 -1
  144. package/src/shared/lib/theme/theme.test.ts +25 -9
  145. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  146. package/src/shared/lib/ui/safe-area.ts +42 -0
  147. package/src/shared/types/harness.ts +30 -4
  148. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  149. package/src/test-support/file-explorer.test-util.ts +20 -18
  150. package/src/test-support/harness-table.test-util.ts +6 -3
  151. package/dist/client/static/js/index-jhmg4w91.css +0 -1
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The About card's FRAME, at both sizes.
8
+ *
9
+ * The phone used to get a full-bleed sheet (`h-full w-full`, no gutters), which
10
+ * put the card's own header against the viewport's top edge — under the status
11
+ * bar on a `viewport-fit: cover` surface — and capped the harness list at `46vh`
12
+ * inside it, so the list scrolled while most of the screen sat empty below it.
13
+ *
14
+ * Two things are guarded here, and both are properties of the TREE rather than
15
+ * of a stylesheet: the card is a bounded floating card sized by the same width
16
+ * cap the composer's model picker uses, and the card carries exactly ONE scroll
17
+ * container (its body) — the harness list must not be a second one.
18
+ */
19
+
20
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
21
+ import { Window } from 'happy-dom';
22
+ import { render } from 'preact';
23
+ import { act } from 'preact/test-utils';
24
+ import { AboutModal } from '@/client/components/layout/session-sidebar/about-modal';
25
+ import { MAX_WIDTH } from '@/client/components/workspace/model-dropdown/popover-metrics';
26
+ import { resetHarnessVersions } from '@/client/hooks/models/use-harness-versions';
27
+ import { resetHarnessesStore } from '@/client/hooks/models/harness-catalog';
28
+ import { delay } from '@/client/hooks/chat/composer/file-reads';
29
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
30
+ import type { UseUpdatesResult } from '@/client/hooks/ui/updates';
31
+
32
+ /** A console with nothing to install: this suite reads the frame, not the data. */
33
+ const UPDATES: UseUpdatesResult = {
34
+ info: null,
35
+ checking: false,
36
+ applying: null,
37
+ progress: null,
38
+ error: null,
39
+ hasUpdate: false,
40
+ check: async () => {},
41
+ apply: async () => null,
42
+ };
43
+
44
+ const nativeFetch = globalThis.fetch;
45
+
46
+ beforeAll(() => {
47
+ installDomGlobals(new Window({ url: 'http://localhost' }));
48
+ // Both catalogs are module-level stores: a suite that ran earlier and left a
49
+ // read in flight (or the "already loaded" flag set) makes this card mount
50
+ // against that state instead of its own 501, and the harness list then renders
51
+ // its skeleton forever — the frame assertions still pass, the ROWS assertion
52
+ // does not. Cold stores make the suite order-independent.
53
+ resetHarnessesStore();
54
+ resetHarnessVersions();
55
+ // The card reads two catalogs on mount; a 501 makes both hooks report their
56
+ // error state instead of dialing a server that is not there.
57
+ globalThis.fetch = (async () => ({
58
+ ok: false,
59
+ status: 501,
60
+ json: async () => ({}),
61
+ })) as unknown as typeof fetch;
62
+ });
63
+
64
+ afterAll(() => {
65
+ globalThis.fetch = nativeFetch;
66
+ restoreDomGlobals();
67
+ });
68
+
69
+ let container: HTMLElement | null = null;
70
+
71
+ afterEach(() => {
72
+ if (container) act(() => render(null, container!));
73
+ container?.remove();
74
+ container = null;
75
+ for (const node of Array.from(document.body.children)) node.remove();
76
+ });
77
+
78
+ /** Mount the card and return its `role="dialog"` panel. */
79
+ async function mountCard(): Promise<HTMLElement> {
80
+ container = document.createElement('div');
81
+ document.body.appendChild(container);
82
+ act(() => render(<AboutModal isOpen onClose={() => {}} updates={UPDATES} />, container!));
83
+ // The two catalog reads land after the first paint; the harness list only
84
+ // exists once the store reports it is done loading.
85
+ await act(() => delay(0));
86
+ const panel = document.querySelector('[role="dialog"][aria-label="About Kabmo"]');
87
+ if (!panel) throw new Error('About card did not mount');
88
+ return panel as HTMLElement;
89
+ }
90
+
91
+ describe('the About card frame', () => {
92
+ test('a floating card sized by the model picker’s cap, not the whole screen', async () => {
93
+ const panel = await mountCard();
94
+ // `h-full` was the full-bleed sheet: a card stretched to the screen's top
95
+ // edge is exactly what drew its header under the status bar.
96
+ expect(panel.classList.contains('h-full')).toBe(false);
97
+ expect(panel.style.getPropertyValue('--about-card-max')).toBe(`min(${MAX_WIDTH}px, 100%)`);
98
+ expect(panel.classList.contains('max-h-full')).toBe(true);
99
+ expect(panel.classList.contains('rounded-2xl')).toBe(true);
100
+ });
101
+
102
+ test('the card is centered with a capped height, never stretched', async () => {
103
+ const panel = await mountCard();
104
+ const backdrop = panel.parentElement!;
105
+ // `items-stretch` + `h-full` was the sheet; a stretched card has no gutter to
106
+ // keep the safe area clear, and no height cap to scroll inside.
107
+ expect(backdrop.className).toContain('items-center');
108
+ expect(backdrop.className).not.toContain('items-stretch');
109
+ expect(panel.classList.contains('max-h-full')).toBe(true);
110
+ });
111
+
112
+ test('exactly ONE scroll container inside the card', async () => {
113
+ const panel = await mountCard();
114
+ const scrollers = panel.querySelectorAll('.scrollbar-overlay-container');
115
+ expect(scrollers).toHaveLength(1);
116
+ // …and the harness list is not it.
117
+ const list = panel.querySelector('[data-harness-rows]');
118
+ expect(list).not.toBeNull();
119
+ expect(list!.classList.contains('scrollbar-overlay-container')).toBe(false);
120
+ expect(list!.classList.contains('overflow-y-auto')).toBe(false);
121
+ });
122
+ });
@@ -15,6 +15,8 @@ import { useHarnessVersions } from '@/client/hooks/models/use-harness-versions';
15
15
  import { useDialogBehaviour } from '@/client/hooks/ui/dialog-behaviour';
16
16
  import { UPDATE_POPUP_OPEN_EVENT } from '@/shared/lib/updates/popup-state';
17
17
  import type { UpdateTarget } from '@/shared/types/updates';
18
+ import { MAX_WIDTH as CARD_MAX_WIDTH } from '@/client/components/workspace/model-dropdown/popover-metrics';
19
+ import { safeAreaPadding } from '@/shared/lib/ui/safe-area';
18
20
 
19
21
  export interface AboutModalProps {
20
22
  isOpen: boolean;
@@ -89,15 +91,20 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
89
91
  // closed, and was invisible.
90
92
  return createPortal(
91
93
  <>
92
- {/* PHONE: the whole screen, one column, and it scrolls. DESKTOP: a wide
93
- two-column card sized to its CONTENT, so nothing scrolls at all.
94
+ {/* ONE centered card at both sizes, sized like the composer's model
95
+ picker: the phone gets its own width cap (the popover's 512px) instead
96
+ of the whole screen, and the card is as TALL as its content up to the
97
+ space the safe area leaves — so nothing hides under the status bar or
98
+ the home indicator, and a short card never asks for a scroll.
94
99
 
95
- The two are one dialog with two frames, chosen by `md`: a 390px phone has
96
- no room for a table beside a sidebar, and a desktop card that needs a
97
- scrollbar to show fourteen rows is hiding information it has the space
98
- to show. */}
100
+ Full-bleed on a phone was the bug: `h-full w-full` with no gutters put
101
+ the header at the viewport's top edge, which a `viewport-fit: cover`
102
+ surface draws UNDER the phone's status bar. The scrim's padding is
103
+ `safeAreaPadding` — one rule, shared with the `Modal` shell. The
104
+ desktop keeps its FIXED 880px two-column card. */}
99
105
  <div
100
- className="fixed inset-0 modal-scrim z-50 flex items-stretch justify-center p-0 md:items-center md:backdrop-blur-[2px] md:p-6 animate-in fade-in duration-200"
106
+ className="fixed inset-0 modal-scrim z-50 flex items-center justify-center md:backdrop-blur-[2px] animate-in fade-in duration-200"
107
+ style={safeAreaPadding()}
101
108
  onClick={onClose}
102
109
  >
103
110
  <div
@@ -110,7 +117,12 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
110
117
  // when auto, so narrowing any one column shrank the whole dialog
111
118
  // (measured when the action column went to an icon). 880px is what the
112
119
  // two-column table needs with room for the widest agent name.
113
- className="glass-overlay relative flex h-full w-full flex-col overflow-hidden border-ink/15 bg-paper text-ink md:h-auto md:max-h-[92vh] md:w-[880px] md:max-w-[calc(100vw-3rem)] md:rounded-2xl md:border md:shadow-2xl select-none"
120
+ //
121
+ // The phone cap is the MODEL PICKER's own width (`MAX_WIDTH`), so the
122
+ // console's two floating cards are one size class; `min(…, 100%)` keeps
123
+ // a 320px phone from overflowing the backdrop padding.
124
+ className="glass-overlay relative flex max-h-full w-full max-w-[var(--about-card-max)] flex-col overflow-hidden rounded-2xl border border-ink/15 bg-paper text-ink shadow-2xl select-none md:w-[880px] md:max-w-[calc(100vw-3rem)] md:max-h-[92vh]"
125
+ style={{ '--about-card-max': `min(${CARD_MAX_WIDTH}px, 100%)` }}
114
126
  onClick={(e) => e.stopPropagation()}
115
127
  >
116
128
  {/* Close Button */}
@@ -122,9 +134,13 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
122
134
  <X size={18} className="stroke-[2.5]" />
123
135
  </button>
124
136
 
125
- {/* ONE scroller, on the phone only. On a desktop the card sizes itself
126
- to the content instead of asking the reader to scroll a dialog. */}
127
- <div className="scrollbar-overlay-container flex-1 overflow-y-auto p-5 md:flex-none md:overflow-visible md:p-6">
137
+ {/* ONE scroller for the WHOLE card, at both sizes: the harness table
138
+ used to cap itself at `46vh` and scroll on a phone while the card
139
+ still had most of the screen empty below it. The body is the only
140
+ place a scroll can happen now, and only when the content genuinely
141
+ outgrows the card. On a desktop the card sizes itself to the content
142
+ instead of asking the reader to scroll a dialog. */}
143
+ <div className="min-h-0 flex-1 scrollbar-overlay-container overflow-y-auto p-5 md:flex-none md:overflow-visible md:p-6">
128
144
  <header className="flex items-center gap-3 pr-10">
129
145
  <img src="/icon.svg" alt="Kabmo" width={44} height={44} draggable={false} />
130
146
  <div className="min-w-0">
@@ -29,12 +29,16 @@ export function EnvProviderForm({ support, onSave }: { support: HarnessProviderS
29
29
  const [baseUrl, setBaseUrl] = useState('');
30
30
  const [apiKey, setApiKey] = useState('');
31
31
  const [model, setModel] = useState('');
32
+ /** One value per `ANTHROPIC_DEFAULT_*_MODEL`-style variable, keyed by name. */
33
+ const [aliases, setAliases] = useState<Record<string, string>>({});
32
34
  const [saving, setSaving] = useState(false);
33
35
  const [problem, setProblem] = useState<string | null>(null);
34
36
  const env = support.env;
35
37
 
36
38
  if (!env) return null;
37
39
 
40
+ const modelAliases = env.modelAliases ?? [];
41
+
38
42
  const save = async () => {
39
43
  setSaving(true);
40
44
  try {
@@ -42,6 +46,10 @@ export function EnvProviderForm({ support, onSave }: { support: HarnessProviderS
42
46
  baseUrl.trim() ? `${env.baseUrl}=${baseUrl.trim()}` : '',
43
47
  apiKey.trim() ? `${env.apiKey}=${apiKey.trim()}` : '',
44
48
  env.model && model.trim() ? `${env.model}=${model.trim()}` : '',
49
+ ...modelAliases.map((alias) => {
50
+ const value = aliases[alias.env]?.trim();
51
+ return value ? `${alias.env}=${value}` : '';
52
+ }),
45
53
  ].filter(Boolean).join('\n');
46
54
  // The ANSWER is what decides success. Reading the `problem` state here held
47
55
  // the PREVIOUS save's value, so a successful save reported failure.
@@ -51,6 +59,7 @@ export function EnvProviderForm({ support, onSave }: { support: HarnessProviderS
51
59
  setBaseUrl('');
52
60
  setApiKey('');
53
61
  setModel('');
62
+ setAliases({});
54
63
  }
55
64
  } finally {
56
65
  setSaving(false);
@@ -100,6 +109,28 @@ export function EnvProviderForm({ support, onSave }: { support: HarnessProviderS
100
109
  />
101
110
  </label>
102
111
  )}
112
+ {modelAliases.length > 0 && (
113
+ <div className="space-y-1.5 rounded-md border border-ink/15 bg-ink/[0.03] p-2">
114
+ <div className="text-[10px] leading-relaxed text-ink/60">
115
+ Each picker alias resolves to a model id the vendor ships unless it is pinned here.
116
+ Leave an alias blank when the endpoint serves that family's vendor id; fill it when
117
+ the endpoint has its own ids — otherwise that pick sends
118
+ {' '}<span className="font-mono">400 model not found</span>.
119
+ </div>
120
+ {modelAliases.map((alias) => (
121
+ <label key={alias.env} className="flex flex-col gap-1">
122
+ <span className="font-mono text-[10px] text-ink/50">{alias.env}</span>
123
+ <input
124
+ type="text"
125
+ value={aliases[alias.env] ?? ''}
126
+ placeholder={`the endpoint's ${alias.family} model id`}
127
+ onInput={(e) => setAliases((prev) => ({ ...prev, [alias.env]: e.currentTarget.value }))}
128
+ className={INPUT_CLASS}
129
+ />
130
+ </label>
131
+ ))}
132
+ </div>
133
+ )}
103
134
 
104
135
  <button
105
136
  type="button"
@@ -197,6 +197,55 @@ describe('the env form', () => {
197
197
  // was a JSX-precompile hazard, not a style choice.
198
198
  expect(container.querySelector('input')?.getAttribute('class')).toContain('font-mono');
199
199
  });
200
+
201
+ test('each alias field writes its own variable; a blank one writes nothing', async () => {
202
+ let saved = '';
203
+ render(
204
+ h(HarnessProviderPanel, {
205
+ support: support({
206
+ level: 'environment',
207
+ env: {
208
+ baseUrl: 'ANTHROPIC_BASE_URL',
209
+ apiKey: 'ANTHROPIC_AUTH_TOKEN',
210
+ model: 'ANTHROPIC_MODEL',
211
+ modelAliases: [
212
+ { family: 'sonnet', env: 'ANTHROPIC_DEFAULT_SONNET_MODEL' },
213
+ { family: 'haiku', env: 'ANTHROPIC_DEFAULT_HAIKU_MODEL' },
214
+ ],
215
+ },
216
+ protocols: ['anthropic-messages'],
217
+ importable: [],
218
+ }),
219
+ onSaveEnv: async (env) => {
220
+ saved = env;
221
+ return null;
222
+ },
223
+ }),
224
+ container,
225
+ );
226
+ const inputs = [...container.querySelectorAll('input')] as HTMLInputElement[];
227
+ expect(inputs).toHaveLength(5);
228
+ await act(async () => {
229
+ const values = ['https://kenari.id', 'kn-key', 'qwen3-8-27b:free', 'claude-sonnet-5-5', ''];
230
+ inputs.forEach((input, index) => {
231
+ input.value = values[index]!;
232
+ input.dispatchEvent(new Event('input', { bubbles: true }));
233
+ });
234
+ });
235
+ const save = buttons().find((button) => button.textContent?.includes('Save to environment'))!;
236
+ await act(async () => {
237
+ save.click();
238
+ await Promise.resolve();
239
+ await Promise.resolve();
240
+ });
241
+ expect(saved).toBe([
242
+ 'ANTHROPIC_BASE_URL=https://kenari.id',
243
+ 'ANTHROPIC_AUTH_TOKEN=kn-key',
244
+ 'ANTHROPIC_MODEL=qwen3-8-27b:free',
245
+ 'ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5',
246
+ ].join('\n'));
247
+ expect([...container.querySelectorAll('input')].every((input) => input.value === '')).toBe(true);
248
+ });
200
249
  });
201
250
 
202
251
  describe('the add-provider form', () => {
@@ -34,8 +34,10 @@ export interface ChatOverlaysProps {
34
34
 
35
35
  newChatInitialContent: string | null;
36
36
  newChatInitialAttachments: Attachment[];
37
+ /** The source chat's harness, carried onto the new chat's spawn. */
38
+ newChatHarness?: string;
37
39
  onCloseNewChat: () => void;
38
- onSendNewChat: (content: string, attachments: Attachment[]) => void;
40
+ onSendNewChat: (content: string, attachments: Attachment[], harness?: string) => void;
39
41
  appSettings: Record<string, unknown>;
40
42
  accessMode: ApprovalMode;
41
43
  onAccessModeChange: (mode: ApprovalMode) => void;
@@ -56,6 +58,7 @@ export function ChatOverlays({
56
58
  isOmpSession,
57
59
  newChatInitialContent,
58
60
  newChatInitialAttachments,
61
+ newChatHarness,
59
62
  onCloseNewChat,
60
63
  onSendNewChat,
61
64
  appSettings,
@@ -84,7 +87,7 @@ export function ChatOverlays({
84
87
  initialContent={newChatInitialContent}
85
88
  initialAttachments={newChatInitialAttachments}
86
89
  onClose={onCloseNewChat}
87
- onSend={onSendNewChat}
90
+ onSend={(content, attachments) => onSendNewChat(content, attachments, newChatHarness)}
88
91
  appSettings={appSettings}
89
92
  accessMode={accessMode}
90
93
  onAccessModeChange={onAccessModeChange}
@@ -132,4 +132,18 @@ describe('MessageList mounted window', () => {
132
132
  const el = await mountWindowed(messages, window(0, 2, 0, 500));
133
133
  expect(footers(el)).toBe(1);
134
134
  });
135
+
136
+ test('an errored answer renders the failure instead of an empty bubble', async () => {
137
+ const el = await mount([
138
+ user('u1'),
139
+ {
140
+ id: 'a1',
141
+ role: 'ai',
142
+ content: '',
143
+ error: { message: 'The agent ended the turn without sending an answer' },
144
+ },
145
+ ], false);
146
+ expect(el.textContent).toContain('Request Failed');
147
+ expect(el.textContent).toContain('without sending an answer');
148
+ });
135
149
  });
@@ -76,13 +76,14 @@ export function ChatInput({
76
76
  const [composerFocused, setComposerFocused] = useState(false);
77
77
  const cardRef = useRef<HTMLDivElement>(null);
78
78
 
79
- const { harnesses } = useHarnesses();
79
+ const { harnesses, liveModels } = useHarnesses();
80
80
  // The ACTIVE agent's own catalog. omp's registry is not a stand-in: no ACP
81
81
  // harness shares its ids, and matching a session model against it left the
82
82
  // composer naming a model the agent never ran.
83
+ const live = harness ? liveModels[harness] : undefined;
83
84
  const scopedModels = useMemo(
84
- () => (harness && harness !== 'omp-rpc' ? harnessModels(harnesses, harness).models : null),
85
- [harness, harnesses],
85
+ () => (harness && harness !== 'omp-rpc' ? harnessModels(harnesses, harness, [], live).models : null),
86
+ [harness, harnesses, live],
86
87
  );
87
88
 
88
89
  const { selectedModel, setSelectedModel, thinkingLevels, currentThinking, selectThinking } = useModelSelection({
@@ -113,7 +113,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
113
113
  [framesByTool, orphanAsks, respondToFrame],
114
114
  );
115
115
 
116
- const newChat = useNewChatOpen({ folders, sessionId, selectedFolderId });
116
+ const newChat = useNewChatOpen({ folders, sessionId, selectedFolderId, ...(activeHarness.harness ? { harness: activeHarness.harness } : {}) });
117
117
  const { pendingUndo, undoing, error: undoError, requestUndo: handleRequestUndo, closeUndoConfirm, confirmUndo } = useUndoConfirmation(handleUndo);
118
118
  const [searchParams, setSearchParams] = useSearchParams();
119
119
 
@@ -330,6 +330,7 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
330
330
  isOmpSession={Boolean(sessionId) && !sessionId.startsWith('new-') && Number.isNaN(Number(sessionId))}
331
331
  newChatInitialContent={newChat.content}
332
332
  newChatInitialAttachments={newChat.attachments}
333
+ newChatHarness={newChat.harness}
333
334
  onCloseNewChat={newChat.close}
334
335
  onSendNewChat={submitNewChat}
335
336
  appSettings={appSettings}
@@ -25,7 +25,7 @@ import { act } from 'preact/test-utils';
25
25
  import { EmptyWorkspacePrompt } from '@/client/components/workspace/chat-timeline/EmptyWorkspacePrompt';
26
26
  import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
27
27
  import { silenceRealtime, restoreRealtime } from '@/test-support/silent-socket';
28
- import { resetHarnessesStore } from '@/client/hooks/models/use-harnesses';
28
+ import { resetHarnessesStore } from '@/client/hooks/models/harness-catalog';
29
29
  import { invalidateModelsCache } from '@/shared/lib/models/client';
30
30
  import type { HarnessSummary } from '@/shared/types/harness';
31
31
 
@@ -76,7 +76,7 @@ export function FrameControl({ frame, multi, selected, onAnswer, onToggle, onRes
76
76
  <textarea
77
77
  autoFocus
78
78
  value={text}
79
- onChange={(event) => setText(event.currentTarget.value)}
79
+ onInput={(event) => setText(event.currentTarget.value)}
80
80
  rows={4}
81
81
  placeholder={frame.placeholder || 'Type your answer…'}
82
82
  className="w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 font-mono text-[11.5px] leading-relaxed text-ink outline-none focus:border-ink"
@@ -87,7 +87,7 @@ export function FrameControl({ frame, multi, selected, onAnswer, onToggle, onRes
87
87
  type={frame.secret === true ? 'password' : 'text'}
88
88
  value={text}
89
89
  placeholder={frame.placeholder || 'Type your answer…'}
90
- onChange={(event) => setText(event.currentTarget.value)}
90
+ onInput={(event) => setText(event.currentTarget.value)}
91
91
  onKeyDown={(event) => {
92
92
  if (event.key !== 'Enter') return;
93
93
  event.preventDefault();
@@ -115,9 +115,6 @@ export function FrameControl({ frame, multi, selected, onAnswer, onToggle, onRes
115
115
  return (
116
116
  <div className="mt-2 space-y-1" role={multi ? 'group' : 'radiogroup'}>
117
117
  {options.map((label, index) => {
118
- // A single-choice question resolves "Other" to the typed text, so the
119
- // row itself is a prompt to type — never a literal answer.
120
- if (!multi && isOtherOption(label)) return null;
121
118
  const checked = multi && selected.includes(label);
122
119
  const finish = multi && DONE_ROW.test(label);
123
120
  return (
@@ -129,24 +126,18 @@ export function FrameControl({ frame, multi, selected, onAnswer, onToggle, onRes
129
126
  checked={checked}
130
127
  suggested={RECOMMENDED.test(label) && !multi}
131
128
  emphasis={finish}
132
- onClick={() => (multi ? (finish ? onRespond({ value: label }) : onToggle(label)) : onAnswer(label))}
129
+ onClick={() => {
130
+ // 18.18.3 accepts only a label it OFFERED: a typed answer sent in
131
+ // place of the "Other" row matches no index and cancels the whole
132
+ // ask. Choosing the row is what opens omp's free-text `input`, and
133
+ // that dialog answers in the same question's group.
134
+ if (!multi && isOtherOption(label)) onRespond({ value: label });
135
+ else if (multi) (finish ? onRespond({ value: label }) : onToggle(label));
136
+ else onAnswer(label);
137
+ }}
133
138
  />
134
139
  );
135
140
  })}
136
-
137
- {!multi && (
138
- <input
139
- value={text}
140
- placeholder="Other: type your own answer…"
141
- onChange={(event) => setText(event.currentTarget.value)}
142
- onKeyDown={(event) => {
143
- if (event.key !== 'Enter' || !text.trim()) return;
144
- event.preventDefault();
145
- onAnswer(text.trim());
146
- }}
147
- className="w-full rounded-md border border-ink/15 bg-canvas/40 px-2.5 py-1.5 text-[11.5px] text-ink outline-none focus:border-ink"
148
- />
149
- )}
150
141
  </div>
151
142
  );
152
143
  }
@@ -32,7 +32,7 @@ import { useMemo, useState } from 'preact/hooks';
32
32
  import type { ComponentChildren } from 'preact';
33
33
  import { CornerDownLeft } from 'lucide-preact';
34
34
  import type { ExtensionAskQuestion, ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
35
- import type { AskAnswer } from '@/shared/lib/chat/ask-questions';
35
+ import type { AskAnswer } from '@/shared/lib/chat/ask-form/types';
36
36
  import { AnswerList, QuestionCard } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard';
37
37
  import { OptionRow } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow';
38
38
  import type { ExtensionDialogResponse } from '@/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Lazy';
@@ -18,7 +18,7 @@
18
18
  import { Ban, CheckCircle2, Clock } from 'lucide-preact';
19
19
  import type { ComponentChildren } from 'preact';
20
20
  import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
21
- import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-questions';
21
+ import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-form/types';
22
22
  import { FrameControl } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl';
23
23
  import { AnswerList, QuestionCard } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard';
24
24
  import type { ExtensionDialogResponse } from '@/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Lazy';
@@ -20,7 +20,7 @@
20
20
 
21
21
  import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
22
22
  import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
23
- import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-questions';
23
+ import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-form/types';
24
24
  import type { ExtensionDialogResponse } from '@/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Lazy';
25
25
 
26
26
  interface UseAskDraftsOptions {
@@ -26,7 +26,8 @@ import { useState } from 'preact/hooks';
26
26
  import { HelpCircle, XCircle } from 'lucide-preact';
27
27
  import type { ToolCallData } from '@/shared/types';
28
28
  import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
29
- import { isAskSettled, parseAskQuestions, parseAskResult } from '@/shared/lib/chat/ask-questions';
29
+ import { isAskSettled, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
30
+ import { parseAskResult } from '@/shared/lib/chat/ask-results';
30
31
  import { useAskFrames } from '@/client/hooks/chat/timeline/ask-frames';
31
32
  import { liveFrame, useAskDrafts } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts';
32
33
  import { QuestionBlock } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock';
@@ -60,6 +60,31 @@ describe('Files panel listing', () => {
60
60
  expect(panel.container.textContent).toContain('keep.ts');
61
61
  });
62
62
 
63
+ test('reopening the panel re-reads the root and the open folders, so hidden-time edits appear', async () => {
64
+ panel.disk = { '.': { src: null }, src: { 'keep.ts': 'file', 'gone.ts': 'file' } };
65
+ panel.dirReads = [];
66
+ await panel.mount();
67
+ await panel.clickRow('src');
68
+ expect(panel.container.textContent).toContain('gone.ts');
69
+
70
+ // The right column is collapsed, or another view is on screen: the layout
71
+ // keeps this panel MOUNTED and hidden, so nothing here reads while the
72
+ // filesystem moves underneath it.
73
+ await panel.setActive(false);
74
+ delete panel.disk['src']!['gone.ts'];
75
+ panel.disk['.']!['added.ts'] = 'file';
76
+ panel.dirReads = [];
77
+
78
+ await panel.setActive(true);
79
+
80
+ // Reopening IS a read — of the root AND of every folder still expanded —
81
+ // so the deleted row is gone and the new one is drawn.
82
+ expect(panel.dirReads).toContain('.');
83
+ expect(panel.dirReads).toContain('src');
84
+ expect(panel.container.textContent).toContain('added.ts');
85
+ expect(panel.container.textContent).not.toContain('gone.ts');
86
+ });
87
+
63
88
  test('an expanded empty folder is read once, and expanding a sibling does not re-read it', async () => {
64
89
  panel.disk = { '.': { empty: null, keep: null }, empty: {}, keep: { 'a.ts': 'file' } };
65
90
  panel.dirReads = [];
@@ -21,7 +21,7 @@ import { fsTopic } from '@/shared/lib/realtime/protocol';
21
21
  import { unfoldChains } from '@/shared/lib/fs/folder-chain';
22
22
  import { useRootDropTarget } from '@/client/hooks/workspace/root-drop-target';
23
23
 
24
- export function FileExplorer({ className = '', enabled = true, rootPath, onOpenFile, refreshKey = 0, onRefresh }: { className?: string, enabled?: boolean, rootPath?: string, onOpenFile?: (file: any) => void, refreshKey?: number, onRefresh?: () => void }) {
24
+ export function FileExplorer({ className = '', enabled = true, active = true, rootPath, onOpenFile, refreshKey = 0, onRefresh }: { className?: string, enabled?: boolean, active?: boolean, rootPath?: string, onOpenFile?: (file: any) => void, refreshKey?: number, onRefresh?: () => void }) {
25
25
  const [searchQuery, setSearchQuery] = useSessionState<string>('files.searchQuery', '');
26
26
  const [storedExpandedPaths, setStoredExpandedPaths, expandedPathsReady] = useSessionState<string[]>('files.expandedPaths', []);
27
27
  const [expandedPaths, setExpandedPaths] = useState<Set<string>>(() => new Set(storedExpandedPaths));
@@ -56,12 +56,18 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
56
56
  });
57
57
 
58
58
  useEffect(() => {
59
- if (!expandedPathsReady) return;
59
+ if (!expandedPathsReady || !active) return;
60
60
  void listing.reload();
61
61
  // `listing.reload` reads the current scope and expansion set off refs, so
62
62
  // the effect is keyed on what should trigger a read, not on the callback.
63
+ // `active` is one of them: the layout keeps this view MOUNTED while the
64
+ // right column is collapsed (or another view is on screen), so without it a
65
+ // reopened panel would draw the tree it read when it was last looked at —
66
+ // a file added, deleted or renamed outside this panel in between would not
67
+ // be there. While inactive the panel starts no reload of its own; being
68
+ // shown again IS the read.
63
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
- }, [refreshKey, rootPath, enabled, activeRepo, expandedPathsReady]);
70
+ }, [refreshKey, rootPath, enabled, activeRepo, expandedPathsReady, active]);
65
71
 
66
72
  // The ROOT listing rides the `fs:<root>\0<repo>` topic: the server pushes a
67
73
  // fresh read when a run's work may have touched the tree. Expanded CHILDREN
@@ -124,6 +124,23 @@ describe('harness model lists', () => {
124
124
  const list = harnessModels([probed('claude', [{ value: 'opus', name: 'Opus' }])], 'claude', ompModels);
125
125
  expect(list.models[0]?.thinkingLevels).toBeUndefined();
126
126
  });
127
+
128
+ test('the open chat’s own lists outrank the one-spawn probe', () => {
129
+ // codex refuses a probe while a chat runs, and the probe's blocked message
130
+ // then sat beside rows that chat was already offering.
131
+ const summary: HarnessSummary = {
132
+ id: 'codex', label: 'codex', transport: 'acp', canLaunch: true, enabled: true,
133
+ probe: probed('codex', [{ value: 'probe-only', name: 'Probe only' }]).probe,
134
+ unavailable: 'Probe refused',
135
+ };
136
+ const list = harnessModels([summary], 'codex', ompModels, {
137
+ models: [{ value: 'openai/gpt-5', name: 'GPT-5' }],
138
+ thinking: [{ value: 'medium', name: 'Medium' }],
139
+ });
140
+ expect(list.models.map((model) => model.id)).toEqual(['gpt-5']);
141
+ expect(list.models[0]?.thinkingLevels).toEqual(['medium']);
142
+ expect(list.blocked).toBeUndefined();
143
+ });
127
144
  });
128
145
 
129
146
  describe('which harnesses the picker offers', () => {