@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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +679 -679
- package/dist/client/static/js/{index-ph0q59rs.js → index-jcr5twtp.js} +769 -767
- package/dist/client/static/js/index-z3w7n85q.css +1 -0
- package/package.json +1 -1
- package/src/client/components/common/Modal.tsx +2 -6
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +23 -7
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +27 -11
- package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
- package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/index.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
- package/src/client/components/workspace/file-explorer/index.tsx +9 -3
- package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
- package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
- package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
- package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
- package/src/client/data/settings/omp-schema.json +4 -4
- package/src/client/hooks/chat/timeline/actions.ts +2 -2
- package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
- package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
- package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
- package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
- package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
- package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
- package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
- package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
- package/src/client/hooks/chat/timeline/send-execute.test.ts +17 -0
- package/src/client/hooks/chat/timeline/send-props.ts +5 -3
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -3
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -1
- package/src/client/hooks/chat/timeline/send.test.ts +1 -3
- package/src/client/hooks/chat/timeline/send.ts +8 -3
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
- package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
- package/src/client/hooks/chat/timeline/session-load.ts +6 -14
- package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
- package/src/client/hooks/models/harness-catalog.ts +114 -0
- package/src/client/hooks/models/provider-writes.test.ts +81 -0
- package/src/client/hooks/models/provider-writes.ts +10 -3
- package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
- package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
- package/src/client/hooks/models/use-harnesses.test.ts +2 -1
- package/src/client/hooks/models/use-harnesses.ts +48 -114
- package/src/client/tailwind.css +9 -1
- package/src/server/lib/harness/acp/activation.test.ts +81 -0
- package/src/server/lib/harness/acp/activation.ts +72 -0
- package/src/server/lib/harness/acp/frames.test.ts +50 -1
- package/src/server/lib/harness/acp/frames.ts +17 -5
- package/src/server/lib/harness/acp/mapper.ts +6 -4
- package/src/server/lib/harness/acp/session-config.test.ts +73 -0
- package/src/server/lib/harness/acp/session-config.ts +87 -6
- package/src/server/lib/harness/acp/session-handshake.ts +9 -2
- package/src/server/lib/harness/acp/session-idle.ts +51 -0
- package/src/server/lib/harness/acp/session-notifications.ts +19 -3
- package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
- package/src/server/lib/harness/acp/session-options.ts +33 -0
- package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
- package/src/server/lib/harness/acp/session.test-util.ts +31 -2
- package/src/server/lib/harness/acp/session.test.ts +65 -3
- package/src/server/lib/harness/acp/session.ts +20 -20
- package/src/server/lib/harness/acp/turn.ts +31 -7
- package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
- package/src/server/lib/harness/auto-probe.server.ts +178 -0
- package/src/server/lib/harness/config.server.test.ts +1 -1
- package/src/server/lib/harness/config.server.ts +1 -1
- package/src/server/lib/harness/launch-table.ts +195 -0
- package/src/server/lib/harness/launch.test.ts +37 -0
- package/src/server/lib/harness/launch.ts +13 -115
- package/src/server/lib/harness/provider-entry.ts +32 -0
- package/src/server/lib/harness/provider-file.server.ts +3 -0
- package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
- package/src/server/lib/harness/provider-sources.server.ts +26 -2
- package/src/server/lib/harness/provider-write.server.ts +21 -32
- package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
- package/src/server/lib/harness/provider-zcode.server.ts +324 -0
- package/src/server/lib/harness/update-state.server.ts +15 -20
- package/src/server/lib/lifecycle/after-listen.ts +7 -0
- package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
- package/src/server/lib/models/registry-refresh.server.ts +98 -0
- package/src/server/lib/omp/rpc/child-config.ts +5 -4
- package/src/server/lib/omp/rpc/constants.test.ts +2 -1
- package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
- package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
- package/src/server/lib/omp/session/delete.server.ts +12 -0
- package/src/server/routes/chat/rewind.test.ts +147 -0
- package/src/server/routes/chat/rewind.ts +29 -7
- package/src/server/routes/chat/session.test.ts +165 -10
- package/src/server/routes/chat/session.ts +60 -7
- package/src/server/routes/harness/import-action.ts +18 -4
- package/src/server/routes/harness/root.ts +8 -49
- package/src/server/routes/harness/toggle.test.ts +20 -0
- package/src/server/routes/harness/update.ts +49 -7
- package/src/server/routes/harness/versions.ts +5 -1
- package/src/server/routes/sessions/delete-acp.test.ts +227 -0
- package/src/server/routes/settings/model-override.ts +5 -2
- package/src/server/routes/settings/provider-entry.ts +2 -2
- package/src/server/routes/settings/provider-model.ts +2 -2
- package/src/server/routes/settings/provider-models.ts +2 -2
- package/src/server/routes/settings/provider-refresh.ts +6 -4
- package/src/server/routes/settings/providers.ts +3 -1
- package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
- package/src/shared/lib/chat/ask-form/fields.ts +76 -0
- package/src/shared/lib/chat/ask-form/index.ts +323 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
- package/src/shared/lib/chat/ask-form/types.ts +43 -0
- package/src/shared/lib/chat/ask-form.test.ts +137 -0
- package/src/shared/lib/chat/ask-questions.test.ts +65 -1
- package/src/shared/lib/chat/ask-questions.ts +51 -145
- package/src/shared/lib/chat/ask-results.ts +198 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
- package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
- package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
- package/src/shared/lib/harness/catalog.test.ts +1 -1
- package/src/shared/lib/harness/config-fields.test.ts +4 -0
- package/src/shared/lib/harness/config-fields.ts +19 -4
- package/src/shared/lib/harness/dialects.test.ts +8 -0
- package/src/shared/lib/harness/dialects.ts +12 -0
- package/src/shared/lib/harness/provider-facts.test.ts +32 -8
- package/src/shared/lib/harness/provider-facts.ts +46 -11
- package/src/shared/lib/harness/providers.ts +9 -0
- package/src/shared/lib/harness/rewind.ts +24 -0
- package/src/shared/lib/harness/update-plan.test.ts +51 -1
- package/src/shared/lib/harness/update-plan.ts +47 -7
- package/src/shared/lib/harness/updates.test.ts +22 -0
- package/src/shared/lib/harness/updates.ts +24 -1
- package/src/shared/lib/models/client.ts +10 -1
- package/src/shared/lib/omp/dialog-methods.ts +4 -3
- package/src/shared/lib/theme/css.ts +2 -0
- package/src/shared/lib/theme/ink-scale.ts +21 -1
- package/src/shared/lib/theme/theme.test.ts +25 -9
- package/src/shared/lib/ui/safe-area.test.ts +28 -0
- package/src/shared/lib/ui/safe-area.ts +42 -0
- package/src/shared/types/harness.ts +30 -4
- package/src/test-support/file-explorer-render.test-util.ts +37 -0
- package/src/test-support/file-explorer.test-util.ts +20 -18
- package/src/test-support/harness-table.test-util.ts +6 -3
- package/dist/client/static/js/index-jhmg4w91.css +0 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Deleting a chat that ran on an ACP harness.
|
|
8
|
+
*
|
|
9
|
+
* An ACP agent writes no session file, so `harness_sessions` IS the row the
|
|
10
|
+
* sidebar draws — and the delete flow used to purge only Kabmo's own tables.
|
|
11
|
+
* Measured before the fix, both failure modes:
|
|
12
|
+
*
|
|
13
|
+
* - a `claude` chat answered 404 "Session not found" and stayed in the
|
|
14
|
+
* sidebar (nothing matched, so the purge reported nothing to remove);
|
|
15
|
+
* - an `omp-acp` chat answered 200 and removed its JSONL, then reappeared
|
|
16
|
+
* from the record the very next sidebar build. Deleting an ARCHIVED ACP
|
|
17
|
+
* chat looked the same: the archive row was purged, the record was not, so
|
|
18
|
+
* the row came back unarchived — the reported "archive is undone by delete".
|
|
19
|
+
*
|
|
20
|
+
* The live child is looked up in the harness-agnostic registry now, so a busy
|
|
21
|
+
* ACP chat is refused rather than removed underneath its own agent, and an idle
|
|
22
|
+
* one is torn down before its rows go.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
|
26
|
+
import fs from 'node:fs';
|
|
27
|
+
import { tmpdir } from 'node:os';
|
|
28
|
+
import { join } from 'node:path';
|
|
29
|
+
|
|
30
|
+
import { getDb } from '@/server/db.server';
|
|
31
|
+
import { saveHarnessSession } from '@/server/lib/harness/session-store.server';
|
|
32
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
33
|
+
import { invalidateOmpSidebarData } from '@/server/lib/omp/session/reader';
|
|
34
|
+
import { loadSidebarStructure } from '@/server/lib/omp/session/sidebar-data.server';
|
|
35
|
+
import { deleteSession } from '@/server/routes/sessions/delete';
|
|
36
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
37
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
38
|
+
|
|
39
|
+
/** The sidebar build spawns `git worktree list` for a folder with sessions. */
|
|
40
|
+
setDefaultTimeout(30_000);
|
|
41
|
+
|
|
42
|
+
const saved = {
|
|
43
|
+
agentDir: Bun.env.PI_CODING_AGENT_DIR,
|
|
44
|
+
mock: Bun.env.MOCK,
|
|
45
|
+
sync: Bun.env.SYNC_WORKSPACE,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let root = '';
|
|
49
|
+
let sessionsRoot = '';
|
|
50
|
+
let project = '';
|
|
51
|
+
let folderId = 0;
|
|
52
|
+
|
|
53
|
+
beforeAll(async () => {
|
|
54
|
+
root = await fs.promises.mkdtemp(join(tmpdir(), 'omc-delete-acp-'));
|
|
55
|
+
const agent = join(root, 'agent');
|
|
56
|
+
sessionsRoot = join(agent, 'sessions');
|
|
57
|
+
await fs.promises.mkdir(sessionsRoot, { recursive: true });
|
|
58
|
+
project = join(root, 'project');
|
|
59
|
+
await fs.promises.mkdir(project, { recursive: true });
|
|
60
|
+
|
|
61
|
+
Bun.env.PI_CODING_AGENT_DIR = agent;
|
|
62
|
+
Bun.env.MOCK = 'false';
|
|
63
|
+
Bun.env.SYNC_WORKSPACE = 'false';
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
afterAll(async () => {
|
|
67
|
+
if (saved.agentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
68
|
+
else Bun.env.PI_CODING_AGENT_DIR = saved.agentDir;
|
|
69
|
+
if (saved.mock === undefined) delete Bun.env.MOCK;
|
|
70
|
+
else Bun.env.MOCK = saved.mock;
|
|
71
|
+
if (saved.sync === undefined) delete Bun.env.SYNC_WORKSPACE;
|
|
72
|
+
else Bun.env.SYNC_WORKSPACE = saved.sync;
|
|
73
|
+
await releaseDb();
|
|
74
|
+
removeDir(root);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
beforeEach(async () => {
|
|
78
|
+
await isolateDb();
|
|
79
|
+
const db = await getDb();
|
|
80
|
+
await db.run('INSERT INTO workspace_folders (name, project_path) VALUES (?, ?)', ['ws', project]);
|
|
81
|
+
const row = await db.get<{ id: number }>('SELECT id FROM workspace_folders ORDER BY id DESC LIMIT 1');
|
|
82
|
+
folderId = Number(row?.id);
|
|
83
|
+
await fs.promises.rm(join(sessionsRoot, 'project'), { recursive: true, force: true });
|
|
84
|
+
invalidateOmpSidebarData();
|
|
85
|
+
clearSessionFileCaches();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
async function deleteSessionRoute(sessionId: string): Promise<Response> {
|
|
89
|
+
return (await deleteSession({
|
|
90
|
+
request: new Request(`http://localhost/api/sessions/${sessionId}`, { method: 'DELETE' }),
|
|
91
|
+
params: { sessionId },
|
|
92
|
+
} as never)) as Response;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The row the sidebar would draw for this id, after a real rebuild. */
|
|
96
|
+
async function sidebarRow(sessionId: string) {
|
|
97
|
+
invalidateOmpSidebarData();
|
|
98
|
+
clearSessionFileCaches();
|
|
99
|
+
const structure = await loadSidebarStructure();
|
|
100
|
+
const folder = structure.folders.find((entry) => Number(entry.id) === folderId);
|
|
101
|
+
return (folder?.sessions ?? []).find((entry) => String(entry.id) === sessionId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** One omp session file: the transcript `omp-acp` writes over ACP. */
|
|
105
|
+
async function writeOmpSession(id: string): Promise<void> {
|
|
106
|
+
const dir = join(sessionsRoot, 'project');
|
|
107
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
108
|
+
const now = new Date().toISOString();
|
|
109
|
+
const lines = [
|
|
110
|
+
JSON.stringify({ type: 'session', id, cwd: project, timestamp: now }),
|
|
111
|
+
JSON.stringify({
|
|
112
|
+
type: 'message', id: `${id}-m1`, parentId: null, timestamp: now,
|
|
113
|
+
message: { role: 'user', content: 'hello' },
|
|
114
|
+
}),
|
|
115
|
+
];
|
|
116
|
+
await Bun.write(join(dir, `${id}.jsonl`), `${lines.join('\n')}\n`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A live session in the shared registry, as a driver would have registered it. */
|
|
120
|
+
function registerLive(session: Record<string, unknown>): void {
|
|
121
|
+
globalThis.__ompSessions ??= new Map();
|
|
122
|
+
globalThis.__ompSessions.set(String(session.sessionId), session as never);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function forgetLive(sessionId: string): void {
|
|
126
|
+
globalThis.__ompSessions?.delete(sessionId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
describe('deleting an ACP chat', () => {
|
|
130
|
+
test('the record is the thing removed — a chat with no transcript is a 200, not a 404', async () => {
|
|
131
|
+
const id = 'ses_acp_only';
|
|
132
|
+
await saveHarnessSession({ sessionId: id, harness: 'opencode', agentSessionId: id, cwd: project });
|
|
133
|
+
expect(await sidebarRow(id)).toBeDefined();
|
|
134
|
+
|
|
135
|
+
const res = await deleteSessionRoute(id);
|
|
136
|
+
expect(res.status).toBe(200);
|
|
137
|
+
|
|
138
|
+
expect(await sidebarRow(id)).toBeUndefined();
|
|
139
|
+
const db = await getDb();
|
|
140
|
+
expect(await db.get('SELECT session_id FROM harness_sessions WHERE session_id = ?', [id])).toBeNull();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('the goal and usage rows keyed to the chat go with it', async () => {
|
|
144
|
+
const id = 'ses_acp_extras';
|
|
145
|
+
await saveHarnessSession({ sessionId: id, harness: 'claude', agentSessionId: id, cwd: project });
|
|
146
|
+
const db = await getDb();
|
|
147
|
+
await db.run('INSERT INTO harness_goal_state (session_id, plan, updated_at) VALUES (?, 1, 1)', [id]);
|
|
148
|
+
await db.run('INSERT INTO harness_usage_state (session_id, updated_at) VALUES (?, 1)', [id]);
|
|
149
|
+
|
|
150
|
+
expect((await deleteSessionRoute(id)).status).toBe(200);
|
|
151
|
+
|
|
152
|
+
// Same final rule as the composer's Context ring: a deleted chat has no
|
|
153
|
+
// stored goal or usage left to answer from a reload.
|
|
154
|
+
expect(await db.get('SELECT session_id FROM harness_goal_state WHERE session_id = ?', [id])).toBeNull();
|
|
155
|
+
expect(await db.get('SELECT session_id FROM harness_usage_state WHERE session_id = ?', [id])).toBeNull();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('an archived ACP chat disappears instead of coming back unarchived', async () => {
|
|
159
|
+
const id = 'ses_acp_archived';
|
|
160
|
+
await saveHarnessSession({ sessionId: id, harness: 'opencode', agentSessionId: id, cwd: project });
|
|
161
|
+
const db = await getDb();
|
|
162
|
+
await db.run('INSERT INTO archived_sessions (session_id) VALUES (?)', [id]);
|
|
163
|
+
expect((await sidebarRow(id))?.is_archived).toBe(1);
|
|
164
|
+
|
|
165
|
+
expect((await deleteSessionRoute(id)).status).toBe(200);
|
|
166
|
+
|
|
167
|
+
// The row is GONE, not merely moved out of the archive view.
|
|
168
|
+
expect(await sidebarRow(id)).toBeUndefined();
|
|
169
|
+
expect(await db.all('SELECT session_id FROM archived_sessions WHERE session_id = ?', [id])).toEqual([]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('an `omp-acp` chat whose JSONL the scan found is not re-listed from its record', async () => {
|
|
173
|
+
const id = '11111111-1111-4111-8111-111111111111';
|
|
174
|
+
await writeOmpSession(id);
|
|
175
|
+
await saveHarnessSession({ sessionId: id, harness: 'omp-acp', agentSessionId: id, cwd: project });
|
|
176
|
+
expect(await sidebarRow(id)).toBeDefined();
|
|
177
|
+
|
|
178
|
+
expect((await deleteSessionRoute(id)).status).toBe(200);
|
|
179
|
+
|
|
180
|
+
expect(await sidebarRow(id)).toBeUndefined();
|
|
181
|
+
expect(fs.existsSync(join(sessionsRoot, 'project', `${id}.jsonl`))).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('a busy ACP chat is refused and left alive', async () => {
|
|
185
|
+
const id = 'ses_acp_busy';
|
|
186
|
+
await saveHarnessSession({ sessionId: id, harness: 'claude', agentSessionId: id, cwd: project });
|
|
187
|
+
let destroyed = false;
|
|
188
|
+
registerLive({
|
|
189
|
+
sessionId: id,
|
|
190
|
+
harness: 'claude',
|
|
191
|
+
isAlive: () => true,
|
|
192
|
+
isBusy: () => true,
|
|
193
|
+
destroyAndWait: async () => { destroyed = true; },
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
const res = await deleteSessionRoute(id);
|
|
198
|
+
expect(res.status).toBe(409);
|
|
199
|
+
expect(await res.json()).toMatchObject({ code: 'session_busy' });
|
|
200
|
+
expect(destroyed).toBe(false);
|
|
201
|
+
expect(await sidebarRow(id)).toBeDefined();
|
|
202
|
+
} finally {
|
|
203
|
+
forgetLive(id);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('an idle live ACP chat is torn down before its rows are purged', async () => {
|
|
208
|
+
const id = 'ses_acp_idle';
|
|
209
|
+
await saveHarnessSession({ sessionId: id, harness: 'claude', agentSessionId: id, cwd: project });
|
|
210
|
+
let destroyed = false;
|
|
211
|
+
registerLive({
|
|
212
|
+
sessionId: id,
|
|
213
|
+
harness: 'claude',
|
|
214
|
+
isAlive: () => true,
|
|
215
|
+
isBusy: () => false,
|
|
216
|
+
destroyAndWait: async () => { destroyed = true; },
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
expect((await deleteSessionRoute(id)).status).toBe(200);
|
|
221
|
+
expect(destroyed).toBe(true);
|
|
222
|
+
expect(await sidebarRow(id)).toBeUndefined();
|
|
223
|
+
} finally {
|
|
224
|
+
forgetLive(id);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -3,7 +3,7 @@ import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
|
3
3
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
4
4
|
import { isMockMode } from '@/server/mock.server';
|
|
5
5
|
import { writeModelOverride, type ReasoningEffort } from '@/server/lib/omp/config/model-overrides';
|
|
6
|
-
import {
|
|
6
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* PUT /api/settings/model-override — the per-model knobs omp actually honours.
|
|
@@ -61,7 +61,10 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
61
61
|
if (isMockMode()) return json({ success: true, written: false, isMock: true });
|
|
62
62
|
|
|
63
63
|
const result = await writeModelOverride({ provider, modelId, maxTokens, reasoningEffort });
|
|
64
|
-
|
|
64
|
+
// A per-model override changes the registry's row metadata, not which models
|
|
65
|
+
// exist — so the readers are recycled, but a stored probe stays valid and
|
|
66
|
+
// the ACP picker does not blank out for an answer that did not change.
|
|
67
|
+
if (result.written) await refreshModelRegistryAfterWrite({ probes: false });
|
|
65
68
|
return json({ success: result.written, ...result });
|
|
66
69
|
} catch (error) {
|
|
67
70
|
return json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 });
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
isProviderAuthMode,
|
|
37
37
|
isProviderDiscoveryType,
|
|
38
38
|
} from '@/shared/lib/models/provider/dialect';
|
|
39
|
-
import {
|
|
39
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* The discovery block from the client: a type plus the knobs that type accepts.
|
|
@@ -100,7 +100,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
100
100
|
if (isMockMode()) return json({ success: true, written: false, isMock: true, changed: [] });
|
|
101
101
|
|
|
102
102
|
const result = await updateOmpProviderEntry(slug, patch);
|
|
103
|
-
if (result.written)
|
|
103
|
+
if (result.written) await refreshModelRegistryAfterWrite({ reprobe: true });
|
|
104
104
|
return json({ success: result.written, ...result }, { status: result.written ? 200 : 400 });
|
|
105
105
|
} catch (error) {
|
|
106
106
|
return json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 });
|
|
@@ -6,7 +6,7 @@ import { upsertOmpProviderModels } from '@/server/lib/omp/config/providers';
|
|
|
6
6
|
import { manualModelSeed } from '@/server/lib/omp/config/provider-seeds';
|
|
7
7
|
import { readNativeProviders } from '@/server/lib/omp/config/models-config';
|
|
8
8
|
import { isProviderAuthMode, isProviderThinkingEffort, modelKindOf } from '@/shared/lib/models/provider/dialect';
|
|
9
|
-
import {
|
|
9
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* POST /api/settings/provider-model — register ONE model by hand.
|
|
@@ -92,7 +92,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
92
92
|
overrideOnly: false,
|
|
93
93
|
models: [seed],
|
|
94
94
|
});
|
|
95
|
-
if (result.written)
|
|
95
|
+
if (result.written) await refreshModelRegistryAfterWrite({ reprobe: true });
|
|
96
96
|
|
|
97
97
|
return json({
|
|
98
98
|
success: result.written || alreadyKnown,
|
|
@@ -3,7 +3,7 @@ import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
|
3
3
|
import { isMockMode } from '@/server/mock.server';
|
|
4
4
|
import { upsertOmpProviderModels } from '@/server/lib/omp/config/providers';
|
|
5
5
|
import { readOmpProviderApiKey } from '@/server/lib/omp/core/auth-credentials';
|
|
6
|
-
import {
|
|
6
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
7
7
|
import {
|
|
8
8
|
enrichFromCatalog,
|
|
9
9
|
fetchRemoteModels,
|
|
@@ -161,7 +161,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
|
|
161
161
|
...(body.replaceModels === true ? { replaceModels: true } : {}),
|
|
162
162
|
models: enriched.map(toOmpSeed),
|
|
163
163
|
});
|
|
164
|
-
if (upsert.written)
|
|
164
|
+
if (upsert.written) await refreshModelRegistryAfterWrite({ reprobe: true });
|
|
165
165
|
omp = {
|
|
166
166
|
written: upsert.written,
|
|
167
167
|
addedCount: upsert.addedModels.length,
|
|
@@ -31,7 +31,7 @@ import { getDb } from '@/server/db.server';
|
|
|
31
31
|
import { refreshModelCatalog } from '@/server/lib/models/catalog.server';
|
|
32
32
|
import { mergeProviders, PROVIDERS_SETTINGS_KEY } from '@/server/lib/models/provider-registry.server';
|
|
33
33
|
import { readSettingsJson } from '@/server/lib/db/settings-store';
|
|
34
|
-
import {
|
|
34
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
35
35
|
import type { ProviderItem } from '@/shared/types';
|
|
36
36
|
|
|
37
37
|
async function readOverlay(): Promise<ProviderItem[]> {
|
|
@@ -63,9 +63,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
63
63
|
if (!result.ok) {
|
|
64
64
|
return json({ success: false, ...result }, { status: 502 });
|
|
65
65
|
}
|
|
66
|
-
// Every listing that moved means the registry did too —
|
|
67
|
-
//
|
|
68
|
-
|
|
66
|
+
// Every listing that moved means the registry did too — recycle the pooled
|
|
67
|
+
// omp child (it caches the catalog it spawned with) and drop the probes that
|
|
68
|
+
// measured the old one, so the chat picker and the role dropdowns see the new
|
|
69
|
+
// rows immediately.
|
|
70
|
+
await refreshModelRegistryAfterWrite({ reprobe: true });
|
|
69
71
|
const merged = await mergeProviders(await readOverlay());
|
|
70
72
|
const changed = slug ? result.changed.filter((entry) => entry.slug === slug) : result.changed;
|
|
71
73
|
return json({
|
|
@@ -10,6 +10,7 @@ import { disableNativeProvider, enableNativeProvider } from '@/server/lib/omp/co
|
|
|
10
10
|
import { removeOmpProvider } from '@/server/lib/omp/config/providers';
|
|
11
11
|
import { PROVIDERS_SETTINGS_KEY as SETTINGS_KEY, deduplicateProviderItems, mergeProviders } from '@/server/lib/models/provider-registry.server';
|
|
12
12
|
import { invalidateModelsCaches } from '@/shared/lib/models/server-cache';
|
|
13
|
+
import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
|
|
13
14
|
|
|
14
15
|
const providersStore = createSettingsListStore<ProviderItem>({
|
|
15
16
|
key: SETTINGS_KEY,
|
|
@@ -173,7 +174,8 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
if (removedFromOmp) await refreshModelRegistryAfterWrite({ reprobe: true });
|
|
178
|
+
else invalidateModelsCaches();
|
|
177
179
|
const after = await mergeProviders(list);
|
|
178
180
|
return json({ success: true, providers: after.providers, removedFromOmp, modelsRemoved });
|
|
179
181
|
}
|
|
@@ -31,6 +31,8 @@ import fs from 'fs';
|
|
|
31
31
|
import os from 'os';
|
|
32
32
|
import path from 'path';
|
|
33
33
|
import { parse as parseYaml } from 'yaml';
|
|
34
|
+
import { closeDb } from '@/server/db.server';
|
|
35
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
34
36
|
import { action as modelOverrideAction } from '@/server/routes/settings/model-override';
|
|
35
37
|
import { action as ompConfigAction, loader as ompConfigLoader } from '@/server/routes/settings/omp-config';
|
|
36
38
|
import { action as providerModelAction } from '@/server/routes/settings/provider-model';
|
|
@@ -58,12 +60,18 @@ afterEach(() => {
|
|
|
58
60
|
fs.rmSync(MODELS_YML, { force: true });
|
|
59
61
|
});
|
|
60
62
|
|
|
61
|
-
afterAll(() => {
|
|
63
|
+
afterAll(async () => {
|
|
64
|
+
// CLOSE the handle, then remove through `removeDir`. A bare `rmSync` with
|
|
65
|
+
// `force: true` reads as infallible and is not: on Windows an open
|
|
66
|
+
// `bun:sqlite` connection holds the temp tree and the delete fails with
|
|
67
|
+
// EBUSY, which reports from an `afterAll` as an unhandled error naming a line
|
|
68
|
+
// nobody can act on. Measured on the Windows gate.
|
|
69
|
+
await closeDb();
|
|
62
70
|
delete Bun.env.PI_CODING_AGENT_DIR;
|
|
63
71
|
delete Bun.env.KABMO_DB_PATH;
|
|
64
72
|
delete Bun.env.SYNC_WORKSPACE;
|
|
65
73
|
delete Bun.env.MOCK;
|
|
66
|
-
|
|
74
|
+
removeDir(ROOT);
|
|
67
75
|
});
|
|
68
76
|
|
|
69
77
|
type Handler = (args: never) => unknown;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The field drafts `ask-form/index.ts` collects while walking a form, and the
|
|
8
|
+
* turn from drafts to the questions the card draws.
|
|
9
|
+
*
|
|
10
|
+
* The question precedence is omp's `fieldQuestions`: the control's own label,
|
|
11
|
+
* else the text block right before it, else its `<fieldset>` legend, else a lone
|
|
12
|
+
* option's label, else the control name. A radio/checkbox group of two or more
|
|
13
|
+
* also gains the `Other (type your own)` row omp's fallback appends, because the
|
|
14
|
+
* card previews the rows the user will actually be offered.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { AskOption, AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
18
|
+
import { oneLine } from '@/shared/lib/chat/ask-form/tokens';
|
|
19
|
+
|
|
20
|
+
/** The "Other" row omp's field-by-field fallback appends to a choice list. */
|
|
21
|
+
const OTHER_LABEL = 'Other (type your own)';
|
|
22
|
+
const OTHER_IN_OPTIONS = /^\s*other\b/i;
|
|
23
|
+
|
|
24
|
+
export interface DraftOption {
|
|
25
|
+
value: string;
|
|
26
|
+
label: string;
|
|
27
|
+
checked: boolean;
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DraftField {
|
|
32
|
+
name: string;
|
|
33
|
+
kind: 'choice' | 'text';
|
|
34
|
+
multi: boolean;
|
|
35
|
+
select: boolean;
|
|
36
|
+
label: string;
|
|
37
|
+
options: DraftOption[];
|
|
38
|
+
/** Text field only. */
|
|
39
|
+
value: string;
|
|
40
|
+
multiline: boolean;
|
|
41
|
+
/** Caption in force when the field appeared, and its section's legend. */
|
|
42
|
+
caption: string;
|
|
43
|
+
section: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Named fields, in document order, as the questions the card renders. */
|
|
47
|
+
export function toQuestions(fields: DraftField[]): AskQuestion[] {
|
|
48
|
+
const questions: AskQuestion[] = [];
|
|
49
|
+
for (const field of fields) {
|
|
50
|
+
if (!field.name) continue;
|
|
51
|
+
const lone = field.kind === 'choice' && field.options.length === 1 ? oneLine(field.options[0].label) : '';
|
|
52
|
+
const question = oneLine(field.label) || field.caption || field.section || lone || field.name;
|
|
53
|
+
const options: AskOption[] = field.options.map((option) => ({
|
|
54
|
+
label: option.label || option.value,
|
|
55
|
+
value: option.value,
|
|
56
|
+
}));
|
|
57
|
+
if (
|
|
58
|
+
field.kind === 'choice' &&
|
|
59
|
+
!field.select &&
|
|
60
|
+
field.options.length >= 2 &&
|
|
61
|
+
!field.options.some((option) => OTHER_IN_OPTIONS.test(option.label))
|
|
62
|
+
) {
|
|
63
|
+
options.push({ label: OTHER_LABEL });
|
|
64
|
+
}
|
|
65
|
+
const checked = field.options.findIndex((option) => option.checked);
|
|
66
|
+
questions.push({
|
|
67
|
+
id: field.name,
|
|
68
|
+
question,
|
|
69
|
+
options,
|
|
70
|
+
multi: field.multi,
|
|
71
|
+
kind: field.kind,
|
|
72
|
+
recommended: field.kind === 'choice' && !field.multi && checked >= 0 ? checked : undefined,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return questions;
|
|
76
|
+
}
|