@steerable/agent-shell-web 0.14.5 → 0.14.7
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/package.json +4 -4
- package/src/components/AgentSidebar.tsx +6 -2
- package/src/components/ChatHeader.tsx +17 -2
- package/src/components/chat/AssistantMessage.tsx +60 -1
- package/src/components/chat/ChatInput.tsx +16 -4
- package/src/components/chat/LocalChatPanel.tsx +32 -1
- package/src/components/chat/MemorySaveNoticeBar.tsx +24 -3
- package/src/components/chat/MessageList.tsx +6 -0
- package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
- package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
- package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
- package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
- package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
- package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
- package/src/components/settings/LlmSettingsPanel.tsx +22 -2
- package/src/components/settings/McpSettingsPanel.tsx +4 -5
- package/src/components/settings/MemorySettingsPanel.tsx +302 -169
- package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
- package/src/components/settings/PortableSettingsPanel.tsx +62 -49
- package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
- package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
- package/src/components/settings/SettingsSidebar.tsx +238 -0
- package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
- package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
- package/src/components/settings/UsagePanel.tsx +27 -35
- package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
- package/src/components/settings/primitives.tsx +302 -0
- package/src/components/settings/settings-registry.ts +371 -0
- package/src/layouts/AgentLayout.tsx +106 -6
- package/src/lib/chat-draft-store.ts +43 -0
- package/src/lib/chat-mode-store.ts +27 -0
- package/src/lib/chat-title.ts +13 -0
- package/src/lib/local-api.ts +35 -0
- package/src/packs/registry.ts +2 -0
- package/src/pages/AgentPage.tsx +333 -3
- package/src/pages/SettingsPage.tsx +337 -487
- package/src/styles/index.css +6 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { LuCheck, LuLoaderCircle } from 'react-icons/lu';
|
|
2
3
|
import { t } from '@/i18n';
|
|
3
4
|
import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
|
|
5
|
+
import {
|
|
6
|
+
SettingRow,
|
|
7
|
+
SettingSection,
|
|
8
|
+
SettingSegmented,
|
|
9
|
+
} from './primitives';
|
|
4
10
|
|
|
5
11
|
export type MemoryScopeTab = 'user' | 'workspace' | 'tenant';
|
|
6
12
|
export type MemoryPermissionMode = 'off' | 'ask' | 'auto';
|
|
@@ -84,19 +90,32 @@ async function requestMemoryApi(
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
export interface MemorySettingsPanelProps {
|
|
93
|
+
initialScope?: MemoryScopeTab;
|
|
87
94
|
workspaceId?: string;
|
|
95
|
+
defaultProjectId?: string;
|
|
88
96
|
showTenantTab?: boolean;
|
|
89
97
|
isAdmin?: boolean;
|
|
90
98
|
}
|
|
91
99
|
|
|
100
|
+
interface WorkspaceProjectOption {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
folderPath: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
92
106
|
export function MemorySettingsPanel({
|
|
107
|
+
initialScope,
|
|
93
108
|
workspaceId = 'default',
|
|
109
|
+
defaultProjectId,
|
|
94
110
|
showTenantTab = false,
|
|
95
111
|
isAdmin = true,
|
|
96
112
|
}: MemorySettingsPanelProps) {
|
|
97
|
-
const [scope, setScope] = useState<MemoryScopeTab>('user');
|
|
113
|
+
const [scope, setScope] = useState<MemoryScopeTab>(initialScope ?? 'user');
|
|
114
|
+
const [selectedWorkspaceId, setSelectedWorkspaceId] = useState<string>(workspaceId || 'default');
|
|
115
|
+
const [projects, setProjects] = useState<WorkspaceProjectOption[]>([]);
|
|
98
116
|
const [permissionMode, setPermissionMode] = useState<MemoryPermissionMode>('ask');
|
|
99
117
|
const [markdown, setMarkdown] = useState('');
|
|
118
|
+
const [savedMarkdown, setSavedMarkdown] = useState('');
|
|
100
119
|
const [baseHash, setBaseHash] = useState('');
|
|
101
120
|
const [bytesUsed, setBytesUsed] = useState(0);
|
|
102
121
|
const [maxBytes, setMaxBytes] = useState(16384);
|
|
@@ -104,19 +123,68 @@ export function MemorySettingsPanel({
|
|
|
104
123
|
const [revokedHashes, setRevokedHashes] = useState<string[]>([]);
|
|
105
124
|
const [conflictBanner, setConflictBanner] = useState(false);
|
|
106
125
|
const [saving, setSaving] = useState(false);
|
|
126
|
+
const [savedOk, setSavedOk] = useState(false);
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (initialScope) {
|
|
130
|
+
setScope(initialScope);
|
|
131
|
+
}
|
|
132
|
+
}, [initialScope]);
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (workspaceId) {
|
|
136
|
+
setSelectedWorkspaceId(workspaceId);
|
|
137
|
+
}
|
|
138
|
+
}, [workspaceId]);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
let cancelled = false;
|
|
142
|
+
void requestMemoryApi('GET', '/api/v2/projects').then((res) => {
|
|
143
|
+
if (cancelled || res.status !== 200) return;
|
|
144
|
+
const rawProjects = res.data.projects;
|
|
145
|
+
if (!Array.isArray(rawProjects)) return;
|
|
146
|
+
const valid = rawProjects
|
|
147
|
+
.filter(
|
|
148
|
+
(item): item is WorkspaceProjectOption =>
|
|
149
|
+
Boolean(
|
|
150
|
+
item &&
|
|
151
|
+
typeof item === 'object' &&
|
|
152
|
+
typeof (item as { folderPath?: unknown }).folderPath === 'string' &&
|
|
153
|
+
(item as { folderPath: string }).folderPath.trim().length > 0,
|
|
154
|
+
),
|
|
155
|
+
)
|
|
156
|
+
.map((item) => ({
|
|
157
|
+
id: String(item.id ?? item.folderPath),
|
|
158
|
+
name: String(item.name || item.folderPath),
|
|
159
|
+
folderPath: item.folderPath,
|
|
160
|
+
}));
|
|
161
|
+
setProjects(valid);
|
|
162
|
+
if (workspaceId === 'default' && defaultProjectId) {
|
|
163
|
+
const matched = valid.find((p) => p.id === defaultProjectId);
|
|
164
|
+
if (matched?.folderPath) {
|
|
165
|
+
setSelectedWorkspaceId((cur) => (cur === 'default' ? matched.folderPath : cur));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return () => {
|
|
170
|
+
cancelled = true;
|
|
171
|
+
};
|
|
172
|
+
}, [defaultProjectId, workspaceId]);
|
|
107
173
|
|
|
108
174
|
const loadScope = useCallback(
|
|
109
|
-
async (targetScope: MemoryScopeTab) => {
|
|
175
|
+
async (targetScope: MemoryScopeTab, targetWorkspaceId = selectedWorkspaceId) => {
|
|
110
176
|
const scopeParam =
|
|
111
|
-
targetScope === 'workspace' ? `&scopeId=${encodeURIComponent(
|
|
177
|
+
targetScope === 'workspace' ? `&scopeId=${encodeURIComponent(targetWorkspaceId)}` : '';
|
|
112
178
|
const res = await requestMemoryApi(
|
|
113
179
|
'GET',
|
|
114
180
|
`/api/v2/memory?scope=${targetScope}${scopeParam}`,
|
|
115
181
|
);
|
|
116
182
|
if (res.status === 200) {
|
|
117
183
|
const d = res.data as unknown as MemoryApiResponse;
|
|
184
|
+
const content = d.contentMarkdown ?? '';
|
|
118
185
|
setPermissionMode(d.permissionMode ?? 'ask');
|
|
119
|
-
setMarkdown(
|
|
186
|
+
setMarkdown(content);
|
|
187
|
+
setSavedMarkdown(content);
|
|
120
188
|
setBaseHash(d.contentSha256 ?? '');
|
|
121
189
|
setBytesUsed(d.bytesUsed ?? 0);
|
|
122
190
|
setMaxBytes(d.maxBytes || 16384);
|
|
@@ -125,12 +193,12 @@ export function MemorySettingsPanel({
|
|
|
125
193
|
setConflictBanner(false);
|
|
126
194
|
}
|
|
127
195
|
},
|
|
128
|
-
[
|
|
196
|
+
[selectedWorkspaceId],
|
|
129
197
|
);
|
|
130
198
|
|
|
131
199
|
useEffect(() => {
|
|
132
|
-
void loadScope(scope);
|
|
133
|
-
}, [scope, loadScope]);
|
|
200
|
+
void loadScope(scope, selectedWorkspaceId);
|
|
201
|
+
}, [scope, selectedWorkspaceId, loadScope]);
|
|
134
202
|
|
|
135
203
|
const handleModeChange = async (nextMode: MemoryPermissionMode) => {
|
|
136
204
|
setPermissionMode(nextMode);
|
|
@@ -138,14 +206,16 @@ export function MemorySettingsPanel({
|
|
|
138
206
|
};
|
|
139
207
|
|
|
140
208
|
const readOnly = scope === 'tenant' && !isAdmin;
|
|
209
|
+
const isDirty = markdown !== savedMarkdown;
|
|
141
210
|
|
|
142
211
|
const handleSave = async () => {
|
|
143
212
|
if (readOnly) return;
|
|
144
213
|
setSaving(true);
|
|
214
|
+
setSavedOk(false);
|
|
145
215
|
try {
|
|
146
216
|
const res = await requestMemoryApi('PUT', '/api/v2/memory', {
|
|
147
217
|
scope,
|
|
148
|
-
...(scope === 'workspace' ? { scopeId:
|
|
218
|
+
...(scope === 'workspace' ? { scopeId: selectedWorkspaceId } : {}),
|
|
149
219
|
contentMarkdown: markdown,
|
|
150
220
|
baseHash,
|
|
151
221
|
});
|
|
@@ -154,7 +224,8 @@ export function MemorySettingsPanel({
|
|
|
154
224
|
return;
|
|
155
225
|
}
|
|
156
226
|
if (res.status === 200) {
|
|
157
|
-
await loadScope(scope);
|
|
227
|
+
await loadScope(scope, selectedWorkspaceId);
|
|
228
|
+
setSavedOk(true);
|
|
158
229
|
}
|
|
159
230
|
} finally {
|
|
160
231
|
setSaving(false);
|
|
@@ -166,192 +237,254 @@ export function MemorySettingsPanel({
|
|
|
166
237
|
action: 'renew' | 'convert' | 'withdraw',
|
|
167
238
|
) => {
|
|
168
239
|
await requestMemoryApi('POST', `/api/v2/memory/refinements/${encodeURIComponent(id)}/${action}`, {
|
|
169
|
-
workspaceId,
|
|
240
|
+
workspaceId: selectedWorkspaceId,
|
|
170
241
|
});
|
|
171
|
-
await loadScope(scope);
|
|
242
|
+
await loadScope(scope, selectedWorkspaceId);
|
|
172
243
|
};
|
|
173
244
|
|
|
174
245
|
const activeRefinements = refinements.filter((r) => r.status === 'active');
|
|
175
246
|
const ratio = Math.min(100, Math.round((bytesUsed / Math.max(1, maxBytes)) * 100));
|
|
176
247
|
|
|
248
|
+
const modeDescription =
|
|
249
|
+
permissionMode === 'off'
|
|
250
|
+
? t('Do not extract or save memories from conversations automatically.')
|
|
251
|
+
: permissionMode === 'ask'
|
|
252
|
+
? t('Ask for your confirmation before saving newly detected preferences.')
|
|
253
|
+
: t('Automatically remember stable preferences and workspace conventions.');
|
|
254
|
+
|
|
255
|
+
const scopeDescription =
|
|
256
|
+
scope === 'user'
|
|
257
|
+
? t('Personal preferences and habits applied across all projects and chats.')
|
|
258
|
+
: scope === 'workspace'
|
|
259
|
+
? t('Conventions and context scoped to the current project workspace.')
|
|
260
|
+
: t('Shared rules enforced across all members in your department.');
|
|
261
|
+
|
|
262
|
+
const scopeTabs: Array<{ id: MemoryScopeTab; label: string; testId: string }> = [
|
|
263
|
+
{ id: 'user', label: t('Personal memory'), testId: 'memory-tab-user' },
|
|
264
|
+
{ id: 'workspace', label: t('Project memory'), testId: 'memory-tab-workspace' },
|
|
265
|
+
...(showTenantTab
|
|
266
|
+
? [{ id: 'tenant' as const, label: t('Department shared rules'), testId: 'memory-tab-tenant' }]
|
|
267
|
+
: []),
|
|
268
|
+
];
|
|
269
|
+
|
|
177
270
|
return (
|
|
178
|
-
<div
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
[
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
271
|
+
<div data-testid="memory-settings-panel" className="space-y-6 text-xs">
|
|
272
|
+
{/* ───── 记忆模式(极简细分割线行 + 标准紧凑分段胶囊)───── */}
|
|
273
|
+
<SettingSection>
|
|
274
|
+
<SettingRow
|
|
275
|
+
title={t('Memory mode')}
|
|
276
|
+
description={modeDescription}
|
|
277
|
+
control={
|
|
278
|
+
<SettingSegmented
|
|
279
|
+
value={permissionMode}
|
|
280
|
+
onChange={(val) => void handleModeChange(val)}
|
|
281
|
+
ariaLabel={t('Memory mode')}
|
|
282
|
+
options={[
|
|
283
|
+
{ value: 'off', label: t('Off'), testId: 'memory-mode-off' },
|
|
284
|
+
{ value: 'ask', label: t('Ask before saving'), testId: 'memory-mode-ask' },
|
|
285
|
+
{ value: 'auto', label: t('Remember automatically'), testId: 'memory-mode-auto' },
|
|
286
|
+
]}
|
|
287
|
+
/>
|
|
288
|
+
}
|
|
289
|
+
/>
|
|
290
|
+
</SettingSection>
|
|
291
|
+
|
|
292
|
+
{/* ───── MEMORY.md 作用域切换与编辑工作台 ───── */}
|
|
293
|
+
<div className="space-y-3">
|
|
294
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
295
|
+
<div className="inline-flex items-center rounded-lg bg-agent-muted/70 p-0.5 ring-1 ring-inset ring-agent-border/60">
|
|
296
|
+
{scopeTabs.map((tab) => {
|
|
297
|
+
const active = scope === tab.id;
|
|
298
|
+
return (
|
|
299
|
+
<button
|
|
300
|
+
key={tab.id}
|
|
301
|
+
type="button"
|
|
302
|
+
data-testid={tab.testId}
|
|
303
|
+
onClick={() => {
|
|
304
|
+
setSavedOk(false);
|
|
305
|
+
setScope(tab.id);
|
|
306
|
+
}}
|
|
307
|
+
className={[
|
|
308
|
+
'h-7 rounded-md px-3 text-xs transition-all',
|
|
309
|
+
active
|
|
310
|
+
? 'bg-agent-canvas font-medium text-agent-foreground shadow-2xs ring-1 ring-inset ring-agent-border/60'
|
|
311
|
+
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
312
|
+
].join(' ')}
|
|
313
|
+
>
|
|
314
|
+
{tab.label}
|
|
315
|
+
</button>
|
|
316
|
+
);
|
|
317
|
+
})}
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
<div className="flex flex-wrap items-center gap-2.5 text-[11px] text-agent-muted-foreground">
|
|
321
|
+
{scope === 'workspace' &&
|
|
322
|
+
(projects.length > 0 || selectedWorkspaceId !== 'default') ? (
|
|
323
|
+
<select
|
|
324
|
+
data-testid="memory-workspace-select"
|
|
325
|
+
aria-label={t('Select project workspace')}
|
|
326
|
+
value={selectedWorkspaceId}
|
|
327
|
+
onChange={(e) => {
|
|
328
|
+
setSavedOk(false);
|
|
329
|
+
setSelectedWorkspaceId(e.target.value);
|
|
330
|
+
}}
|
|
331
|
+
className="h-7 max-w-[14rem] truncate rounded-md border border-agent-border bg-agent-canvas px-2 text-xs text-agent-foreground focus:border-agent-foreground/40 focus:outline-none"
|
|
332
|
+
>
|
|
333
|
+
<option value="default">{t('Unlinked workspace (default)')}</option>
|
|
334
|
+
{projects.map((p) => (
|
|
335
|
+
<option key={p.id} value={p.folderPath}>
|
|
336
|
+
{p.name}
|
|
337
|
+
</option>
|
|
338
|
+
))}
|
|
339
|
+
{selectedWorkspaceId !== 'default' &&
|
|
340
|
+
!projects.some((p) => p.folderPath === selectedWorkspaceId) ? (
|
|
341
|
+
<option value={selectedWorkspaceId}>{selectedWorkspaceId}</option>
|
|
342
|
+
) : null}
|
|
343
|
+
</select>
|
|
344
|
+
) : null}
|
|
345
|
+
<span data-testid="memory-quota-label" className="tabular-nums">
|
|
346
|
+
{(bytesUsed / 1024).toFixed(1)} / {(maxBytes / 1024).toFixed(1)} KB
|
|
347
|
+
</span>
|
|
348
|
+
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-agent-border/80">
|
|
349
|
+
<div
|
|
350
|
+
className="h-full rounded-full bg-agent-foreground transition-all"
|
|
351
|
+
style={{ width: `${ratio}%` }}
|
|
352
|
+
/>
|
|
353
|
+
</div>
|
|
213
354
|
</div>
|
|
214
355
|
</div>
|
|
215
|
-
</div>
|
|
216
356
|
|
|
217
|
-
|
|
218
|
-
<div className="flex items-center gap-2 border-b border-agent-border pb-2">
|
|
219
|
-
<button
|
|
220
|
-
type="button"
|
|
221
|
-
data-testid="memory-tab-user"
|
|
222
|
-
onClick={() => setScope('user')}
|
|
223
|
-
className={`rounded px-2.5 py-1 ${
|
|
224
|
-
scope === 'user' ? 'bg-agent-foreground/10 font-semibold' : 'text-agent-muted-foreground'
|
|
225
|
-
}`}
|
|
226
|
-
>
|
|
227
|
-
{t('Personal memory')}
|
|
228
|
-
</button>
|
|
229
|
-
<button
|
|
230
|
-
type="button"
|
|
231
|
-
data-testid="memory-tab-workspace"
|
|
232
|
-
onClick={() => setScope('workspace')}
|
|
233
|
-
className={`rounded px-2.5 py-1 ${
|
|
234
|
-
scope === 'workspace'
|
|
235
|
-
? 'bg-agent-foreground/10 font-semibold'
|
|
236
|
-
: 'text-agent-muted-foreground'
|
|
237
|
-
}`}
|
|
238
|
-
>
|
|
239
|
-
{t('Project memory')}
|
|
240
|
-
</button>
|
|
241
|
-
{showTenantTab ? (
|
|
242
|
-
<button
|
|
243
|
-
type="button"
|
|
244
|
-
data-testid="memory-tab-tenant"
|
|
245
|
-
onClick={() => setScope('tenant')}
|
|
246
|
-
className={`rounded px-2.5 py-1 ${
|
|
247
|
-
scope === 'tenant'
|
|
248
|
-
? 'bg-agent-foreground/10 font-semibold'
|
|
249
|
-
: 'text-agent-muted-foreground'
|
|
250
|
-
}`}
|
|
251
|
-
>
|
|
252
|
-
{t('Department shared rules')}
|
|
253
|
-
</button>
|
|
254
|
-
) : null}
|
|
255
|
-
</div>
|
|
357
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">{scopeDescription}</p>
|
|
256
358
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
>
|
|
264
|
-
<span>{t('Memory changed in another session. Reload before saving.')}</span>
|
|
265
|
-
<button
|
|
266
|
-
type="button"
|
|
267
|
-
data-testid="memory-conflict-reload"
|
|
268
|
-
onClick={() => void loadScope(scope)}
|
|
269
|
-
className="rounded bg-amber-600 px-2 py-1 text-white"
|
|
359
|
+
{/* Optimistic lock conflict banner */}
|
|
360
|
+
{conflictBanner ? (
|
|
361
|
+
<div
|
|
362
|
+
role="alert"
|
|
363
|
+
data-testid="memory-conflict-banner"
|
|
364
|
+
className="flex items-center justify-between gap-2 rounded-agent-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-amber-900 dark:text-amber-200"
|
|
270
365
|
>
|
|
271
|
-
{t('Reload')}
|
|
272
|
-
</button>
|
|
273
|
-
</div>
|
|
274
|
-
) : null}
|
|
275
|
-
|
|
276
|
-
{/* MEMORY.md editor */}
|
|
277
|
-
<div className="space-y-2">
|
|
278
|
-
<textarea
|
|
279
|
-
rows={6}
|
|
280
|
-
readOnly={readOnly}
|
|
281
|
-
value={markdown}
|
|
282
|
-
onChange={(e) => setMarkdown(e.target.value)}
|
|
283
|
-
aria-label={t('Memory markdown editor')}
|
|
284
|
-
data-testid="memory-markdown-editor"
|
|
285
|
-
className="w-full rounded-lg border border-agent-border bg-agent-background p-2.5 font-mono text-xs"
|
|
286
|
-
/>
|
|
287
|
-
{!readOnly ? (
|
|
288
|
-
<div className="flex justify-end">
|
|
366
|
+
<span>{t('Memory changed in another session. Reload before saving.')}</span>
|
|
289
367
|
<button
|
|
290
368
|
type="button"
|
|
291
|
-
|
|
292
|
-
onClick={() => void
|
|
293
|
-
|
|
294
|
-
className="rounded-md bg-agent-foreground px-3 py-1.5 text-xs font-medium text-agent-background disabled:opacity-50"
|
|
369
|
+
data-testid="memory-conflict-reload"
|
|
370
|
+
onClick={() => void loadScope(scope)}
|
|
371
|
+
className="h-6 shrink-0 rounded-full bg-amber-600 px-2.5 text-xs font-medium text-white hover:bg-amber-700"
|
|
295
372
|
>
|
|
296
|
-
{t('
|
|
373
|
+
{t('Reload')}
|
|
297
374
|
</button>
|
|
298
375
|
</div>
|
|
299
|
-
) :
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
376
|
+
) : null}
|
|
377
|
+
|
|
378
|
+
{/* MEMORY.md editor */}
|
|
379
|
+
<div className="space-y-2.5">
|
|
380
|
+
<textarea
|
|
381
|
+
rows={10}
|
|
382
|
+
readOnly={readOnly}
|
|
383
|
+
value={markdown}
|
|
384
|
+
onChange={(e) => {
|
|
385
|
+
setMarkdown(e.target.value);
|
|
386
|
+
if (savedOk) setSavedOk(false);
|
|
387
|
+
}}
|
|
388
|
+
onKeyDown={(e) => {
|
|
389
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 's') {
|
|
390
|
+
e.preventDefault();
|
|
391
|
+
void handleSave();
|
|
392
|
+
}
|
|
393
|
+
}}
|
|
394
|
+
placeholder={t(
|
|
395
|
+
'- Reply in Chinese with conclusions first\n- Use strict TypeScript and concise comments',
|
|
396
|
+
)}
|
|
397
|
+
aria-label={t('Memory markdown editor')}
|
|
398
|
+
data-testid="memory-markdown-editor"
|
|
399
|
+
className="w-full rounded-agent-md border border-agent-border bg-agent-canvas p-3 font-mono text-xs leading-relaxed text-agent-foreground placeholder:text-agent-muted-foreground/60 focus:border-agent-foreground/40 focus:outline-none focus:ring-2 focus:ring-agent-foreground/15"
|
|
400
|
+
/>
|
|
401
|
+
{!readOnly ? (
|
|
402
|
+
<div className="flex items-center justify-between gap-3">
|
|
403
|
+
<div className="text-[11px] text-agent-muted-foreground">
|
|
404
|
+
{isDirty ? (
|
|
405
|
+
<span>{t('Unsaved changes · press ⌘S / Ctrl+S to save')}</span>
|
|
406
|
+
) : savedOk ? (
|
|
407
|
+
<span className="inline-flex items-center gap-1 text-emerald-700 dark:text-emerald-400">
|
|
408
|
+
<LuCheck className="h-3.5 w-3.5" />
|
|
409
|
+
{t('Saved')}
|
|
410
|
+
</span>
|
|
411
|
+
) : null}
|
|
412
|
+
</div>
|
|
413
|
+
<button
|
|
414
|
+
type="button"
|
|
415
|
+
disabled={saving}
|
|
416
|
+
onClick={() => void handleSave()}
|
|
417
|
+
data-testid="memory-save-btn"
|
|
418
|
+
className={[
|
|
419
|
+
'inline-flex h-8 items-center gap-1.5 rounded-full px-4 text-xs font-medium transition-all disabled:opacity-50',
|
|
420
|
+
isDirty
|
|
421
|
+
? 'bg-agent-foreground text-agent-canvas hover:opacity-90'
|
|
422
|
+
: 'border border-agent-border bg-agent-canvas text-agent-foreground hover:bg-agent-muted/60',
|
|
423
|
+
].join(' ')}
|
|
424
|
+
>
|
|
425
|
+
{saving ? <LuLoaderCircle className="h-3.5 w-3.5 animate-spin" /> : null}
|
|
426
|
+
<span>{t('Save memory')}</span>
|
|
427
|
+
</button>
|
|
428
|
+
</div>
|
|
429
|
+
) : (
|
|
430
|
+
<p className="text-[11px] text-agent-muted-foreground">
|
|
431
|
+
{t('Read-only: only administrators can edit department shared rules.')}
|
|
432
|
+
</p>
|
|
433
|
+
)}
|
|
434
|
+
</div>
|
|
304
435
|
</div>
|
|
305
436
|
|
|
306
437
|
{/* Active RSI refinement review queue */}
|
|
307
438
|
{activeRefinements.length > 0 ? (
|
|
308
|
-
<div className="space-y-2 border-t border-agent-border pt-
|
|
439
|
+
<div className="space-y-2 border-t border-agent-border/60 pt-4">
|
|
309
440
|
<div className="font-semibold text-agent-foreground">
|
|
310
441
|
{t('Refinement notes pending review (30-day expiry)')}
|
|
311
442
|
</div>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
<div className="
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
443
|
+
<div className="divide-y divide-agent-border/60 border-t border-b border-agent-border/60">
|
|
444
|
+
{activeRefinements.map((item) => (
|
|
445
|
+
<div
|
|
446
|
+
key={item.id}
|
|
447
|
+
data-testid={`memory-refinement-${item.id}`}
|
|
448
|
+
className="flex flex-wrap items-center justify-between gap-3 py-3"
|
|
449
|
+
>
|
|
450
|
+
<div className="space-y-0.5">
|
|
451
|
+
<div className="text-agent-foreground">{item.content}</div>
|
|
452
|
+
<div className="font-mono text-[11px] text-agent-muted-foreground">
|
|
453
|
+
{item.id}
|
|
454
|
+
{item.expiresAt ? ` · ${t('Expires')} ${item.expiresAt.slice(0, 10)}` : ''}
|
|
455
|
+
</div>
|
|
323
456
|
</div>
|
|
457
|
+
{!readOnly ? (
|
|
458
|
+
<div className="flex items-center gap-1.5">
|
|
459
|
+
<button
|
|
460
|
+
type="button"
|
|
461
|
+
data-testid={`memory-renew-${item.id}`}
|
|
462
|
+
onClick={() => void handleRefinementAction(item.id, 'renew')}
|
|
463
|
+
className="h-7 rounded-full border border-agent-border bg-agent-canvas px-2.5 text-agent-foreground hover:bg-agent-muted/60"
|
|
464
|
+
>
|
|
465
|
+
{t('Renew 30d')}
|
|
466
|
+
</button>
|
|
467
|
+
<button
|
|
468
|
+
type="button"
|
|
469
|
+
data-testid={`memory-convert-${item.id}`}
|
|
470
|
+
onClick={() => void handleRefinementAction(item.id, 'convert')}
|
|
471
|
+
className="h-7 rounded-full border border-agent-border bg-agent-canvas px-2.5 text-agent-foreground hover:bg-agent-muted/60"
|
|
472
|
+
>
|
|
473
|
+
{t('Make ordinary')}
|
|
474
|
+
</button>
|
|
475
|
+
<button
|
|
476
|
+
type="button"
|
|
477
|
+
data-testid={`memory-withdraw-${item.id}`}
|
|
478
|
+
onClick={() => void handleRefinementAction(item.id, 'withdraw')}
|
|
479
|
+
className="h-7 rounded-full border border-agent-destructive/30 px-2.5 text-agent-destructive hover:bg-agent-destructive/10"
|
|
480
|
+
>
|
|
481
|
+
{t('Withdraw')}
|
|
482
|
+
</button>
|
|
483
|
+
</div>
|
|
484
|
+
) : null}
|
|
324
485
|
</div>
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<button
|
|
328
|
-
type="button"
|
|
329
|
-
data-testid={`memory-renew-${item.id}`}
|
|
330
|
-
onClick={() => void handleRefinementAction(item.id, 'renew')}
|
|
331
|
-
className="rounded border border-agent-border px-2 py-1 hover:bg-agent-foreground/5"
|
|
332
|
-
>
|
|
333
|
-
{t('Renew 30d')}
|
|
334
|
-
</button>
|
|
335
|
-
<button
|
|
336
|
-
type="button"
|
|
337
|
-
data-testid={`memory-convert-${item.id}`}
|
|
338
|
-
onClick={() => void handleRefinementAction(item.id, 'convert')}
|
|
339
|
-
className="rounded border border-agent-border px-2 py-1 hover:bg-agent-foreground/5"
|
|
340
|
-
>
|
|
341
|
-
{t('Make ordinary')}
|
|
342
|
-
</button>
|
|
343
|
-
<button
|
|
344
|
-
type="button"
|
|
345
|
-
data-testid={`memory-withdraw-${item.id}`}
|
|
346
|
-
onClick={() => void handleRefinementAction(item.id, 'withdraw')}
|
|
347
|
-
className="rounded border border-rose-500/40 px-2 py-1 text-rose-600 hover:bg-rose-500/10"
|
|
348
|
-
>
|
|
349
|
-
{t('Withdraw')}
|
|
350
|
-
</button>
|
|
351
|
-
</div>
|
|
352
|
-
) : null}
|
|
353
|
-
</div>
|
|
354
|
-
))}
|
|
486
|
+
))}
|
|
487
|
+
</div>
|
|
355
488
|
</div>
|
|
356
489
|
) : null}
|
|
357
490
|
|