@steerable/agent-shell-web 0.14.3 → 0.14.5

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.
Files changed (30) hide show
  1. package/package.json +4 -4
  2. package/src/components/AgentSidebar.tsx +189 -46
  3. package/src/components/ChatHeader.tsx +12 -1
  4. package/src/components/SidebarAccount.tsx +33 -41
  5. package/src/components/chat/AssistantMessage.tsx +36 -10
  6. package/src/components/chat/ChatInput.tsx +308 -131
  7. package/src/components/chat/ChatProjectBadge.tsx +311 -100
  8. package/src/components/chat/ContextUsagePill.tsx +20 -5
  9. package/src/components/chat/ExecPolicyPicker.tsx +72 -67
  10. package/src/components/chat/LocalChatPanel.tsx +33 -35
  11. package/src/components/chat/Markdown.tsx +109 -11
  12. package/src/components/chat/MessageList.tsx +109 -19
  13. package/src/components/chat/ModelPicker.tsx +2 -2
  14. package/src/components/chat/PlanTodoList.tsx +184 -78
  15. package/src/components/chat/SessionTodoList.tsx +63 -72
  16. package/src/components/chat/TurnFilesCard.tsx +270 -112
  17. package/src/components/chat/TurnProcessGroup.tsx +3 -0
  18. package/src/components/chat/TurnProcessTimeline.tsx +13 -0
  19. package/src/components/chat/UserMessage.tsx +8 -1
  20. package/src/components/chat/next-steps-tags.ts +13 -0
  21. package/src/components/chat/process-status.ts +112 -2
  22. package/src/components/chat/todo-list-model.ts +52 -4
  23. package/src/layouts/AgentLayout.tsx +173 -10
  24. package/src/layouts/PanelToggleButton.tsx +27 -9
  25. package/src/layouts/conversation-preview.ts +3 -0
  26. package/src/layouts/request-chat-slot.ts +20 -0
  27. package/src/layouts/right-panel-tabs.ts +32 -0
  28. package/src/lib/chat-mode-store.ts +241 -0
  29. package/src/lib/file-preview-registry.ts +57 -0
  30. package/src/pages/AgentPage.tsx +188 -78
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerable/agent-shell-web",
3
- "version": "0.14.3",
3
+ "version": "0.14.5",
4
4
  "type": "module",
5
5
  "description": "Steerable framework — product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/), plus the compiled vite.base config factory (vite.base.js + .d.ts) for Node-side config loading.",
6
6
  "license": "Apache-2.0",
@@ -45,8 +45,8 @@
45
45
  "react-router-dom": "^6.30.0",
46
46
  "rehype-raw": "^7.0.0",
47
47
  "remark-gfm": "^4.0.1",
48
- "@steerable/agent-protocol": "0.14.3",
49
- "@steerable/agent-ui": "0.14.3"
48
+ "@steerable/agent-protocol": "0.14.5",
49
+ "@steerable/agent-ui": "0.14.5"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@tailwindcss/vite": "^4.3.0",
@@ -59,7 +59,7 @@
59
59
  "typescript": "^5.8.3",
60
60
  "vite": "^5.4.21",
61
61
  "vitest": "^3.2.4",
62
- "@steerable/pack-sdk": "0.14.3"
62
+ "@steerable/pack-sdk": "0.14.5"
63
63
  },
