@steerable/agent-shell-web 0.14.5 → 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/chat/LocalChatPanel.tsx +26 -1
- 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 +106 -6
- package/src/lib/chat-draft-store.ts +43 -0
- package/src/packs/registry.ts +2 -0
- package/src/pages/AgentPage.tsx +11 -1
- package/src/pages/SettingsPage.tsx +327 -489
- package/src/styles/index.css +6 -0
|
@@ -2,6 +2,12 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
3
3
|
import { LuBlocks, LuPanelLeftOpen, LuSettings, LuSquarePen } from 'react-icons/lu';
|
|
4
4
|
import { AgentSidebar } from '@/components/AgentSidebar';
|
|
5
|
+
import { useAppRelease } from '@/components/SidebarRelease';
|
|
6
|
+
import { SettingsSidebar } from '@/components/settings/SettingsSidebar';
|
|
7
|
+
import {
|
|
8
|
+
buildSettingsNavEntries,
|
|
9
|
+
resolveSettingsRoute,
|
|
10
|
+
} from '@/components/settings/settings-registry';
|
|
5
11
|
import { TerminalPanel } from '@/components/TerminalPanel';
|
|
6
12
|
import { RightPanelTabBar } from '@/layouts/RightPanelTabBar';
|
|
7
13
|
import { TaskProcessPanel, type InspectedTask } from '@/components/chat/TaskProcessPanel';
|
|
@@ -154,6 +160,10 @@ export type AgentOutletContext = UseChatsAndAgentsResult & {
|
|
|
154
160
|
hiddenPanelTitle: string | null;
|
|
155
161
|
/** 标题栏开关:整栏收着或空着时打开。 */
|
|
156
162
|
onOpenRightPanel: () => void;
|
|
163
|
+
/** 当前应用隐藏的导航项列表(供设置页与侧栏保持一致裁剪)。 */
|
|
164
|
+
hiddenNavItems?: readonly HiddenNavItem[];
|
|
165
|
+
/** 退出设置页并返回上一次聊天路由。 */
|
|
166
|
+
onExitSettings?: () => void;
|
|
157
167
|
};
|
|
158
168
|
|
|
159
169
|
function AgentLayoutContent() {
|
|
@@ -798,6 +808,45 @@ function AgentLayoutContent() {
|
|
|
798
808
|
(!(hiddenSet.has('agents') && hiddenSet.has('skills') && hiddenSet.has('mcp')) &&
|
|
799
809
|
settingsChrome('web-search'));
|
|
800
810
|
const onSettingsPage = location.pathname === '/settings';
|
|
811
|
+
const release = useAppRelease();
|
|
812
|
+
const lastChatLocationRef = useRef<string>('/agent');
|
|
813
|
+
useEffect(() => {
|
|
814
|
+
if (location.pathname !== '/settings') {
|
|
815
|
+
lastChatLocationRef.current = `${location.pathname}${location.search}`;
|
|
816
|
+
}
|
|
817
|
+
}, [location.pathname, location.search]);
|
|
818
|
+
|
|
819
|
+
const exitSettings = useCallback(() => {
|
|
820
|
+
navigate(lastChatLocationRef.current || '/agent');
|
|
821
|
+
}, [navigate]);
|
|
822
|
+
|
|
823
|
+
const settingsEntries = useMemo(
|
|
824
|
+
() =>
|
|
825
|
+
onSettingsPage
|
|
826
|
+
? buildSettingsNavEntries({
|
|
827
|
+
hiddenNavItems,
|
|
828
|
+
releaseVersion: release.version,
|
|
829
|
+
})
|
|
830
|
+
: [],
|
|
831
|
+
[onSettingsPage, hiddenNavItems, release.version],
|
|
832
|
+
);
|
|
833
|
+
const resolvedSettings = useMemo(
|
|
834
|
+
() =>
|
|
835
|
+
onSettingsPage
|
|
836
|
+
? resolveSettingsRoute(
|
|
837
|
+
new URLSearchParams(location.search),
|
|
838
|
+
settingsEntries.map((item) => item.id),
|
|
839
|
+
)
|
|
840
|
+
: { tabId: 'general', anchorId: null },
|
|
841
|
+
[onSettingsPage, location.search, settingsEntries],
|
|
842
|
+
);
|
|
843
|
+
const handleSelectSettingsTab = useCallback(
|
|
844
|
+
(tabId: string) => {
|
|
845
|
+
navigate(`/settings?tab=${encodeURIComponent(tabId)}`);
|
|
846
|
+
},
|
|
847
|
+
[navigate],
|
|
848
|
+
);
|
|
849
|
+
|
|
801
850
|
const settingsSection = useMemo(
|
|
802
851
|
() => new URLSearchParams(location.search).get('section'),
|
|
803
852
|
[location.search],
|
|
@@ -812,9 +861,9 @@ function AgentLayoutContent() {
|
|
|
812
861
|
const onGeneralSettings = onSettingsPage && !onPluginsSettings;
|
|
813
862
|
const onNewChatHome = !chatId && !onSettingsPage;
|
|
814
863
|
|
|
815
|
-
//
|
|
864
|
+
// 收起侧边栏或处在设置页时 AgentSidebar 未挂载,由外层补接菜单 Cmd+N。
|
|
816
865
|
useEffect(() => {
|
|
817
|
-
if (!sidebarCollapsed) return;
|
|
866
|
+
if (!sidebarCollapsed && !onSettingsPage) return;
|
|
818
867
|
const bridge = getHostBridge();
|
|
819
868
|
if (!bridge?.onMenuNewChat) return;
|
|
820
869
|
bridge.onMenuNewChat(() => {
|
|
@@ -823,22 +872,71 @@ function AgentLayoutContent() {
|
|
|
823
872
|
return () => {
|
|
824
873
|
bridge.offMenuNewChat?.();
|
|
825
874
|
};
|
|
826
|
-
}, [sidebarCollapsed, navigate]);
|
|
875
|
+
}, [sidebarCollapsed, onSettingsPage, navigate]);
|
|
827
876
|
|
|
828
877
|
useEffect(() => {
|
|
829
878
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
830
879
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey && event.key.toLowerCase() === 'o') {
|
|
831
880
|
event.preventDefault();
|
|
832
881
|
navigate('/agent');
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey && event.key === ',') {
|
|
885
|
+
if (!hasGeneralSettingsChrome() && !pluginsAvailable) return;
|
|
886
|
+
event.preventDefault();
|
|
887
|
+
if (onSettingsPage) {
|
|
888
|
+
exitSettings();
|
|
889
|
+
} else {
|
|
890
|
+
navigate('/settings');
|
|
891
|
+
}
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (onSettingsPage && event.key === 'Escape' && !event.defaultPrevented) {
|
|
895
|
+
const active = document.activeElement as HTMLElement | null;
|
|
896
|
+
const tag = active?.tagName?.toLowerCase();
|
|
897
|
+
if (
|
|
898
|
+
tag === 'input' ||
|
|
899
|
+
tag === 'textarea' ||
|
|
900
|
+
tag === 'select' ||
|
|
901
|
+
active?.isContentEditable ||
|
|
902
|
+
active?.closest('[role="dialog"], [role="menu"], [role="listbox"]')
|
|
903
|
+
) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
event.preventDefault();
|
|
907
|
+
exitSettings();
|
|
833
908
|
}
|
|
834
909
|
};
|
|
835
910
|
window.addEventListener('keydown', onKeyDown);
|
|
836
911
|
return () => window.removeEventListener('keydown', onKeyDown);
|
|
837
|
-
}, [navigate]);
|
|
912
|
+
}, [navigate, onSettingsPage, exitSettings, pluginsAvailable]);
|
|
838
913
|
|
|
839
914
|
return (
|
|
840
915
|
<div className="relative flex h-full w-full bg-agent-muted/30">
|
|
841
|
-
{
|
|
916
|
+
{onSettingsPage ? (
|
|
917
|
+
<>
|
|
918
|
+
<div
|
|
919
|
+
className="hidden h-full flex-shrink-0 sm:block"
|
|
920
|
+
style={{ width: Math.max(sidebarWidth, 224) }}
|
|
921
|
+
>
|
|
922
|
+
<SettingsSidebar
|
|
923
|
+
entries={settingsEntries}
|
|
924
|
+
activeTabId={resolvedSettings.tabId}
|
|
925
|
+
onSelectTab={handleSelectSettingsTab}
|
|
926
|
+
onBack={exitSettings}
|
|
927
|
+
/>
|
|
928
|
+
</div>
|
|
929
|
+
<div
|
|
930
|
+
role="separator"
|
|
931
|
+
aria-orientation="vertical"
|
|
932
|
+
aria-label={t('Resize sidebar')}
|
|
933
|
+
onMouseDown={() => setIsResizing(true)}
|
|
934
|
+
onDoubleClick={resetWidth}
|
|
935
|
+
className="hidden w-1 flex-shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-agent-border/60 sm:block"
|
|
936
|
+
title={t('Drag to resize the sidebar (double-click to reset)')}
|
|
937
|
+
/>
|
|
938
|
+
</>
|
|
939
|
+
) : sidebarCollapsed ? (
|
|
842
940
|
// 收起态:窄 rail 提供展开、新对话、插件与底部设置快捷入口。
|
|
843
941
|
<div className="flex h-full w-10 flex-shrink-0 flex-col items-center border-r border-agent-border/60 bg-agent-muted/70 backdrop-blur-md">
|
|
844
942
|
<div className="flex h-11 w-full items-center justify-center">
|
|
@@ -956,12 +1054,14 @@ function AgentLayoutContent() {
|
|
|
956
1054
|
hiddenPanelCount,
|
|
957
1055
|
hiddenPanelTitle,
|
|
958
1056
|
onOpenRightPanel: expandRightSide,
|
|
1057
|
+
hiddenNavItems,
|
|
1058
|
+
onExitSettings: exitSettings,
|
|
959
1059
|
} satisfies AgentOutletContext}
|
|
960
1060
|
/>
|
|
961
1061
|
</div>
|
|
962
1062
|
{settingsChrome('insights') && <InsightsConsentBanner />}
|
|
963
1063
|
</div>
|
|
964
|
-
{(panelOpen || inspectedTask !== null) && (
|
|
1064
|
+
{!onSettingsPage && (panelOpen || inspectedTask !== null) && (
|
|
965
1065
|
<>
|
|
966
1066
|
<div
|
|
967
1067
|
role="separator"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 进程内会话输入草稿缓存(按 chatId 或首屏 '__hero__' 键控)。
|
|
3
|
+
*
|
|
4
|
+
* 用于从对话页切往 `/settings`(或切换不同会话)再返回时,无损恢复尚未发送的
|
|
5
|
+
* 输入框文本,不落盘、不污染持久化数据库。上限 50 条按最近写入顺序淘汰。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_DRAFT_ENTRIES = 50;
|
|
9
|
+
const HERO_DRAFT_KEY = '__hero__';
|
|
10
|
+
|
|
11
|
+
const drafts = new Map<string, string>();
|
|
12
|
+
|
|
13
|
+
export function resolveChatDraftKey(chatId?: string | null): string {
|
|
14
|
+
const trimmed = chatId?.trim();
|
|
15
|
+
return trimmed ? trimmed : HERO_DRAFT_KEY;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getChatDraft(chatId?: string | null): string {
|
|
19
|
+
return drafts.get(resolveChatDraftKey(chatId)) ?? '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setChatDraft(chatId: string | null | undefined, value: string): void {
|
|
23
|
+
const key = resolveChatDraftKey(chatId);
|
|
24
|
+
if (!value) {
|
|
25
|
+
drafts.delete(key);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (drafts.has(key)) {
|
|
29
|
+
drafts.delete(key);
|
|
30
|
+
} else if (drafts.size >= MAX_DRAFT_ENTRIES) {
|
|
31
|
+
const oldest = drafts.keys().next().value;
|
|
32
|
+
if (oldest !== undefined) drafts.delete(oldest);
|
|
33
|
+
}
|
|
34
|
+
drafts.set(key, value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function clearChatDraft(chatId?: string | null): void {
|
|
38
|
+
drafts.delete(resolveChatDraftKey(chatId));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function resetChatDraftsForTests(): void {
|
|
42
|
+
drafts.clear();
|
|
43
|
+
}
|
package/src/packs/registry.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
PackRendererContributions,
|
|
19
19
|
PackRouteContribution,
|
|
20
20
|
PackSettingsPanelContribution,
|
|
21
|
+
SettingsNavGroup,
|
|
21
22
|
} from '@steerable/pack-sdk/web';
|
|
22
23
|
|
|
23
24
|
// 类型单一真源在 @steerable/pack-sdk/web(阶段 2.2);re-export 兼容既有调用方。
|
|
@@ -29,6 +30,7 @@ export type {
|
|
|
29
30
|
PackRendererContributions,
|
|
30
31
|
PackRouteContribution,
|
|
31
32
|
PackSettingsPanelContribution,
|
|
33
|
+
SettingsNavGroup,
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const routes: PackRouteContribution[] = [];
|
package/src/pages/AgentPage.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
readStoredExecPolicy,
|
|
27
27
|
type ExecPolicy,
|
|
28
28
|
} from "@/lib/exec-policy";
|
|
29
|
+
import { clearChatDraft, getChatDraft, setChatDraft } from "@/lib/chat-draft-store";
|
|
29
30
|
import { clampWebChatMode, hostToolChrome, settingsChrome } from "@/lib/host-tools";
|
|
30
31
|
import type { ExecutedAction } from "@/components/chat/ExecutedActionsCard";
|
|
31
32
|
import { inspectTaskTitle, type InspectTaskInput } from "@/components/chat/executed-actions-model";
|
|
@@ -1740,6 +1741,7 @@ function AgentChatView({
|
|
|
1740
1741
|
)}
|
|
1741
1742
|
<LocalChatPanel
|
|
1742
1743
|
chatId={chatId}
|
|
1744
|
+
preserveDraft
|
|
1743
1745
|
messages={effectiveMessages}
|
|
1744
1746
|
isStreaming={effectiveIsStreaming}
|
|
1745
1747
|
onSubmit={handleSubmit}
|
|
@@ -1929,7 +1931,14 @@ function EmptyChatGate() {
|
|
|
1929
1931
|
const navigate = useNavigate();
|
|
1930
1932
|
const [searchParams] = useSearchParams();
|
|
1931
1933
|
const projectIdFromUrl = searchParams.get("projectId");
|
|
1932
|
-
const [inputValue,
|
|
1934
|
+
const [inputValue, setInputValueState] = useState(() => getChatDraft(null));
|
|
1935
|
+
const setInputValue = useCallback((next: string | ((prev: string) => string)) => {
|
|
1936
|
+
setInputValueState((prev) => {
|
|
1937
|
+
const resolved = typeof next === "function" ? next(prev) : next;
|
|
1938
|
+
setChatDraft(null, resolved);
|
|
1939
|
+
return resolved;
|
|
1940
|
+
});
|
|
1941
|
+
}, []);
|
|
1933
1942
|
const [files, setFiles] = useState<AttachmentFile[]>([]);
|
|
1934
1943
|
const [mentionReferences, setMentionReferences] = useState<
|
|
1935
1944
|
MentionReference[]
|
|
@@ -2052,6 +2061,7 @@ function EmptyChatGate() {
|
|
|
2052
2061
|
};
|
|
2053
2062
|
|
|
2054
2063
|
writeChatModeForSession(id, effectiveMode);
|
|
2064
|
+
clearChatDraft(null);
|
|
2055
2065
|
setPendingFirstMessage({
|
|
2056
2066
|
chatId: id,
|
|
2057
2067
|
content,
|