@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
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { Outlet, useParams } from 'react-router-dom';
|
|
3
|
-
import { LuPanelLeftOpen } from 'react-icons/lu';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
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';
|
|
@@ -24,7 +30,12 @@ import {
|
|
|
24
30
|
useChatsAndAgents,
|
|
25
31
|
type UseChatsAndAgentsResult,
|
|
26
32
|
} from '@/hooks/useChatsAndAgents';
|
|
27
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
hasGeneralSettingsChrome,
|
|
35
|
+
hostToolChrome,
|
|
36
|
+
sanitizeRightPanelKind,
|
|
37
|
+
settingsChrome,
|
|
38
|
+
} from '@/lib/host-tools';
|
|
28
39
|
import { t } from '@/i18n';
|
|
29
40
|
import { BRAND_NAME } from '@/brand';
|
|
30
41
|
import { chatWindowTitle } from '@/lib/chat-row-keys';
|
|
@@ -36,6 +47,7 @@ import {
|
|
|
36
47
|
followRightPanelTab,
|
|
37
48
|
openRightPanelTab,
|
|
38
49
|
parseRightPanelMap,
|
|
50
|
+
revealDeliverableRightPanelTab,
|
|
39
51
|
revealRightPanelTab,
|
|
40
52
|
serializeRightPanelMap,
|
|
41
53
|
shouldMountRightPanelTab,
|
|
@@ -49,6 +61,7 @@ import {
|
|
|
49
61
|
parseLegacyChatSlotTabId,
|
|
50
62
|
subscribeChatSlotFollows,
|
|
51
63
|
subscribeChatSlotRequests,
|
|
64
|
+
subscribeChatSlotReveals,
|
|
52
65
|
type ChatSlotRequest,
|
|
53
66
|
} from '@/layouts/request-chat-slot';
|
|
54
67
|
|
|
@@ -95,7 +108,7 @@ export type { RightPanelMap, RightPanelTabs };
|
|
|
95
108
|
*/
|
|
96
109
|
const SIDEBAR_WIDTH_KEY = 'deeppath.agent.sidebarWidth';
|
|
97
110
|
const SIDEBAR_COLLAPSED_KEY = 'deeppath.agent.sidebarCollapsed';
|
|
98
|
-
const DEFAULT_SIDEBAR_WIDTH =
|
|
111
|
+
const DEFAULT_SIDEBAR_WIDTH = 224;
|
|
99
112
|
const MIN_SIDEBAR_WIDTH = 180;
|
|
100
113
|
const MAX_SIDEBAR_WIDTH = 420;
|
|
101
114
|
|
|
@@ -141,12 +154,22 @@ export type AgentOutletContext = UseChatsAndAgentsResult & {
|
|
|
141
154
|
rightPanel: RightPanelState;
|
|
142
155
|
/** 当前会话已经打开且正在显示的标签,顺序与标签条一致。 */
|
|
143
156
|
openPanelIds: readonly string[];
|
|
157
|
+
/** 右侧整栏收起或尚未打开时,当前会话后台待预览的标签数。 */
|
|
158
|
+
hiddenPanelCount: number;
|
|
159
|
+
/** 右侧整栏收起时待预览的激活标签标题。 */
|
|
160
|
+
hiddenPanelTitle: string | null;
|
|
144
161
|
/** 标题栏开关:整栏收着或空着时打开。 */
|
|
145
162
|
onOpenRightPanel: () => void;
|
|
163
|
+
/** 当前应用隐藏的导航项列表(供设置页与侧栏保持一致裁剪)。 */
|
|
164
|
+
hiddenNavItems?: readonly HiddenNavItem[];
|
|
165
|
+
/** 退出设置页并返回上一次聊天路由。 */
|
|
166
|
+
onExitSettings?: () => void;
|
|
146
167
|
};
|
|
147
168
|
|
|
148
169
|
function AgentLayoutContent() {
|
|
149
170
|
const data = useChatsAndAgents();
|
|
171
|
+
const navigate = useNavigate();
|
|
172
|
+
const location = useLocation();
|
|
150
173
|
const { chatId } = useParams<{ chatId?: string }>();
|
|
151
174
|
const currentChatTitle = chatId
|
|
152
175
|
? data.chats.find((chat) => chat.id === chatId)?.title
|
|
@@ -406,6 +429,10 @@ function AgentLayoutContent() {
|
|
|
406
429
|
const [rightPanelMap, setRightPanelMap] = useState<RightPanelMap>(() =>
|
|
407
430
|
readRightPanelMap(),
|
|
408
431
|
);
|
|
432
|
+
const [stagedTabsByChatId, setStagedTabsByChatId] = useState<
|
|
433
|
+
Record<string, RightPanelTabRecord>
|
|
434
|
+
>({});
|
|
435
|
+
const stagedTabRef = useRef<RightPanelTabRecord | null>(null);
|
|
409
436
|
|
|
410
437
|
// 切换会话时重新读取映射(迁移老 key / 多窗口写入)。
|
|
411
438
|
useEffect(() => {
|
|
@@ -413,10 +440,21 @@ function AgentLayoutContent() {
|
|
|
413
440
|
}, [readRightPanelMap]);
|
|
414
441
|
|
|
415
442
|
const panelEntry: RightPanelTabs | null = chatId ? rightPanelMap[chatId] ?? null : null;
|
|
443
|
+
const stagedTab: RightPanelTabRecord | null = chatId ? stagedTabsByChatId[chatId] ?? null : null;
|
|
444
|
+
stagedTabRef.current = stagedTab;
|
|
416
445
|
const panelOpen = panelEntry !== null && panelEntry.collapsed !== true;
|
|
417
446
|
const activePanelTab = panelOpen
|
|
418
447
|
? panelEntry.tabs.find((tab) => tab.id === panelEntry.activeTabId) ?? null
|
|
419
448
|
: null;
|
|
449
|
+
const hiddenActiveTab = !panelOpen
|
|
450
|
+
? (panelEntry?.tabs.find((tab) => tab.id === panelEntry.activeTabId)
|
|
451
|
+
?? panelEntry?.tabs[0]
|
|
452
|
+
?? stagedTab)
|
|
453
|
+
: null;
|
|
454
|
+
const hiddenPanelCount = !panelOpen
|
|
455
|
+
? (panelEntry && panelEntry.tabs.length > 0 ? panelEntry.tabs.length : stagedTab ? 1 : 0)
|
|
456
|
+
: 0;
|
|
457
|
+
const hiddenPanelTitle = hiddenActiveTab?.title ?? null;
|
|
420
458
|
const rightPanel: RightPanelState = activePanelTab?.kind ?? null;
|
|
421
459
|
const openPanelIds = panelOpen
|
|
422
460
|
? [...new Set(panelEntry.tabs.map((tab) => tab.kind))]
|
|
@@ -511,11 +549,16 @@ function AgentLayoutContent() {
|
|
|
511
549
|
applyPanelEntry(expandRightPanel(current));
|
|
512
550
|
return;
|
|
513
551
|
}
|
|
552
|
+
if (stagedTabRef.current) {
|
|
553
|
+
setInspectedTask(null);
|
|
554
|
+
applyPanelEntry(openRightPanelTab(null, stagedTabRef.current));
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
514
557
|
const first = packChatSlots[0]?.slotId ?? sanitizeRightPanelKind('terminal');
|
|
515
558
|
if (!first) return;
|
|
516
559
|
setInspectedTask(null);
|
|
517
560
|
openPanelKind(first);
|
|
518
|
-
}, [openPanelKind, packChatSlots]);
|
|
561
|
+
}, [applyPanelEntry, openPanelKind, packChatSlots]);
|
|
519
562
|
|
|
520
563
|
const collapseRightSide = useCallback(() => {
|
|
521
564
|
const current = panelEntryRef.current;
|
|
@@ -639,14 +682,43 @@ function AgentLayoutContent() {
|
|
|
639
682
|
// 交付文件点击要打开对应栏位。菜单按钮不在文档里时也能切过去。
|
|
640
683
|
useEffect(() => subscribeChatSlotRequests(openPanelTab), [openPanelTab]);
|
|
641
684
|
|
|
685
|
+
// 本会话活跃回合新产出主交付物时,自动展开右侧预览(若用户曾主动收起则保持收起并点亮角标)。
|
|
686
|
+
useEffect(() => subscribeChatSlotReveals((request) => {
|
|
687
|
+
const tab = tabForRequest(request);
|
|
688
|
+
if (!tab || tab.kind === 'terminal') return;
|
|
689
|
+
const current = panelEntryRef.current;
|
|
690
|
+
const next = revealDeliverableRightPanelTab(current, tab);
|
|
691
|
+
if (next === current) return;
|
|
692
|
+
if (!next.collapsed && current === null) setInspectedTask(null);
|
|
693
|
+
applyPanelEntry(next);
|
|
694
|
+
}), [applyPanelEntry, tabForRequest]);
|
|
695
|
+
|
|
642
696
|
// 对话滚动或新产物换右侧正在看的文件。关着的栏不弹出,终端不被抢走。
|
|
643
697
|
useEffect(() => subscribeChatSlotFollows((request) => {
|
|
644
698
|
const tab = tabForRequest(request);
|
|
645
699
|
if (!tab || tab.kind === 'terminal') return;
|
|
646
|
-
const
|
|
647
|
-
if (
|
|
700
|
+
const current = panelEntryRef.current;
|
|
701
|
+
if (current === null) {
|
|
702
|
+
if (chatId) {
|
|
703
|
+
setStagedTabsByChatId((prev) => {
|
|
704
|
+
const existing = prev[chatId];
|
|
705
|
+
if (
|
|
706
|
+
existing
|
|
707
|
+
&& existing.kind === tab.kind
|
|
708
|
+
&& existing.contentId === tab.contentId
|
|
709
|
+
&& existing.title === tab.title
|
|
710
|
+
) {
|
|
711
|
+
return prev;
|
|
712
|
+
}
|
|
713
|
+
return { ...prev, [chatId]: tab };
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
const next = followRightPanelTab(current, tab);
|
|
719
|
+
if (!next || next === current) return;
|
|
648
720
|
applyPanelEntry(next);
|
|
649
|
-
}), [applyPanelEntry, tabForRequest]);
|
|
721
|
+
}), [applyPanelEntry, chatId, tabForRequest]);
|
|
650
722
|
|
|
651
723
|
// Same drag ergonomics as the sidebar handle, mirrored: the terminal's
|
|
652
724
|
// right edge is pinned to the window's right padding (p-1.5 = 6px), so the
|
|
@@ -728,10 +800,144 @@ function AgentLayoutContent() {
|
|
|
728
800
|
? []
|
|
729
801
|
: (activeApp?.hiddenNavItems ?? []);
|
|
730
802
|
|
|
803
|
+
const hiddenSet = useMemo(() => new Set(hiddenNavItems), [hiddenNavItems]);
|
|
804
|
+
const pluginsAvailable =
|
|
805
|
+
(!hiddenSet.has('agents') && settingsChrome('agents')) ||
|
|
806
|
+
(!hiddenSet.has('skills') && settingsChrome('skills')) ||
|
|
807
|
+
(!hiddenSet.has('mcp') && settingsChrome('mcp')) ||
|
|
808
|
+
(!(hiddenSet.has('agents') && hiddenSet.has('skills') && hiddenSet.has('mcp')) &&
|
|
809
|
+
settingsChrome('web-search'));
|
|
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
|
+
|
|
850
|
+
const settingsSection = useMemo(
|
|
851
|
+
() => new URLSearchParams(location.search).get('section'),
|
|
852
|
+
[location.search],
|
|
853
|
+
);
|
|
854
|
+
const onPluginsSettings =
|
|
855
|
+
pluginsAvailable &&
|
|
856
|
+
onSettingsPage &&
|
|
857
|
+
(settingsSection === 'plugins' ||
|
|
858
|
+
settingsSection === 'agents' ||
|
|
859
|
+
settingsSection === 'skills' ||
|
|
860
|
+
settingsSection === 'mcp');
|
|
861
|
+
const onGeneralSettings = onSettingsPage && !onPluginsSettings;
|
|
862
|
+
const onNewChatHome = !chatId && !onSettingsPage;
|
|
863
|
+
|
|
864
|
+
// 收起侧边栏或处在设置页时 AgentSidebar 未挂载,由外层补接菜单 Cmd+N。
|
|
865
|
+
useEffect(() => {
|
|
866
|
+
if (!sidebarCollapsed && !onSettingsPage) return;
|
|
867
|
+
const bridge = getHostBridge();
|
|
868
|
+
if (!bridge?.onMenuNewChat) return;
|
|
869
|
+
bridge.onMenuNewChat(() => {
|
|
870
|
+
navigate('/agent');
|
|
871
|
+
});
|
|
872
|
+
return () => {
|
|
873
|
+
bridge.offMenuNewChat?.();
|
|
874
|
+
};
|
|
875
|
+
}, [sidebarCollapsed, onSettingsPage, navigate]);
|
|
876
|
+
|
|
877
|
+
useEffect(() => {
|
|
878
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
879
|
+
if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey && event.key.toLowerCase() === 'o') {
|
|
880
|
+
event.preventDefault();
|
|
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();
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
window.addEventListener('keydown', onKeyDown);
|
|
911
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
912
|
+
}, [navigate, onSettingsPage, exitSettings, pluginsAvailable]);
|
|
913
|
+
|
|
731
914
|
return (
|
|
732
915
|
<div className="relative flex h-full w-full bg-agent-muted/30">
|
|
733
|
-
{
|
|
734
|
-
|
|
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 ? (
|
|
940
|
+
// 收起态:窄 rail 提供展开、新对话、插件与底部设置快捷入口。
|
|
735
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">
|
|
736
942
|
<div className="flex h-11 w-full items-center justify-center">
|
|
737
943
|
<button
|
|
@@ -744,6 +950,59 @@ function AgentLayoutContent() {
|
|
|
744
950
|
<LuPanelLeftOpen className="h-3.5 w-3.5" />
|
|
745
951
|
</button>
|
|
746
952
|
</div>
|
|
953
|
+
<div className="flex flex-col items-center gap-0.5 pb-1">
|
|
954
|
+
<button
|
|
955
|
+
type="button"
|
|
956
|
+
data-testid="sidebar-rail-new-chat"
|
|
957
|
+
onClick={() => navigate('/agent')}
|
|
958
|
+
className={[
|
|
959
|
+
'flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200',
|
|
960
|
+
onNewChatHome
|
|
961
|
+
? 'bg-agent-foreground/10 text-agent-foreground'
|
|
962
|
+
: 'text-agent-foreground/85 hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
963
|
+
].join(' ')}
|
|
964
|
+
title={t('Start a new chat')}
|
|
965
|
+
aria-label={t('Start a new chat')}
|
|
966
|
+
>
|
|
967
|
+
<LuSquarePen className="h-3.5 w-3.5" />
|
|
968
|
+
</button>
|
|
969
|
+
{pluginsAvailable && (
|
|
970
|
+
<button
|
|
971
|
+
type="button"
|
|
972
|
+
data-testid="sidebar-rail-plugins"
|
|
973
|
+
onClick={() => navigate('/settings?section=plugins')}
|
|
974
|
+
className={[
|
|
975
|
+
'flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200',
|
|
976
|
+
onPluginsSettings
|
|
977
|
+
? 'bg-agent-foreground/10 text-agent-foreground'
|
|
978
|
+
: 'text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
979
|
+
].join(' ')}
|
|
980
|
+
title={t('Plugins')}
|
|
981
|
+
aria-label={t('Plugins')}
|
|
982
|
+
>
|
|
983
|
+
<LuBlocks className="h-3.5 w-3.5" />
|
|
984
|
+
</button>
|
|
985
|
+
)}
|
|
986
|
+
</div>
|
|
987
|
+
{hasGeneralSettingsChrome() && (
|
|
988
|
+
<div className="mt-auto flex w-full flex-col items-center border-t border-agent-border/40 py-1.5">
|
|
989
|
+
<button
|
|
990
|
+
type="button"
|
|
991
|
+
data-testid="sidebar-rail-settings"
|
|
992
|
+
onClick={() => navigate('/settings')}
|
|
993
|
+
className={[
|
|
994
|
+
'flex h-7 w-7 items-center justify-center rounded-full transition-colors duration-200',
|
|
995
|
+
onGeneralSettings
|
|
996
|
+
? 'bg-agent-foreground/10 text-agent-foreground'
|
|
997
|
+
: 'text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
998
|
+
].join(' ')}
|
|
999
|
+
title={t('Settings')}
|
|
1000
|
+
aria-label={t('Settings')}
|
|
1001
|
+
>
|
|
1002
|
+
<LuSettings className="h-3.5 w-3.5" />
|
|
1003
|
+
</button>
|
|
1004
|
+
</div>
|
|
1005
|
+
)}
|
|
747
1006
|
</div>
|
|
748
1007
|
) : (
|
|
749
1008
|
<>
|
|
@@ -792,13 +1051,17 @@ function AgentLayoutContent() {
|
|
|
792
1051
|
chatSlots: packChatSlots,
|
|
793
1052
|
rightPanel,
|
|
794
1053
|
openPanelIds,
|
|
1054
|
+
hiddenPanelCount,
|
|
1055
|
+
hiddenPanelTitle,
|
|
795
1056
|
onOpenRightPanel: expandRightSide,
|
|
1057
|
+
hiddenNavItems,
|
|
1058
|
+
onExitSettings: exitSettings,
|
|
796
1059
|
} satisfies AgentOutletContext}
|
|
797
1060
|
/>
|
|
798
1061
|
</div>
|
|
799
1062
|
{settingsChrome('insights') && <InsightsConsentBanner />}
|
|
800
1063
|
</div>
|
|
801
|
-
{(panelOpen || inspectedTask !== null) && (
|
|
1064
|
+
{!onSettingsPage && (panelOpen || inspectedTask !== null) && (
|
|
802
1065
|
<>
|
|
803
1066
|
<div
|
|
804
1067
|
role="separator"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LuPanelRight, LuPanelRightClose } from 'react-icons/lu';
|
|
2
2
|
import { t } from '@/i18n';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,30 +6,48 @@ import { t } from '@/i18n';
|
|
|
6
6
|
*/
|
|
7
7
|
export function PanelToggleButton({
|
|
8
8
|
pressed,
|
|
9
|
+
hiddenTabCount = 0,
|
|
10
|
+
hiddenActiveTitle = null,
|
|
9
11
|
onClick,
|
|
10
12
|
}: {
|
|
11
13
|
pressed: boolean;
|
|
14
|
+
hiddenTabCount?: number;
|
|
15
|
+
hiddenActiveTitle?: string | null;
|
|
12
16
|
onClick: () => void;
|
|
13
17
|
}) {
|
|
18
|
+
const showBadge = !pressed && hiddenTabCount > 0;
|
|
19
|
+
const title = pressed
|
|
20
|
+
? t('Close {name}', { name: t('Panels') })
|
|
21
|
+
: showBadge && hiddenActiveTitle
|
|
22
|
+
? t('Open preview ({title})', { title: hiddenActiveTitle })
|
|
23
|
+
: t('Open {name}', { name: t('Panels') });
|
|
24
|
+
|
|
14
25
|
return (
|
|
15
26
|
<button
|
|
16
27
|
type="button"
|
|
17
28
|
onClick={onClick}
|
|
18
|
-
className={`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground ${
|
|
29
|
+
className={`relative flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground ${
|
|
19
30
|
pressed
|
|
20
31
|
? 'bg-agent-foreground/10 text-agent-foreground'
|
|
21
32
|
: 'text-agent-muted-foreground'
|
|
22
33
|
}`}
|
|
23
|
-
title={
|
|
24
|
-
|
|
25
|
-
? t('Close {name}', { name: t('Panels') })
|
|
26
|
-
: t('Open {name}', { name: t('Panels') })
|
|
27
|
-
}
|
|
28
|
-
aria-label={t('Panels')}
|
|
34
|
+
title={title}
|
|
35
|
+
aria-label={showBadge && hiddenActiveTitle ? title : t('Panels')}
|
|
29
36
|
aria-pressed={pressed}
|
|
30
37
|
data-testid="header-chat-panels"
|
|
31
38
|
>
|
|
32
|
-
|
|
39
|
+
{pressed ? (
|
|
40
|
+
<LuPanelRightClose className="h-4 w-4" />
|
|
41
|
+
) : (
|
|
42
|
+
<LuPanelRight className="h-4 w-4" />
|
|
43
|
+
)}
|
|
44
|
+
{showBadge && (
|
|
45
|
+
<span
|
|
46
|
+
className="pointer-events-none absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-agent-accent ring-2 ring-agent-canvas"
|
|
47
|
+
data-testid="header-chat-panels-badge"
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
33
51
|
</button>
|
|
34
52
|
);
|
|
35
53
|
}
|
|
@@ -9,6 +9,8 @@ export interface ConversationPreviewTarget {
|
|
|
9
9
|
chatId: string;
|
|
10
10
|
messageId: string;
|
|
11
11
|
path: string;
|
|
12
|
+
/** True when this target is newly produced in the active turn and should auto-reveal the preview pane unless collapsed by user. */
|
|
13
|
+
autoReveal?: boolean;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const targets = new Map<string, ConversationPreviewTarget>();
|
|
@@ -22,6 +24,7 @@ function emit(target: ConversationPreviewTarget): void {
|
|
|
22
24
|
previous
|
|
23
25
|
&& previous.messageId === target.messageId
|
|
24
26
|
&& previous.path === target.path
|
|
27
|
+
&& !target.autoReveal
|
|
25
28
|
) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
@@ -13,6 +13,7 @@ export interface ChatSlotRequest {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const listeners = new Set<(request: ChatSlotRequest) => void>();
|
|
16
|
+
const revealListeners = new Set<(request: ChatSlotRequest) => void>();
|
|
16
17
|
const followListeners = new Set<(request: ChatSlotRequest) => void>();
|
|
17
18
|
|
|
18
19
|
/** 只用于读取 v1 持久化的 `slotId:resource:<encoded path>`。 */
|
|
@@ -45,6 +46,25 @@ export function subscribeChatSlotRequests(
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Auto-reveal a newly produced deliverable in the right panel:
|
|
51
|
+
* opens the panel when untouched, switches document tabs when already open,
|
|
52
|
+
* and respects an explicit user collapse in the current chat by staging the tab.
|
|
53
|
+
*/
|
|
54
|
+
export function revealChatSlot(kind: string, options: Omit<ChatSlotRequest, 'kind'> = {}): void {
|
|
55
|
+
const request = { kind, ...options };
|
|
56
|
+
for (const listener of revealListeners) listener(request);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function subscribeChatSlotReveals(
|
|
60
|
+
listener: (request: ChatSlotRequest) => void,
|
|
61
|
+
): () => void {
|
|
62
|
+
revealListeners.add(listener);
|
|
63
|
+
return () => {
|
|
64
|
+
revealListeners.delete(listener);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
48
68
|
/**
|
|
49
69
|
* 对话滚动或新产物把右侧内容换到这个栏位。
|
|
50
70
|
* 和点击不同:栏位关着时不弹出,正在看终端时也不抢走。
|
|
@@ -307,3 +307,35 @@ export function openRightPanelTab(
|
|
|
307
307
|
if (existing) return { tabs: current.tabs, activeTabId: existing.id };
|
|
308
308
|
return { tabs: [...current.tabs, requested], activeTabId: requested.id };
|
|
309
309
|
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Auto-reveal a newly generated turn deliverable:
|
|
313
|
+
* - Untouched chat (`current === null`): opens the right panel on this deliverable.
|
|
314
|
+
* - Explicitly collapsed chat (`current.collapsed === true`): stages/updates the tab while keeping it collapsed.
|
|
315
|
+
* - Open panel on terminal: appends the deliverable tab without stealing terminal focus.
|
|
316
|
+
* - Open panel on another document: appends/activates the new deliverable tab.
|
|
317
|
+
*/
|
|
318
|
+
export function revealDeliverableRightPanelTab(
|
|
319
|
+
current: RightPanelTabs | null,
|
|
320
|
+
requested: RightPanelTabRecord,
|
|
321
|
+
): RightPanelTabs {
|
|
322
|
+
if (!current) return { tabs: [requested], activeTabId: requested.id };
|
|
323
|
+
if (current.collapsed) {
|
|
324
|
+
return (
|
|
325
|
+
followRightPanelTab(current, requested) ?? {
|
|
326
|
+
tabs: [requested],
|
|
327
|
+
activeTabId: requested.id,
|
|
328
|
+
collapsed: true,
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
const existing = findRightPanelContentTab(current, requested);
|
|
333
|
+
const tab = existing ?? requested;
|
|
334
|
+
const tabs = existing ? current.tabs : [...current.tabs, tab];
|
|
335
|
+
const activeTab = current.tabs.find((item) => item.id === current.activeTabId);
|
|
336
|
+
const activeTabId = activeTab?.kind === 'terminal' ? activeTab.id : tab.id;
|
|
337
|
+
if (current.activeTabId === activeTabId && sameRightPanelTabs(current.tabs, tabs)) {
|
|
338
|
+
return current;
|
|
339
|
+
}
|
|
340
|
+
return { tabs, activeTabId };
|
|
341
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product-neutral registry for in-app deliverable preview handlers.
|
|
3
|
+
*
|
|
4
|
+
* Host packs register file matchers and side-panel openers here so
|
|
5
|
+
* `DeliverableCard` can render a first-class `Preview` button without
|
|
6
|
+
* coupling `@steerable/agent-shell-web` to specific document packs.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface DeliverablePreviewOpenInput {
|
|
10
|
+
chatId: string | null;
|
|
11
|
+
messageId?: string;
|
|
12
|
+
filePath: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DeliverablePreviewHandler {
|
|
16
|
+
id: string;
|
|
17
|
+
canPreview: (filePath: string) => boolean;
|
|
18
|
+
openPreview: (input: DeliverablePreviewOpenInput) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const handlers = new Map<string, DeliverablePreviewHandler>();
|
|
22
|
+
const listeners = new Set<() => void>();
|
|
23
|
+
|
|
24
|
+
function notify(): void {
|
|
25
|
+
for (const listener of listeners) listener();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function registerDeliverablePreviewer(handler: DeliverablePreviewHandler): () => void {
|
|
29
|
+
handlers.set(handler.id, handler);
|
|
30
|
+
notify();
|
|
31
|
+
return () => {
|
|
32
|
+
if (handlers.get(handler.id) === handler) {
|
|
33
|
+
handlers.delete(handler.id);
|
|
34
|
+
notify();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function findDeliverablePreviewer(filePath: string): DeliverablePreviewHandler | null {
|
|
40
|
+
if (!filePath) return null;
|
|
41
|
+
for (const handler of handlers.values()) {
|
|
42
|
+
if (handler.canPreview(filePath)) return handler;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function subscribeDeliverablePreviewers(listener: () => void): () => void {
|
|
48
|
+
listeners.add(listener);
|
|
49
|
+
return () => {
|
|
50
|
+
listeners.delete(listener);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function clearDeliverablePreviewersForTests(): void {
|
|
55
|
+
handlers.clear();
|
|
56
|
+
notify();
|
|
57
|
+
}
|
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[] = [];
|