64
64
  "scripts": {
65
65
  "gen": "echo agent-shell-web",
@@ -91,6 +91,8 @@ import {
91
91
  LuGitBranch,
92
92
  LuCircleHelp,
93
93
  LuTerminal,
94
+ LuSearch,
95
+ LuX,
94
96
  } from "react-icons/lu";
95
97
  import { RiPushpin2Fill, RiPushpin2Line } from "react-icons/ri";
96
98
  import { parseChatTitle } from "@/lib/chat-title";
@@ -483,12 +485,36 @@ export function AgentSidebar({
483
485
  } = data;
484
486
 
485
487
  const [isMac, setIsMac] = useState(false);
488
+ const [searchQuery, setSearchQuery] = useState("");
489
+ const searchInputRef = useRef<HTMLInputElement>(null);
490
+ const normalizedSearchQuery = searchQuery.trim().toLowerCase();
491
+ const isSearching = normalizedSearchQuery.length > 0;
492
+ const isDesktopApp =
493
+ typeof window !== "undefined" &&
494
+ (window.__TAURI_INTERNALS__ != null || window.steerableHost != null);
486
495
 
487
496
  useEffect(() => {
488
497
  if (typeof navigator !== "undefined") {
489
498
  setIsMac(/Mac|iPod|iPhone|iPad/.test(navigator.platform));
490
499
  }
491
500
  }, []);
501
+
502
+ useEffect(() => {
503
+ const onKeyDown = (event: KeyboardEvent) => {
504
+ if (
505
+ (event.metaKey || event.ctrlKey) &&
506
+ !event.shiftKey &&
507
+ !event.altKey &&
508
+ event.key.toLowerCase() === "k"
509
+ ) {
510
+ event.preventDefault();
511
+ searchInputRef.current?.focus();
512
+ searchInputRef.current?.select();
513
+ }
514
+ };
515
+ window.addEventListener("keydown", onKeyDown);
516
+ return () => window.removeEventListener("keydown", onKeyDown);
517
+ }, []);
492
518
  const [pendingDeleteChat, setPendingDeleteChat] = useState<{
493
519
  id: string;
494
520
  title: string;
@@ -969,10 +995,28 @@ export function AgentSidebar({
969
995
  }, [projects, normalizedChats, showProjectsChrome]);
970
996
 
971
997
  const pinnedChats = useMemo(
972
- () => normalizedChats.filter((c) => c.isPinned),
973
- [normalizedChats],
998
+ () =>
999
+ normalizedChats.filter(
1000
+ (c) =>
1001
+ c.isPinned &&
1002
+ (!isSearching || c.title.toLowerCase().includes(normalizedSearchQuery)),
1003
+ ),
1004
+ [normalizedChats, isSearching, normalizedSearchQuery],
974
1005
  );
975
1006
 
1007
+ const visibleProjectGroups = useMemo(() => {
1008
+ if (!isSearching) return projectGroups;
1009
+ return projectGroups.flatMap(({ project, items }) => {
1010
+ if (project.name.toLowerCase().includes(normalizedSearchQuery)) {
1011
+ return [{ project, items }];
1012
+ }
1013
+ const matched = items.filter((c) =>
1014
+ c.title.toLowerCase().includes(normalizedSearchQuery),
1015
+ );
1016
+ return matched.length > 0 ? [{ project, items: matched }] : [];
1017
+ });
1018
+ }, [projectGroups, isSearching, normalizedSearchQuery]);
1019
+
976
1020
  const recentChatGroups = useMemo(() => {
977
1021
  const map = new Map<
978
1022
  string,
@@ -983,7 +1027,11 @@ export function AgentSidebar({
983
1027
  }
984
1028
  >();
985
1029
  noProjectChats
986
- .filter((chat) => !chat.isPinned)
1030
+ .filter(
1031
+ (chat) =>
1032
+ !chat.isPinned &&
1033
+ (!isSearching || chat.title.toLowerCase().includes(normalizedSearchQuery)),
1034
+ )
987
1035
  .forEach((chat) => {
988
1036
  const label = getDateGroupLabel(chat.sortDate);
989
1037
  if (!map.has(label)) {
@@ -996,11 +1044,15 @@ export function AgentSidebar({
996
1044
  map.get(label)!.items.push(chat);
997
1045
  });
998
1046
  return Array.from(map.values()).sort((a, b) => a.priority - b.priority);
999
- }, [noProjectChats]);
1047
+ }, [noProjectChats, isSearching, normalizedSearchQuery]);
1000
1048
 
1001
- const isPinnedExpanded = pinnedExpanded ?? pinnedChats.length > 0;
1002
- const isProjectsExpanded = projectsExpanded ?? true;
1003
- const isRecentsExpanded = recentsExpanded ?? true;
1049
+ const isPinnedExpanded = isSearching || (pinnedExpanded ?? pinnedChats.length > 0);
1050
+ const isProjectsExpanded = isSearching || (projectsExpanded ?? true);
1051
+ const isRecentsExpanded = isSearching || (recentsExpanded ?? true);
1052
+ const hasAnySearchMatch =
1053
+ pinnedChats.length > 0 ||
1054
+ visibleProjectGroups.length > 0 ||
1055
+ recentChatGroups.length > 0;
1004
1056
 
1005
1057
  const handleDeleteChat = useCallback(async () => {
1006
1058
  if (!pendingDeleteChat || deletingChatId === pendingDeleteChat.id) return;
@@ -1345,7 +1397,7 @@ export function AgentSidebar({
1345
1397
  container.scrollHeight - 60;
1346
1398
  const needsCompleteProjectGroups =
1347
1399
  showProjectsChrome && projects.length > 0;
1348
- if (nearBottom || needsCompleteProjectGroups) void loadMoreChats();
1400
+ if (nearBottom || needsCompleteProjectGroups || isSearching) void loadMoreChats();
1349
1401
  };
1350
1402
  container.addEventListener("scroll", maybeLoadMore, { passive: true });
1351
1403
  const tickId = window.requestAnimationFrame(maybeLoadMore);
@@ -1358,6 +1410,7 @@ export function AgentSidebar({
1358
1410
  isLoadingMoreChats,
1359
1411
  loadMoreChats,
1360
1412
  isRecentsExpanded,
1413
+ isSearching,
1361
1414
  normalizedChats.length,
1362
1415
  projects.length,
1363
1416
  showProjectsChrome,
@@ -1381,6 +1434,14 @@ export function AgentSidebar({
1381
1434
  ),
1382
1435
  });
1383
1436
 
1437
+ const newChatShortcut = isMac
1438
+ ? isDesktopApp
1439
+ ? "⌘N"
1440
+ : "⇧⌘O"
1441
+ : isDesktopApp
1442
+ ? "Ctrl+N"
1443
+ : "Ctrl+Shift+O";
1444
+
1384
1445
  return (
1385
1446
  <div className="flex h-full w-full flex-col border-r border-agent-border/60 bg-agent-muted/70 backdrop-blur-md">
1386
1447
  {/* ───── Brand + actions ───── */}
@@ -1401,23 +1462,76 @@ export function AgentSidebar({
1401
1462
 
1402
1463
  {/* ───── 会话 ───── */}
1403
1464
  <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
1404
- {/* 新对话 + 插件(智能体 / Skills / MCP / 网络搜索在同一页用分类切换) */}
1405
- <div className="flex-shrink-0 space-y-0.5 px-2.5 pb-0.5">
1465
+ {/* 新对话 + 快速搜索 + 插件(智能体 / Skills / MCP / 网络搜索在同一页用分类切换) */}
1466
+ <div className="flex-shrink-0 space-y-0.5 px-2.5 pb-1">
1406
1467
  <button
1407
1468
  type="button"
1408
1469
  onClick={() => handleOpenNewChat()}
1409
1470
  className={[
1410
- "flex h-7 w-full items-center gap-1.5 rounded-full px-2.5 text-xs transition-colors",
1471
+ "group/newchat flex h-7 w-full items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors",
1411
1472
  onNewChatHome
1412
- ? "bg-agent-foreground/10 font-medium text-agent-foreground"
1413
- : "text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground",
1473
+ ? "bg-agent-foreground/10 text-agent-foreground"
1474
+ : "text-agent-foreground/90 hover:bg-agent-foreground/6 hover:text-agent-foreground",
1414
1475
  ].join(" ")}
1415
- title={t("Start a new chat")}
1476
+ title={`${t("Start a new chat")} (${newChatShortcut})`}
1416
1477
  data-testid="sidebar-new-chat"
1417
1478
  >
1418
- <LuSquarePen className="h-3.5 w-3.5" />
1419
- <span>{t("New chat")}</span>
1479
+ <LuSquarePen className="h-3.5 w-3.5 shrink-0" />
1480
+ <span className="truncate">{t("New chat")}</span>
1481
+ <kbd
1482
+ aria-hidden="true"
1483
+ className="ml-auto shrink-0 font-sans text-[10px] font-normal tracking-tight text-agent-muted-foreground/55 opacity-0 transition-opacity group-hover/newchat:opacity-100 group-focus-visible/newchat:opacity-100"
1484
+ >
1485
+ {newChatShortcut}
1486
+ </kbd>
1420
1487
  </button>
1488
+ <div className="group/search relative flex h-7 w-full items-center rounded-full px-2.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 focus-within:bg-agent-canvas focus-within:text-agent-foreground focus-within:shadow-2xs focus-within:ring-1 focus-within:ring-inset focus-within:ring-agent-border/80">
1489
+ <LuSearch
1490
+ className="mr-1.5 h-3.5 w-3.5 shrink-0 text-agent-muted-foreground"
1491
+ aria-hidden="true"
1492
+ />
1493
+ <input
1494
+ ref={searchInputRef}
1495
+ type="search"
1496
+ value={searchQuery}
1497
+ onChange={(event) => setSearchQuery(event.target.value)}
1498
+ onKeyDown={(event) => {
1499
+ if (event.key !== "Escape") return;
1500
+ event.preventDefault();
1501
+ if (searchQuery) {
1502
+ setSearchQuery("");
1503
+ } else {
1504
+ event.currentTarget.blur();
1505
+ }
1506
+ }}
1507
+ placeholder={t("Search chats…")}
1508
+ aria-label={t("Search chats")}
1509
+ data-testid="sidebar-chat-search"
1510
+ className="w-full min-w-0 bg-transparent text-xs text-agent-foreground placeholder:text-agent-muted-foreground focus:outline-none [&::-webkit-search-cancel-button]:hidden"
1511
+ />
1512
+ {searchQuery ? (
1513
+ <button
1514
+ type="button"
1515
+ onClick={() => {
1516
+ setSearchQuery("");
1517
+ searchInputRef.current?.focus();
1518
+ }}
1519
+ aria-label={t("Clear search")}
1520
+ title={t("Clear search")}
1521
+ data-testid="sidebar-chat-search-clear"
1522
+ className="-mr-1 ml-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground hover:bg-agent-foreground/10 hover:text-agent-foreground"
1523
+ >
1524
+ <LuX className="h-3 w-3" />
1525
+ </button>
1526
+ ) : (
1527
+ <kbd
1528
+ aria-hidden="true"
1529
+ className="ml-1 shrink-0 font-sans text-[10px] text-agent-muted-foreground/50 opacity-0 transition-opacity group-hover/search:opacity-100"
1530
+ >
1531
+ {isMac ? "⌘K" : "Ctrl+K"}
1532
+ </kbd>
1533
+ )}
1534
+ </div>
1421
1535
  {pluginsAvailable && (
1422
1536
  <button
1423
1537
  type="button"
@@ -1431,7 +1545,7 @@ export function AgentSidebar({
1431
1545
  title={t("Plugins")}
1432
1546
  data-testid="sidebar-plugins"
1433
1547
  >
1434
- <LuBlocks className="h-3.5 w-3.5" />
1548
+ <LuBlocks className="h-3.5 w-3.5 shrink-0" />
1435
1549
  <span>{t("Plugins")}</span>
1436
1550
  </button>
1437
1551
  )}
@@ -1446,17 +1560,24 @@ export function AgentSidebar({
1446
1560
  <LuLoaderCircle className="mr-1.5 h-3 w-3 animate-spin" />
1447
1561
  {t("Loading...")}
1448
1562
  </div>
1563
+ ) : isSearching && !hasAnySearchMatch ? (
1564
+ <div
1565
+ className="px-2.5 py-6 text-center text-xs text-agent-muted-foreground"
1566
+ data-testid="sidebar-search-empty"
1567
+ >
1568
+ {t("No matching chats")}
1569
+ </div>
1449
1570
  ) : (
1450
1571
  <>
1451
1572
  {/* 1. 置顶 (Pinned):没有置顶会话时整组不出现 */}
1452
1573
  {pinnedChats.length > 0 && (
1453
1574
  <div className="mb-1.5">
1454
- <div className="group/section flex h-7 items-center justify-between rounded-agent-md px-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1575
+ <div className="group/section flex h-7 items-center justify-between rounded-full pl-2.5 pr-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1455
1576
  <button
1456
1577
  type="button"
1457
1578
  aria-expanded={isPinnedExpanded}
1458
1579
  onClick={() => {
1459
- const next = !isPinnedExpanded;
1580
+ const next = !(pinnedExpanded ?? pinnedChats.length > 0);
1460
1581
  setPinnedExpanded(next);
1461
1582
  writeSidebarSectionExpanded("pinned", next);
1462
1583
  }}
@@ -1479,14 +1600,14 @@ export function AgentSidebar({
1479
1600
  )}
1480
1601
 
1481
1602
  {/* 2. 项目 (Projects) */}
1482
- {showProjectsChrome && (
1603
+ {showProjectsChrome && (!isSearching || visibleProjectGroups.length > 0) && (
1483
1604
  <div className="mb-1.5">
1484
- <div className="group/section flex h-7 items-center justify-between rounded-agent-md px-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1605
+ <div className="group/section flex h-7 items-center justify-between rounded-full pl-2.5 pr-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1485
1606
  <button
1486
1607
  type="button"
1487
1608
  aria-expanded={isProjectsExpanded}
1488
1609
  onClick={() => {
1489
- const next = !isProjectsExpanded;
1610
+ const next = !(projectsExpanded ?? true);
1490
1611
  setProjectsExpanded(next);
1491
1612
  writeSidebarSectionExpanded("projects", next);
1492
1613
  }}
@@ -1506,7 +1627,12 @@ export function AgentSidebar({
1506
1627
  e.stopPropagation();
1507
1628
  setCreateProjectOpen(true);
1508
1629
  }}
1509
- className="flex h-5 w-5 items-center justify-center rounded-full text-agent-muted-foreground opacity-0 transition-opacity duration-200 hover:bg-agent-foreground/10 hover:text-agent-foreground group-hover/section:opacity-100 focus:opacity-100"
1630
+ className={[
1631
+ "flex h-5 w-5 items-center justify-center rounded-full text-agent-muted-foreground transition-opacity duration-200 hover:bg-agent-foreground/10 hover:text-agent-foreground focus:opacity-100",
1632
+ projectGroups.length === 0
1633
+ ? "opacity-70 hover:opacity-100"
1634
+ : "opacity-0 group-hover/section:opacity-100",
1635
+ ].join(" ")}
1510
1636
  title={t("New project")}
1511
1637
  aria-label={t("New project")}
1512
1638
  >
@@ -1516,12 +1642,27 @@ export function AgentSidebar({
1516
1642
  </div>
1517
1643
  {isProjectsExpanded && (
1518
1644
  <div className="space-y-0.5">
1519
- {projectGroups.length === 0 ? (
1520
- <div className="px-2.5 py-1 text-[11px] text-agent-muted-foreground/60">
1521
- {t("No projects")}
1522
- </div>
1645
+ {visibleProjectGroups.length === 0 ? (
1646
+ hasElectron ? (
1647
+ <button
1648
+ type="button"
1649
+ data-testid="sidebar-empty-create-project"
1650
+ onClick={() => setCreateProjectOpen(true)}
1651
+ className="flex h-7 w-full items-center gap-1.5 rounded-full px-2.5 text-xs text-agent-muted-foreground/75 transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground"
1652
+ >
1653
+ <LuFolderPlus className="h-3.5 w-3.5 shrink-0 opacity-75" />
1654
+ <span className="truncate">{t("Create first project")}</span>
1655
+ </button>
1656
+ ) : (
1657
+ <div className="px-2.5 py-1 text-[11px] text-agent-muted-foreground/60">
1658
+ {t("No projects")}
1659
+ </div>
1660
+ )
1523
1661
  ) : (
1524
- projectGroups.map(({ project, items }) => (
1662
+ visibleProjectGroups.map(({ project, items }) => {
1663
+ const isProjectCollapsed =
1664
+ !isSearching && collapsedProjectIds.has(project.id);
1665
+ return (
1525
1666
  <div
1526
1667
  key={project.id}
1527
1668
  data-testid="sidebar-project"
@@ -1617,7 +1758,7 @@ export function AgentSidebar({
1617
1758
  <>
1618
1759
  <button
1619
1760
  type="button"
1620
- draggable
1761
+ draggable={!isSearching}
1621
1762
  data-testid="sidebar-project-handle"
1622
1763
  data-project-id={project.id}
1623
1764
  onDragStart={(event) => {
@@ -1641,10 +1782,10 @@ export function AgentSidebar({
1641
1782
  if (projectDragMovedRef.current) return;
1642
1783
  toggleProjectCollapsed(project.id);
1643
1784
  }}
1644
- className="flex w-full min-w-0 cursor-grab items-center px-2 pb-0.5 pt-1 text-[11px] font-medium text-agent-muted-foreground/90 transition-colors hover:text-agent-foreground active:cursor-grabbing"
1785
+ className="flex w-full min-w-0 cursor-grab items-center px-2.5 pb-0.5 pt-1 text-[11px] font-medium text-agent-muted-foreground/90 transition-colors hover:text-agent-foreground active:cursor-grabbing"
1645
1786
  title={`${project.name}\n${project.folderPath}`}
1646
1787
  >
1647
- <LuFolder className="mr-1 h-3.5 w-3.5 shrink-0" />
1788
+ <LuFolder className="mr-1.5 h-3.5 w-3.5 shrink-0" />
1648
1789
  <span className="min-w-0 truncate normal-case">
1649
1790
  {project.name}
1650
1791
  </span>
@@ -1659,7 +1800,7 @@ export function AgentSidebar({
1659
1800
  </span>
1660
1801
  ) : null}
1661
1802
  <span className="ml-1 shrink-0">
1662
- {collapsedProjectIds.has(project.id) ? (
1803
+ {isProjectCollapsed ? (
1663
1804
  <LuChevronRight className="h-3 w-3" />
1664
1805
  ) : (
1665
1806
  <LuChevronDown className="h-3 w-3" />
@@ -1702,7 +1843,7 @@ export function AgentSidebar({
1702
1843
  </>
1703
1844
  )}
1704
1845
  </div>
1705
- {!collapsedProjectIds.has(project.id) && (
1846
+ {!isProjectCollapsed && (
1706
1847
  <div className="space-y-0.5 pl-2">
1707
1848
  {items.length === 0 ? (
1708
1849
  <div className="px-2.5 py-0.5 text-[11px] text-agent-muted-foreground/60">
@@ -1710,9 +1851,10 @@ export function AgentSidebar({
1710
1851
  </div>
1711
1852
  ) : (
1712
1853
  (() => {
1713
- const limit =
1714
- projectChatLimits[project.id] ??
1715
- PROJECT_CHAT_PAGE;
1854
+ const limit = isSearching
1855
+ ? Number.POSITIVE_INFINITY
1856
+ : (projectChatLimits[project.id] ??
1857
+ PROJECT_CHAT_PAGE);
1716
1858
  const folded = projectChatWindow(
1717
1859
  items,
1718
1860
  PROJECT_CHAT_PAGE,
@@ -1724,7 +1866,7 @@ export function AgentSidebar({
1724
1866
  {shown.rows.map((chat) =>
1725
1867
  renderChatRow(chat),
1726
1868
  )}
1727
- {folded.hiddenCount > 0 && (
1869
+ {!isSearching && folded.hiddenCount > 0 && (
1728
1870
  <button
1729
1871
  type="button"
1730
1872
  data-testid="sidebar-project-show-more"
@@ -1752,7 +1894,8 @@ export function AgentSidebar({
1752
1894
  </div>
1753
1895
  )}
1754
1896
  </div>
1755
- ))
1897
+ );
1898
+ })
1756
1899
  )}
1757
1900
  </div>
1758
1901
  )}
@@ -1760,13 +1903,14 @@ export function AgentSidebar({
1760
1903
  )}
1761
1904
 
1762
1905
  {/* 3. 最近 (Recents) */}
1906
+ {(!isSearching || recentChatGroups.length > 0) && (
1763
1907
  <div className="mb-1.5">
1764
- <div className="group/section flex h-7 items-center justify-between rounded-agent-md px-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1908
+ <div className="group/section flex h-7 items-center justify-between rounded-full pl-2.5 pr-1.5 text-xs text-agent-muted-foreground transition-colors hover:bg-agent-foreground/5 hover:text-agent-foreground">
1765
1909
  <button
1766
1910
  type="button"
1767
1911
  aria-expanded={isRecentsExpanded}
1768
1912
  onClick={() => {
1769
- const next = !isRecentsExpanded;
1913
+ const next = !(recentsExpanded ?? true);
1770
1914
  setRecentsExpanded(next);
1771
1915
  writeSidebarSectionExpanded("recents", next);
1772
1916
  }}
@@ -1810,7 +1954,7 @@ export function AgentSidebar({
1810
1954
  ) : (
1811
1955
  recentChatGroups.map((group) => (
1812
1956
  <div key={group.label} className="mb-1">
1813
- <div className="px-2 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-wider text-agent-muted-foreground/80">
1957
+ <div className="px-2.5 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-wider text-agent-muted-foreground/80">
1814
1958
  {group.label}
1815
1959
  </div>
1816
1960
  <div className="space-y-0.5">
@@ -1822,19 +1966,18 @@ export function AgentSidebar({
1822
1966
  </div>
1823
1967
  )}
1824
1968
  </div>
1969
+ )}
1825
1970
  </>
1826
1971
  )}
1827
- {normalizedChats.length > 0 && (
1828
- <div className="px-2 py-2 text-center text-[11px] text-agent-muted-foreground">
1972
+ {normalizedChats.length > 0 && (isLoadingMoreChats || hasMoreChats) && (
1973
+ <div className="px-2.5 py-2 text-center text-[11px] text-agent-muted-foreground">
1829
1974
  {isLoadingMoreChats ? (
1830
1975
  <span className="inline-flex items-center gap-1">
1831
1976
  <LuLoaderCircle className="h-3 w-3 animate-spin" />
1832
1977
  {t("Loading more...")}
1833
1978
  </span>
1834
- ) : hasMoreChats ? (
1835
- t("Scroll down to load more")
1836
1979
  ) : (
1837
- t("Total chats: {count}", { count: normalizedChats.length })
1980
+ t("Scroll down to load more")
1838
1981
  )}
1839
1982
  </div>
1840
1983
  )}
@@ -82,6 +82,10 @@ interface ChatHeaderProps {
82
82
  rightPanel?: string | null;
83
83
  /** 已经打开且正在显示的标签。缺省时只把 rightPanel 当作唯一打开项。 */
84
84
  openPanelIds?: readonly string[];
85
+ /** 右侧整栏收起时,当前会话后台已就绪待预览的标签数。 */
86
+ hiddenPanelCount?: number;
87
+ /** 右侧整栏收起时待预览的激活标签标题。 */
88
+ hiddenPanelTitle?: string | null;
85
89
  /** 右侧整栏关着时,点标题栏开关把它打开。 */
86
90
  onOpenRightPanel?: () => void;
87
91
  /** 产品打开项目入口时,summary 展示当前对话关联的目录。 */
@@ -114,6 +118,8 @@ export function ChatHeader({
114
118
  chatSlots = [],
115
119
  rightPanel = null,
116
120
  openPanelIds,
121
+ hiddenPanelCount = 0,
122
+ hiddenPanelTitle = null,
117
123
  onOpenRightPanel,
118
124
  showProject = false,
119
125
  project = null,
@@ -450,7 +456,12 @@ export function ChatHeader({
450
456
  </button>
451
457
  )}
452
458
  {chat && canTogglePanel && openIds.length === 0 && (
453
- <PanelToggleButton pressed={false} onClick={() => onOpenRightPanel?.()} />
459
+ <PanelToggleButton
460
+ pressed={false}
461
+ hiddenTabCount={hiddenPanelCount}
462
+ hiddenActiveTitle={hiddenPanelTitle}
463
+ onClick={() => onOpenRightPanel?.()}
464
+ />
454
465
  )}
455
466
  {popoverNode}
456
467
  {chat && treeModalOpen && (
@@ -96,18 +96,44 @@ export function SidebarAccount() {
96
96
  : account.available === false
97
97
  ? t('Unavailable')
98
98
  : null;
99
+ const tooltip = [t('Account balance'), availableLabel, detail].filter(Boolean).join(' · ');
99
100
 
100
101
  return (
101
102
  <div
102
103
  data-testid="sidebar-account"
103
- className="mb-1.5 px-1 py-1"
104
+ className="mb-0.5 flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs text-agent-muted-foreground"
104
105
  aria-label={t('Account balance')}
105
106
  >
106
- <div className="flex items-center gap-1.5">
107
- <div className="flex min-w-0 flex-1 items-center gap-1.5 text-[11px] text-agent-foreground">
108
- <LuGauge className="h-3 w-3 shrink-0 text-agent-muted-foreground" />
109
- <span className="truncate font-medium">{account.label}</span>
110
- </div>
107
+ <LuGauge className="h-3.5 w-3.5 shrink-0 text-agent-muted-foreground" />
108
+ <span className="min-w-0 truncate">{account.label}</span>
109
+ {account.status === 'ready' && availableLabel ? (
110
+ <span
111
+ className={`h-1.5 w-1.5 shrink-0 rounded-full ${account.available ? 'bg-emerald-500' : 'bg-amber-500'}`}
112
+ title={availableLabel}
113
+ aria-label={availableLabel}
114
+ />
115
+ ) : null}
116
+ <div className="ml-auto flex min-w-0 items-center gap-1">
117
+ {account.status === 'ready' && account.total ? (
118
+ <span
119
+ data-testid="sidebar-account-total"
120
+ title={tooltip}
121
+ className={`shrink-0 font-medium tabular-nums ${
122
+ account.available === false
123
+ ? 'text-amber-600 dark:text-amber-400'
124
+ : 'text-agent-foreground'
125
+ }`}
126
+ >
127
+ {formatMoney(account.total, account.currency)}
128
+ </span>
129
+ ) : (
130
+ <span
131
+ className="truncate text-[11px] text-agent-muted-foreground"
132
+ title={t('Balance unavailable')}
133
+ >
134
+ {t('Balance unavailable')}
135
+ </span>
136
+ )}
111
137
  <button
112
138
  type="button"
113
139
  data-testid="sidebar-account-refresh"
@@ -115,7 +141,7 @@ export function SidebarAccount() {
115
141
  aria-label={t('Refresh balance')}
116
142
  disabled={refreshing}
117
143
  onClick={() => void load(true)}
118
- className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground/70 transition-colors hover:bg-agent-foreground/10 hover:text-agent-foreground disabled:opacity-50"
144
+ className="-mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground/70 transition-colors hover:bg-agent-foreground/10 hover:text-agent-foreground disabled:opacity-50"
119
145
  >
120
146
  {refreshing ? (
121
147
  <LuLoaderCircle className="h-3 w-3 animate-spin" />
@@ -124,40 +150,6 @@ export function SidebarAccount() {
124
150
  )}
125
151
  </button>
126
152
  </div>
127
- {account.status === 'ready' && account.total ? (
128
- <>
129
- <div className="mt-1.5 flex items-center justify-between gap-1.5 text-xs">
130
- <span className="shrink-0 text-agent-foreground" title={t('Account balance')}>
131
- {t('Balance')}
132
- </span>
133
- <div className="flex min-w-0 items-center justify-end gap-1">
134
- <span
135
- data-testid="sidebar-account-total"
136
- className="shrink-0 font-medium tabular-nums text-agent-foreground"
137
- >
138
- {formatMoney(account.total, account.currency)}
139
- </span>
140
- {availableLabel ? (
141
- <span
142
- className={`min-w-0 truncate text-[10px] ${account.available ? 'text-emerald-600' : 'text-amber-600'}`}
143
- >
144
- {availableLabel}
145
- </span>
146
- ) : null}
147
- </div>
148
- </div>
149
- {detail ? (
150
- <p
151
- className="mt-1 truncate text-[9px] leading-none text-agent-muted-foreground"
152
- title={detail}
153
- >
154
- {detail}
155
- </p>
156
- ) : null}
157
- </>
158
- ) : (
159
- <p className="mt-1 text-[10px] text-agent-muted-foreground">{t('Balance unavailable')}</p>
160
- )}
161
153
  </div>
162
154
  );
163
155
  }