@steerable/agent-shell-web 0.14.4 → 0.14.6
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 +189 -46
- package/src/components/ChatHeader.tsx +12 -1
- package/src/components/SidebarAccount.tsx +33 -41
- package/src/components/chat/AssistantMessage.tsx +25 -4
- package/src/components/chat/ChatInput.tsx +169 -111
- package/src/components/chat/ChatProjectBadge.tsx +233 -88
- package/src/components/chat/ContextUsagePill.tsx +20 -5
- package/src/components/chat/ExecPolicyPicker.tsx +72 -67
- package/src/components/chat/LocalChatPanel.tsx +34 -34
- package/src/components/chat/MessageList.tsx +109 -19
- package/src/components/chat/ModelPicker.tsx +2 -2
- package/src/components/chat/SessionTodoList.tsx +63 -72
- package/src/components/chat/TurnFilesCard.tsx +270 -112
- package/src/components/chat/TurnProcessGroup.tsx +3 -0
- package/src/components/chat/TurnProcessTimeline.tsx +13 -0
- package/src/components/chat/UserMessage.tsx +8 -1
- package/src/components/chat/next-steps-tags.ts +13 -0
- package/src/components/chat/process-status.ts +112 -2
- package/src/components/chat/todo-list-model.ts +52 -4
- 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 +210 -159
- 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 +275 -12
- package/src/layouts/PanelToggleButton.tsx +27 -9
- package/src/layouts/conversation-preview.ts +3 -0
- package/src/layouts/request-chat-slot.ts +20 -0
- package/src/layouts/right-panel-tabs.ts +32 -0
- package/src/lib/chat-draft-store.ts +43 -0
- package/src/lib/file-preview-registry.ts +57 -0
- package/src/packs/registry.ts +2 -0
- package/src/pages/AgentPage.tsx +17 -4
- package/src/pages/SettingsPage.tsx +327 -489
- package/src/styles/index.css +6 -0
|
@@ -29,29 +29,31 @@ export function CliInstallSettingsPanel(props: {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<div className="space-y-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
<div className="space-y-3 border-t border-b border-agent-border/60 py-3.5" data-testid="cli-install-settings">
|
|
33
|
+
<div className="flex items-center justify-between gap-6">
|
|
34
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">
|
|
35
|
+
{t('Install the command-line tool on your PATH so you can run it from a terminal.')}
|
|
36
|
+
</p>
|
|
37
|
+
<button
|
|
38
|
+
type="button"
|
|
39
|
+
data-testid="cli-install-button"
|
|
40
|
+
onClick={() => void onClick()}
|
|
41
|
+
disabled={running}
|
|
42
|
+
className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-agent-foreground px-3.5 text-xs font-medium text-agent-canvas transition hover:opacity-90 disabled:opacity-50"
|
|
43
|
+
>
|
|
44
|
+
{running ? (
|
|
45
|
+
<>
|
|
46
|
+
<LuLoader className="h-3.5 w-3.5 animate-spin" />
|
|
47
|
+
{t('Installing…')}
|
|
48
|
+
</>
|
|
49
|
+
) : (
|
|
50
|
+
<>
|
|
51
|
+
<LuTerminal className="h-3.5 w-3.5" />
|
|
52
|
+
{t('Install command-line tool')}
|
|
53
|
+
</>
|
|
54
|
+
)}
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
55
57
|
{message && (
|
|
56
58
|
<p data-testid="cli-install-message" className="text-xs text-agent-foreground">
|
|
57
59
|
{message}
|
|
@@ -139,8 +139,8 @@ export function DiagnoseSettingsPanel() {
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
return (
|
|
142
|
-
<div className="space-y-
|
|
143
|
-
<p className="text-xs text-agent-muted-foreground">
|
|
142
|
+
<div className="space-y-3 border-t border-agent-border/60 pt-3">
|
|
143
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">
|
|
144
144
|
{t(
|
|
145
145
|
'Diagnose network connectivity to the current model service, including DNS resolution, TCP connection, TLS handshake, the HTTP endpoint, and chat completion.',
|
|
146
146
|
)}{' '}
|
|
@@ -153,7 +153,7 @@ export function DiagnoseSettingsPanel() {
|
|
|
153
153
|
type="button"
|
|
154
154
|
onClick={() => void run()}
|
|
155
155
|
disabled={running}
|
|
156
|
-
className="inline-flex items-center gap-1.5 rounded-
|
|
156
|
+
className="inline-flex h-8 items-center gap-1.5 rounded-full bg-agent-foreground px-3.5 text-xs font-medium text-agent-canvas transition hover:opacity-90 disabled:opacity-50"
|
|
157
157
|
>
|
|
158
158
|
{running ? (
|
|
159
159
|
<>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { LuChartBar } from 'react-icons/lu';
|
|
3
2
|
import { BRAND_NAME } from '@/brand';
|
|
4
3
|
import { t } from '@/i18n';
|
|
5
4
|
import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
|
|
@@ -203,13 +202,12 @@ export function InsightsSettingsPanel() {
|
|
|
203
202
|
const stats = data.stats ?? empty.stats!;
|
|
204
203
|
|
|
205
204
|
return (
|
|
206
|
-
<div className="space-y-3" data-testid="insights-settings-panel">
|
|
207
|
-
<div className="
|
|
208
|
-
<
|
|
209
|
-
<LuChartBar className="h-3.5 w-3.5 text-agent-muted-foreground" />
|
|
205
|
+
<div className="space-y-3 border-t border-agent-border/60 pt-3" data-testid="insights-settings-panel">
|
|
206
|
+
<div className="space-y-3">
|
|
207
|
+
<p className="sr-only">
|
|
210
208
|
{t('Help improve the product (behavior / conversations / user info are confirmed separately)')}
|
|
211
|
-
</
|
|
212
|
-
<p className="text-
|
|
209
|
+
</p>
|
|
210
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">
|
|
213
211
|
{t(
|
|
214
212
|
'Even if the user does not agree to upload, records stay on this device. You can export JSON and send it to the product team, or click "Upload now" once.',
|
|
215
213
|
)}
|
|
@@ -32,6 +32,7 @@ import { ModelCapabilityChips } from '@/components/settings/ModelCapabilityChips
|
|
|
32
32
|
import { modelCapabilityChips } from '@/components/settings/model-capabilities';
|
|
33
33
|
import { ModelIdCombobox } from '@/components/settings/ModelIdCombobox';
|
|
34
34
|
import { SettingsSaveButton } from '@/components/settings/SettingsSaveButton';
|
|
35
|
+
import { SettingDisclosure } from '@/components/settings/primitives';
|
|
35
36
|
import { t } from '@/i18n';
|
|
36
37
|
import { hasHostBridge } from '@/lib/host-bridge';
|
|
37
38
|
import {
|
|
@@ -69,6 +70,8 @@ interface LlmSettingsPanelProps {
|
|
|
69
70
|
onSaved?: (settings: LlmSettings) => void;
|
|
70
71
|
onSaveUiChange?: (ui: LlmSaveUi) => void;
|
|
71
72
|
showFooterSave?: boolean;
|
|
73
|
+
/** 在设置页子页面内默认将预制/兼容旗标/预算/超时折叠进高级区,保持首屏清爽。 */
|
|
74
|
+
collapseAdvanced?: boolean;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// ─── 厂商参数预制(框架 llm.presets)────────────────────────────────────────
|
|
@@ -78,12 +81,12 @@ interface LlmSettingsPanelProps {
|
|
|
78
81
|
/**
|
|
79
82
|
* LlmSettingsPanel — 本地模型设置表单(服务商 / URL / Key / 模型 / 预制 / 超时)。
|
|
80
83
|
*
|
|
81
|
-
*
|
|
84
|
+
* 两处复用:设置页「模型服务」子页,以及输入区齿轮打开的 LocalLlmSettingsModal。
|
|
82
85
|
* 挂载时自取当前配置;保存走 local-api `setLlmSettings`。
|
|
83
86
|
*/
|
|
84
87
|
export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPanelProps>(
|
|
85
88
|
function LlmSettingsPanel(
|
|
86
|
-
{ onSaved, onSaveUiChange, showFooterSave = true },
|
|
89
|
+
{ onSaved, onSaveUiChange, showFooterSave = true, collapseAdvanced = false },
|
|
87
90
|
ref,
|
|
88
91
|
) {
|
|
89
92
|
const [settings, setSettings] = useState<LlmSettings>({
|
|
@@ -613,6 +616,9 @@ export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPa
|
|
|
613
616
|
</p>
|
|
614
617
|
</div>
|
|
615
618
|
|
|
619
|
+
{(() => {
|
|
620
|
+
const advancedBody = (
|
|
621
|
+
<div className="space-y-4">
|
|
616
622
|
{usesOpenAiCompatExtras(settings.provider) && (
|
|
617
623
|
<div className="rounded-agent-md border border-agent-border/60 p-3 space-y-3">
|
|
618
624
|
<div>
|
|
@@ -889,6 +895,20 @@ export const LlmSettingsPanel = forwardRef<LlmSettingsPanelHandle, LlmSettingsPa
|
|
|
889
895
|
</div>
|
|
890
896
|
|
|
891
897
|
</div>
|
|
898
|
+
</div>
|
|
899
|
+
);
|
|
900
|
+
if (!collapseAdvanced) return advancedBody;
|
|
901
|
+
return (
|
|
902
|
+
<SettingDisclosure
|
|
903
|
+
title={t('Advanced parameters & compatibility')}
|
|
904
|
+
summary={`${t('Token budget limit')}: ${(settings.maxTotalTokens ?? 60000).toLocaleString()}`}
|
|
905
|
+
defaultOpen={false}
|
|
906
|
+
testId="llm-advanced-disclosure"
|
|
907
|
+
>
|
|
908
|
+
{advancedBody}
|
|
909
|
+
</SettingDisclosure>
|
|
910
|
+
);
|
|
911
|
+
})()}
|
|
892
912
|
</>
|
|
893
913
|
)}
|
|
894
914
|
|
|
@@ -281,11 +281,10 @@ export function McpSettingsPanel() {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
return (
|
|
284
|
-
<div className="space-y-
|
|
284
|
+
<div className="space-y-5">
|
|
285
285
|
{/* JSON 导入 */}
|
|
286
|
-
<div className="
|
|
287
|
-
<h4 className="text-xs font-
|
|
288
|
-
<LuPlug className="h-3.5 w-3.5 text-agent-muted-foreground" />
|
|
286
|
+
<div className="space-y-2.5 border-t border-b border-agent-border/60 py-4">
|
|
287
|
+
<h4 className="text-xs font-medium text-agent-foreground">
|
|
289
288
|
{t('Paste JSON to import (Claude Desktop format)')}
|
|
290
289
|
</h4>
|
|
291
290
|
<textarea
|
|
@@ -322,7 +321,7 @@ export function McpSettingsPanel() {
|
|
|
322
321
|
|
|
323
322
|
{/* 手动添加 / 编辑表单 */}
|
|
324
323
|
{mcpFormOpen ? (
|
|
325
|
-
<div className="
|
|
324
|
+
<div className="space-y-3 rounded-agent-md border border-agent-border bg-agent-canvas p-4">
|
|
326
325
|
<h4 className="text-xs font-semibold text-agent-foreground">
|
|
327
326
|
{mcpEditingId ? t('Edit MCP server') : t('Add MCP server manually')}
|
|
328
327
|
</h4>
|
|
@@ -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';
|
|
@@ -97,6 +103,7 @@ export function MemorySettingsPanel({
|
|
|
97
103
|
const [scope, setScope] = useState<MemoryScopeTab>('user');
|
|
98
104
|
const [permissionMode, setPermissionMode] = useState<MemoryPermissionMode>('ask');
|
|
99
105
|
const [markdown, setMarkdown] = useState('');
|
|
106
|
+
const [savedMarkdown, setSavedMarkdown] = useState('');
|
|
100
107
|
const [baseHash, setBaseHash] = useState('');
|
|
101
108
|
const [bytesUsed, setBytesUsed] = useState(0);
|
|
102
109
|
const [maxBytes, setMaxBytes] = useState(16384);
|
|
@@ -104,6 +111,7 @@ export function MemorySettingsPanel({
|
|
|
104
111
|
const [revokedHashes, setRevokedHashes] = useState<string[]>([]);
|
|
105
112
|
const [conflictBanner, setConflictBanner] = useState(false);
|
|
106
113
|
const [saving, setSaving] = useState(false);
|
|
114
|
+
const [savedOk, setSavedOk] = useState(false);
|
|
107
115
|
|
|
108
116
|
const loadScope = useCallback(
|
|
109
117
|
async (targetScope: MemoryScopeTab) => {
|
|
@@ -115,8 +123,10 @@ export function MemorySettingsPanel({
|
|
|
115
123
|
);
|
|
116
124
|
if (res.status === 200) {
|
|
117
125
|
const d = res.data as unknown as MemoryApiResponse;
|
|
126
|
+
const content = d.contentMarkdown ?? '';
|
|
118
127
|
setPermissionMode(d.permissionMode ?? 'ask');
|
|
119
|
-
setMarkdown(
|
|
128
|
+
setMarkdown(content);
|
|
129
|
+
setSavedMarkdown(content);
|
|
120
130
|
setBaseHash(d.contentSha256 ?? '');
|
|
121
131
|
setBytesUsed(d.bytesUsed ?? 0);
|
|
122
132
|
setMaxBytes(d.maxBytes || 16384);
|
|
@@ -138,10 +148,12 @@ export function MemorySettingsPanel({
|
|
|
138
148
|
};
|
|
139
149
|
|
|
140
150
|
const readOnly = scope === 'tenant' && !isAdmin;
|
|
151
|
+
const isDirty = markdown !== savedMarkdown;
|
|
141
152
|
|
|
142
153
|
const handleSave = async () => {
|
|
143
154
|
if (readOnly) return;
|
|
144
155
|
setSaving(true);
|
|
156
|
+
setSavedOk(false);
|
|
145
157
|
try {
|
|
146
158
|
const res = await requestMemoryApi('PUT', '/api/v2/memory', {
|
|
147
159
|
scope,
|
|
@@ -155,6 +167,7 @@ export function MemorySettingsPanel({
|
|
|
155
167
|
}
|
|
156
168
|
if (res.status === 200) {
|
|
157
169
|
await loadScope(scope);
|
|
170
|
+
setSavedOk(true);
|
|
158
171
|
}
|
|
159
172
|
} finally {
|
|
160
173
|
setSaving(false);
|
|
@@ -174,184 +187,222 @@ export function MemorySettingsPanel({
|
|
|
174
187
|
const activeRefinements = refinements.filter((r) => r.status === 'active');
|
|
175
188
|
const ratio = Math.min(100, Math.round((bytesUsed / Math.max(1, maxBytes)) * 100));
|
|
176
189
|
|
|
190
|
+
const modeDescription =
|
|
191
|
+
permissionMode === 'off'
|
|
192
|
+
? t('Do not extract or save memories from conversations automatically.')
|
|
193
|
+
: permissionMode === 'ask'
|
|
194
|
+
? t('Ask for your confirmation before saving newly detected preferences.')
|
|
195
|
+
: t('Automatically remember stable preferences and workspace conventions.');
|
|
196
|
+
|
|
197
|
+
const scopeDescription =
|
|
198
|
+
scope === 'user'
|
|
199
|
+
? t('Personal preferences and habits applied across all projects and chats.')
|
|
200
|
+
: scope === 'workspace'
|
|
201
|
+
? t('Conventions and context scoped to the current project workspace.')
|
|
202
|
+
: t('Shared rules enforced across all members in your department.');
|
|
203
|
+
|
|
204
|
+
const scopeTabs: Array<{ id: MemoryScopeTab; label: string; testId: string }> = [
|
|
205
|
+
{ id: 'user', label: t('Personal memory'), testId: 'memory-tab-user' },
|
|
206
|
+
{ id: 'workspace', label: t('Project memory'), testId: 'memory-tab-workspace' },
|
|
207
|
+
...(showTenantTab
|
|
208
|
+
? [{ id: 'tenant' as const, label: t('Department shared rules'), testId: 'memory-tab-tenant' }]
|
|
209
|
+
: []),
|
|
210
|
+
];
|
|
211
|
+
|
|
177
212
|
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
|
-
|
|
213
|
+
<div data-testid="memory-settings-panel" className="space-y-6 text-xs">
|
|
214
|
+
{/* ───── 记忆模式(极简细分割线行 + 标准紧凑分段胶囊)───── */}
|
|
215
|
+
<SettingSection>
|
|
216
|
+
<SettingRow
|
|
217
|
+
title={t('Memory mode')}
|
|
218
|
+
description={modeDescription}
|
|
219
|
+
control={
|
|
220
|
+
<SettingSegmented
|
|
221
|
+
value={permissionMode}
|
|
222
|
+
onChange={(val) => void handleModeChange(val)}
|
|
223
|
+
ariaLabel={t('Memory mode')}
|
|
224
|
+
options={[
|
|
225
|
+
{ value: 'off', label: t('Off'), testId: 'memory-mode-off' },
|
|
226
|
+
{ value: 'ask', label: t('Ask before saving'), testId: 'memory-mode-ask' },
|
|
227
|
+
{ value: 'auto', label: t('Remember automatically'), testId: 'memory-mode-auto' },
|
|
228
|
+
]}
|
|
229
|
+
/>
|
|
230
|
+
}
|
|
231
|
+
/>
|
|
232
|
+
</SettingSection>
|
|
233
|
+
|
|
234
|
+
{/* ───── MEMORY.md 作用域切换与编辑工作台 ───── */}
|
|
235
|
+
<div className="space-y-3">
|
|
236
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
237
|
+
<div className="inline-flex items-center rounded-lg bg-agent-muted/70 p-0.5 ring-1 ring-inset ring-agent-border/60">
|
|
238
|
+
{scopeTabs.map((tab) => {
|
|
239
|
+
const active = scope === tab.id;
|
|
240
|
+
return (
|
|
241
|
+
<button
|
|
242
|
+
key={tab.id}
|
|
243
|
+
type="button"
|
|
244
|
+
data-testid={tab.testId}
|
|
245
|
+
onClick={() => {
|
|
246
|
+
setSavedOk(false);
|
|
247
|
+
setScope(tab.id);
|
|
248
|
+
}}
|
|
249
|
+
className={[
|
|
250
|
+
'h-7 rounded-md px-3 text-xs transition-all',
|
|
251
|
+
active
|
|
252
|
+
? 'bg-agent-canvas font-medium text-agent-foreground shadow-2xs ring-1 ring-inset ring-agent-border/60'
|
|
253
|
+
: 'text-agent-muted-foreground hover:text-agent-foreground',
|
|
254
|
+
].join(' ')}
|
|
255
|
+
>
|
|
256
|
+
{tab.label}
|
|
257
|
+
</button>
|
|
258
|
+
);
|
|
259
|
+
})}
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div className="flex items-center gap-2.5 text-[11px] text-agent-muted-foreground">
|
|
263
|
+
<span data-testid="memory-quota-label" className="tabular-nums">
|
|
264
|
+
{(bytesUsed / 1024).toFixed(1)} / {(maxBytes / 1024).toFixed(1)} KB
|
|
265
|
+
</span>
|
|
266
|
+
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-agent-border/80">
|
|
267
|
+
<div
|
|
268
|
+
className="h-full rounded-full bg-agent-foreground transition-all"
|
|
269
|
+
style={{ width: `${ratio}%` }}
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
213
272
|
</div>
|
|
214
273
|
</div>
|
|
215
|
-
</div>
|
|
216
274
|
|
|
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>
|
|
275
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">{scopeDescription}</p>
|
|
256
276
|
|
|
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"
|
|
277
|
+
{/* Optimistic lock conflict banner */}
|
|
278
|
+
{conflictBanner ? (
|
|
279
|
+
<div
|
|
280
|
+
role="alert"
|
|
281
|
+
data-testid="memory-conflict-banner"
|
|
282
|
+
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
283
|
>
|
|
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">
|
|
284
|
+
<span>{t('Memory changed in another session. Reload before saving.')}</span>
|
|
289
285
|
<button
|
|
290
286
|
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"
|
|
287
|
+
data-testid="memory-conflict-reload"
|
|
288
|
+
onClick={() => void loadScope(scope)}
|
|
289
|
+
className="h-6 shrink-0 rounded-full bg-amber-600 px-2.5 text-xs font-medium text-white hover:bg-amber-700"
|
|
295
290
|
>
|
|
296
|
-
{t('
|
|
291
|
+
{t('Reload')}
|
|
297
292
|
</button>
|
|
298
293
|
</div>
|
|
299
|
-
) :
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
294
|
+
) : null}
|
|
295
|
+
|
|
296
|
+
{/* MEMORY.md editor */}
|
|
297
|
+
<div className="space-y-2.5">
|
|
298
|
+
<textarea
|
|
299
|
+
rows={10}
|
|
300
|
+
readOnly={readOnly}
|
|
301
|
+
value={markdown}
|
|
302
|
+
onChange={(e) => {
|
|
303
|
+
setMarkdown(e.target.value);
|
|
304
|
+
if (savedOk) setSavedOk(false);
|
|
305
|
+
}}
|
|
306
|
+
onKeyDown={(e) => {
|
|
307
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 's') {
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
void handleSave();
|
|
310
|
+
}
|
|
311
|
+
}}
|
|
312
|
+
placeholder={t(
|
|
313
|
+
'- Reply in Chinese with conclusions first\n- Use strict TypeScript and concise comments',
|
|
314
|
+
)}
|
|
315
|
+
aria-label={t('Memory markdown editor')}
|
|
316
|
+
data-testid="memory-markdown-editor"
|
|
317
|
+
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"
|
|
318
|
+
/>
|
|
319
|
+
{!readOnly ? (
|
|
320
|
+
<div className="flex items-center justify-between gap-3">
|
|
321
|
+
<div className="text-[11px] text-agent-muted-foreground">
|
|
322
|
+
{isDirty ? (
|
|
323
|
+
<span>{t('Unsaved changes · press ⌘S / Ctrl+S to save')}</span>
|
|
324
|
+
) : savedOk ? (
|
|
325
|
+
<span className="inline-flex items-center gap-1 text-emerald-700 dark:text-emerald-400">
|
|
326
|
+
<LuCheck className="h-3.5 w-3.5" />
|
|
327
|
+
{t('Saved')}
|
|
328
|
+
</span>
|
|
329
|
+
) : null}
|
|
330
|
+
</div>
|
|
331
|
+
<button
|
|
332
|
+
type="button"
|
|
333
|
+
disabled={saving}
|
|
334
|
+
onClick={() => void handleSave()}
|
|
335
|
+
data-testid="memory-save-btn"
|
|
336
|
+
className={[
|
|
337
|
+
'inline-flex h-8 items-center gap-1.5 rounded-full px-4 text-xs font-medium transition-all disabled:opacity-50',
|
|
338
|
+
isDirty
|
|
339
|
+
? 'bg-agent-foreground text-agent-canvas hover:opacity-90'
|
|
340
|
+
: 'border border-agent-border bg-agent-canvas text-agent-foreground hover:bg-agent-muted/60',
|
|
341
|
+
].join(' ')}
|
|
342
|
+
>
|
|
343
|
+
{saving ? <LuLoaderCircle className="h-3.5 w-3.5 animate-spin" /> : null}
|
|
344
|
+
<span>{t('Save memory')}</span>
|
|
345
|
+
</button>
|
|
346
|
+
</div>
|
|
347
|
+
) : (
|
|
348
|
+
<p className="text-[11px] text-agent-muted-foreground">
|
|
349
|
+
{t('Read-only: only administrators can edit department shared rules.')}
|
|
350
|
+
</p>
|
|
351
|
+
)}
|
|
352
|
+
</div>
|
|
304
353
|
</div>
|
|
305
354
|
|
|
306
355
|
{/* Active RSI refinement review queue */}
|
|
307
356
|
{activeRefinements.length > 0 ? (
|
|
308
|
-
<div className="space-y-2 border-t border-agent-border pt-
|
|
357
|
+
<div className="space-y-2 border-t border-agent-border/60 pt-4">
|
|
309
358
|
<div className="font-semibold text-agent-foreground">
|
|
310
359
|
{t('Refinement notes pending review (30-day expiry)')}
|
|
311
360
|
</div>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
<div className="
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
361
|
+
<div className="divide-y divide-agent-border/60 border-t border-b border-agent-border/60">
|
|
362
|
+
{activeRefinements.map((item) => (
|
|
363
|
+
<div
|
|
364
|
+
key={item.id}
|
|
365
|
+
data-testid={`memory-refinement-${item.id}`}
|
|
366
|
+
className="flex flex-wrap items-center justify-between gap-3 py-3"
|
|
367
|
+
>
|
|
368
|
+
<div className="space-y-0.5">
|
|
369
|
+
<div className="text-agent-foreground">{item.content}</div>
|
|
370
|
+
<div className="font-mono text-[11px] text-agent-muted-foreground">
|
|
371
|
+
{item.id}
|
|
372
|
+
{item.expiresAt ? ` · ${t('Expires')} ${item.expiresAt.slice(0, 10)}` : ''}
|
|
373
|
+
</div>
|
|
323
374
|
</div>
|
|
375
|
+
{!readOnly ? (
|
|
376
|
+
<div className="flex items-center gap-1.5">
|
|
377
|
+
<button
|
|
378
|
+
type="button"
|
|
379
|
+
data-testid={`memory-renew-${item.id}`}
|
|
380
|
+
onClick={() => void handleRefinementAction(item.id, 'renew')}
|
|
381
|
+
className="h-7 rounded-full border border-agent-border bg-agent-canvas px-2.5 text-agent-foreground hover:bg-agent-muted/60"
|
|
382
|
+
>
|
|
383
|
+
{t('Renew 30d')}
|
|
384
|
+
</button>
|
|
385
|
+
<button
|
|
386
|
+
type="button"
|
|
387
|
+
data-testid={`memory-convert-${item.id}`}
|
|
388
|
+
onClick={() => void handleRefinementAction(item.id, 'convert')}
|
|
389
|
+
className="h-7 rounded-full border border-agent-border bg-agent-canvas px-2.5 text-agent-foreground hover:bg-agent-muted/60"
|
|
390
|
+
>
|
|
391
|
+
{t('Make ordinary')}
|
|
392
|
+
</button>
|
|
393
|
+
<button
|
|
394
|
+
type="button"
|
|
395
|
+
data-testid={`memory-withdraw-${item.id}`}
|
|
396
|
+
onClick={() => void handleRefinementAction(item.id, 'withdraw')}
|
|
397
|
+
className="h-7 rounded-full border border-agent-destructive/30 px-2.5 text-agent-destructive hover:bg-agent-destructive/10"
|
|
398
|
+
>
|
|
399
|
+
{t('Withdraw')}
|
|
400
|
+
</button>
|
|
401
|
+
</div>
|
|
402
|
+
) : null}
|
|
324
403
|
</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
|
-
))}
|
|
404
|
+
))}
|
|
405
|
+
</div>
|
|
355
406
|
</div>
|
|
356
407
|
) : null}
|
|
357
408
|
|