Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
refactor(webui): remove session list previews and timestamps (#6189)
chengyongrucdb6210b45d4
diff --git a/nanobot/webui/sidebar_state.py b/nanobot/webui/sidebar_state.pyindex c28b95610..5248898ff 100644--- a/nanobot/webui/sidebar_state.py+++ b/nanobot/webui/sidebar_state.py@@ -50,8 +50,6 @@ def default_webui_sidebar_state() -> dict[str, Any]:"workbench": {"version": 1, "tabs": {}},"view": {"density": "comfortable",- "show_previews": False,- "show_timestamps": False,"show_archived": False,"sort": "updated_desc",},@@ -144,8 +142,6 @@ def _clean_view(value: Any) -> dict[str, Any]:sort = view.get("sort")return {"density": density if density in _ALLOWED_DENSITIES else default["density"],- "show_previews": bool(view.get("show_previews", default["show_previews"])),- "show_timestamps": bool(view.get("show_timestamps", default["show_timestamps"])),"show_archived": bool(view.get("show_archived", default["show_archived"])),"sort": sort if sort in _ALLOWED_SORTS else default["sort"],}diff --git a/tests/utils/test_webui_sidebar_state.py b/tests/utils/test_webui_sidebar_state.pyindex c61ff52a2..25b4b0a10 100644--- a/tests/utils/test_webui_sidebar_state.py+++ b/tests/utils/test_webui_sidebar_state.py@@ -52,7 +52,13 @@ def test_sidebar_state_normalizes_partial_payload(tmp_path, monkeypatch) -> None},},},- "view": {"density": "tiny", "show_archived": True, "sort": "nope"},+ "view": {+ "density": "tiny",+ "show_archived": True,+ "sort": "nope",+ "show_previews": True,+ "show_timestamps": True,+ },}),encoding="utf-8",@@ -83,8 +89,6 @@ def test_sidebar_state_normalizes_partial_payload(tmp_path, monkeypatch) -> None}assert state["view"] == {"density": "comfortable",- "show_previews": False,- "show_timestamps": False,"show_archived": True,"sort": "updated_desc",}@@ -100,7 +104,7 @@ def test_sidebar_state_write_is_scoped_to_config_data_dir(tmp_path, monkeypatch)"session_order": ["websocket:b", "websocket:a"],"title_overrides": {"websocket:a": "Release"},"project_name_overrides": {"/repo": "Core"},- "view": {"density": "compact", "show_previews": True, "sort": "manual"},+ "view": {"density": "compact", "sort": "manual"},})@@ -110,10 +114,9 @@ def test_sidebar_state_write_is_scoped_to_config_data_dir(tmp_path, monkeypatch)assert state["title_overrides"] == {"websocket:a": "Release"}assert state["project_name_overrides"] == {"/repo": "Core"}assert state["view"]["density"] == "compact"- assert state["view"]["show_previews"] is Trueassert state["view"]["sort"] == "manual"assert webui_sidebar_state_path().is_file()- assert read_webui_sidebar_state()["pinned_keys"] == ["websocket:a"]+ assert read_webui_sidebar_state() == statedef test_sidebar_state_persists_only_visible_workbench_groups(tmp_path, monkeypatch) -> None:diff --git a/webui/src/components/ChatList.tsx b/webui/src/components/ChatList.tsxindex 2aa499b51..843f28d08 100644--- a/webui/src/components/ChatList.tsx+++ b/webui/src/components/ChatList.tsx@@ -51,8 +51,6 @@ import {SIDEBAR_SELECTION_ITEM_CLASS,SidebarSelectionHighlight,} from "@/components/SidebarSelectionHighlight";-import { visibleSessionPreview } from "@/lib/format";-import { relativeTime } from "@/lib/format-time";import {COLLAPSED_CHATS_VISIBLE_COUNT,displayTitle,@@ -254,8 +252,6 @@ interface ChatListProps {updatedChatIds?: string[];recoveryChatIds?: string[];density?: SidebarDensity;- showPreviews?: boolean;- showTimestamps?: boolean;sort?: SidebarSortMode;showArchived?: boolean;defaultWorkspacePath?: string | null;@@ -297,8 +293,6 @@ export const ChatList = memo(function ChatList({updatedChatIds = [],recoveryChatIds = [],density = "comfortable",- showPreviews = false,- showTimestamps = false,sort = "updated_desc",showArchived = false,defaultWorkspacePath,@@ -767,7 +761,6 @@ export const ChatList = memo(function ChatList({: undefined}actionMenuPortalContainer={actionMenuPortalContainer}- updatedAt={showTimestamps ? group.updatedAt : null}/>) : (<ChatsGroupHeader label={group.label} />@@ -935,11 +928,6 @@ export const ChatList = memo(function ChatList({const isPinned = pinned.has(s.key);const isArchived = archived.has(s.key);- const preview = visibleSessionPreview(s.preview);- const showPreview = showPreviews && preview && preview !== title;- const timestamp = showTimestamps- ? relativeTime(s.updatedAt ?? s.createdAt)- : "";const activityState = running.has(s.chatId)? "running": recovery.has(s.chatId)@@ -1013,41 +1001,15 @@ export const ChatList = memo(function ChatList({partial={tabPartiallySelected}/>) : null}- <span className="min-w-0 flex-1 overflow-hidden">- {projectMode ? (- <span className="relative flex w-full min-w-0 items-center gap-2">- <SidebarSessionHandle handle={s.handle} />- <span className="min-w-0 flex-1 truncate font-normal leading-5">- {title}- </span>- {isPinned ? <PinnedChatIndicator /> : null}- {timestamp ? (- <span className="shrink-0 text-[11.5px] font-medium text-sidebar-muted-foreground">- {timestamp}- </span>- ) : null}-- </span>- ) : (- <span className="relative flex w-full min-w-0 items-center gap-1.5">- <SidebarSessionHandle handle={s.handle} />- <span className="min-w-0 flex-1 truncate font-normal leading-5">- {title}- </span>- {isPinned ? <PinnedChatIndicator /> : null}-- </span>- )}- {showPreview ? (- <span className="block w-full truncate text-[11.5px] leading-4 text-sidebar-muted-foreground">- {preview}- </span>- ) : null}- {timestamp && !projectMode ? (- <span className="block w-full truncate text-[11px] leading-4 text-sidebar-muted-foreground">- {timestamp}- </span>- ) : null}+ <span className={cn(+ "relative flex min-w-0 flex-1 items-center overflow-hidden",+ projectMode ? "gap-2" : "gap-1.5",+ )}>+ <SidebarSessionHandle handle={s.handle} />+ <span className="min-w-0 flex-1 truncate font-normal leading-5">+ {title}+ </span>+ {isPinned ? <PinnedChatIndicator /> : null}</span></button><SessionActivityIndicator state={activityState} />@@ -1710,7 +1672,6 @@ function ProjectGroupHeader({onRequestRename,onNewChat,actionMenuPortalContainer,- updatedAt,}: {active: boolean;label: string;@@ -1722,7 +1683,6 @@ function ProjectGroupHeader({onRequestRename?: () => void;onNewChat?: () => void;actionMenuPortalContainer?: HTMLElement | null;- updatedAt?: string | null;}) {const { t } = useTranslation();const projectButton = (@@ -1776,11 +1736,6 @@ function ProjectGroupHeader({{projectButton}</HoverHint>) : projectButton}- {updatedAt ? (- <span className="shrink-0 text-[11px] text-sidebar-muted-foreground">- {relativeTime(updatedAt)}- </span>- ) : null}{onRequestRename || onNewChat ? (<DropdownMenumodal={false}diff --git a/webui/src/components/Sidebar.tsx b/webui/src/components/Sidebar.tsxindex 53f8a8d12..c534747b2 100644--- a/webui/src/components/Sidebar.tsx+++ b/webui/src/components/Sidebar.tsx@@ -302,8 +302,6 @@ export function Sidebar(props: SidebarProps) {updatedChatIds={props.updatedChatIds}recoveryChatIds={props.recoveryChatIds}density={props.viewState?.density}- showPreviews={props.viewState?.show_previews}- showTimestamps={props.viewState?.show_timestamps}sort={props.viewState?.sort}showArchived={props.showArchived}defaultWorkspacePath={props.defaultWorkspacePath}diff --git a/webui/src/dev/gallery/standalone.tsx b/webui/src/dev/gallery/standalone.tsxindex 6f8ad5181..56847374b 100644--- a/webui/src/dev/gallery/standalone.tsx+++ b/webui/src/dev/gallery/standalone.tsx@@ -47,20 +47,22 @@ const initialSessions: ChatSummary[] = [createdAt: "2026-10-01T12:00:00Z", updatedAt: "2026-10-13T08:00:00Z", handle: { id: "gallery-components", name: "design" } },{ key: "websocket:gallery-tests", chatId: "gallery-tests", channel: "websocket", title: "验证交互", preview: "检查错误状态与键盘操作。",createdAt: "2026-10-02T12:00:00Z", updatedAt: "2026-10-13T09:00:00Z", handle: { id: "gallery-tests", name: "tests" } },+ { key: "websocket:gallery-history", chatId: "gallery-history", channel: "websocket", title: "历史方案", preview: "已归档的会话示例。",+ createdAt: "2026-10-01T10:00:00Z", updatedAt: "2026-10-05T10:00:00Z", handle: { id: "gallery-history", name: "history" } },];function ChatsPreview() {const [sessions, setSessions] = useState(initialSessions);const [active, setActive] = useState<string | null>(initialSessions[0].key);const [pinned, setPinned] = useState<string[]>([]);- const [archived, setArchived] = useState<string[]>([]);+ const [archived, setArchived] = useState<string[]>(["websocket:gallery-history"]);const [mode, setMode] = useState<"ready" | "loading" | "empty" | "archived">("ready");const [action, setAction] = useState("");const toggle = (keys: string[], key: string) => keys.includes(key) ? keys.filter((value) => value !== key) : [...keys, key];return <><StatePicker label="会话列表状态" value={mode} options={["ready", "loading", "empty", "archived"]} onChange={setMode} />- <div className="flex h-80 max-w-sm flex-col rounded-panel bg-sidebar p-2"><ChatList sessions={mode === "empty" ? [] : sessions}+ <div className="flex h-80 max-w-sm flex-col rounded-panel bg-sidebar p-2"><ChatList sessions={mode === "loading" || mode === "empty" ? [] : sessions}activeKey={active} onSelect={setActive} pinnedKeys={pinned} archivedKeys={archived} showArchived={mode === "archived"}- showPreviews showTimestamps loading={mode === "loading"}+ loading={mode === "loading"}onTogglePin={(key) => setPinned(toggle(pinned, key))} onToggleArchive={(key) => setArchived(toggle(archived, key))}onRequestDelete={(key) => setSessions((items) => items.filter((item) => item.key !== key))}onRequestRename={(_, label) => setAction(`选择重命名:${label}`)} /></div>diff --git a/webui/src/hooks/useSidebarState.ts b/webui/src/hooks/useSidebarState.tsindex c83d45845..e615d07d6 100644--- a/webui/src/hooks/useSidebarState.ts+++ b/webui/src/hooks/useSidebarState.ts@@ -17,8 +17,6 @@ const DEFAULT_SIDEBAR_STATE: SidebarStatePayload = {workbench: { version: 1, tabs: {} },view: {density: "comfortable",- show_previews: false,- show_timestamps: false,show_archived: false,sort: "updated_desc",},@@ -98,8 +96,6 @@ function normalizeSidebarState(raw: unknown): SidebarStatePayload {workbench: normalizeWorkbenchState(value.workbench),view: {density,- show_previews: Boolean(view.show_previews),- show_timestamps: Boolean(view.show_timestamps),show_archived: Boolean(view.show_archived),sort,},diff --git a/webui/src/lib/types.ts b/webui/src/lib/types.tsindex d68ba0986..e64c08262 100644--- a/webui/src/lib/types.ts+++ b/webui/src/lib/types.ts@@ -523,8 +523,6 @@ export interface WorkbenchState {export interface SidebarViewState {density: SidebarDensity;- show_previews: boolean;- show_timestamps: boolean;show_archived: boolean;sort: SidebarSortMode;}diff --git a/webui/src/tests/api.test.ts b/webui/src/tests/api.test.tsindex 1f0b71c39..fe9cb8ee2 100644--- a/webui/src/tests/api.test.ts+++ b/webui/src/tests/api.test.ts@@ -1185,8 +1185,6 @@ describe("webui API helpers", () => {collapsed_groups: {},view: {density: "compact" as const,- show_previews: false,- show_timestamps: false,show_archived: true,sort: "updated_desc" as const,},diff --git a/webui/src/tests/app-layout.test.tsx b/webui/src/tests/app-layout.test.tsxindex 084080b14..12d7d1087 100644--- a/webui/src/tests/app-layout.test.tsx+++ b/webui/src/tests/app-layout.test.tsx@@ -1855,8 +1855,7 @@ describe("App layout", () => {schema_version: 1, pinned_keys: [], archived_keys: [], session_order: [],title_overrides: { [key]: "推特大战场" }, project_name_overrides: {},tags_by_key: {}, collapsed_groups: {}, workbench: { version: 1, tabs: {} },- view: { density: "comfortable", show_previews: false, show_timestamps: false,- show_archived: false, sort: "updated_desc" },+ view: { density: "comfortable", show_archived: false, sort: "updated_desc" },};mockFetchRoutes({"/api/settings": baseSettingsPayload(),@@ -2591,8 +2590,6 @@ describe("App layout", () => {collapsed_groups: {},view: {density: "comfortable",- show_previews: false,- show_timestamps: false,show_archived: false,sort: "updated_desc",},@@ -2674,8 +2671,6 @@ describe("App layout", () => {collapsed_groups: {},view: {density: "comfortable",- show_previews: false,- show_timestamps: false,show_archived: false,sort: "title_asc",},diff --git a/webui/src/tests/chat-list.test.tsx b/webui/src/tests/chat-list.test.tsxindex 6573cb03c..58a4789eb 100644--- a/webui/src/tests/chat-list.test.tsx+++ b/webui/src/tests/chat-list.test.tsx@@ -946,16 +946,19 @@ describe("ChatList", () => {onTogglePin={vi.fn()}onRequestRename={vi.fn()}onToggleArchive={vi.fn()}- showPreviews/>,);const chatsSection = screen.getAllByRole("region")[0];- const text = chatsSection.textContent ?? "";+ const chats = within(chatsSection).getAllByRole("button", {+ name: /^(Newest|Middle|Older) chat$/,+ });- expect(text.indexOf("Newest chat")).toBeLessThan(text.indexOf("Middle chat"));- expect(text.indexOf("Middle chat")).toBeLessThan(text.indexOf("Older chat"));- expect(screen.queryByText("/model fast")).not.toBeInTheDocument();+ expect(chats.map((chat) => chat.textContent)).toEqual([+ "Newest chat",+ "Middle chat",+ "Older chat",+ ]);});it("shows a pin indicator for pinned chats", () => {@@ -1032,7 +1035,6 @@ describe("ChatList", () => {onRequestRename={vi.fn()}onToggleArchive={vi.fn()}sort="title_asc"- showTimestampsrunningChatIds={["zeta"]}/>,);@@ -1092,7 +1094,6 @@ describe("ChatList", () => {onRequestRename={vi.fn()}onToggleArchive={vi.fn()}defaultWorkspacePath="/Users/me/.nanobot/workspace"- showTimestamps/>,);@@ -1444,7 +1445,6 @@ describe("ChatList", () => {onTogglePin={vi.fn()}onRequestRename={vi.fn()}onToggleArchive={vi.fn()}- showTimestamps/>,);@@ -1500,7 +1500,6 @@ describe("ChatList", () => {onTogglePin={vi.fn()}onRequestRename={vi.fn()}onToggleArchive={vi.fn()}- showTimestamps/>,);@@ -1550,7 +1549,6 @@ describe("ChatList", () => {onTogglePin={vi.fn()}onRequestRename={vi.fn()}onToggleArchive={vi.fn()}- showTimestamps/>,);diff --git a/webui/src/tests/component-gallery.test.tsx b/webui/src/tests/component-gallery.test.tsxindex 9570118b4..c49a7630e 100644--- a/webui/src/tests/component-gallery.test.tsx+++ b/webui/src/tests/component-gallery.test.tsx@@ -125,6 +125,36 @@ it("submits a message through the actual composer using only local preview stateexpect(fetch.mock.calls[0][0]).toBe("/__nanobot_components");});+it("switches the chat list preview between ready, loading, empty and archived states", async () => {+ const source = "webui/src/components/SidebarSelectionHighlight.tsx";+ window.history.replaceState({}, "", `/gallery.html#${new URLSearchParams({ component: source })}`);+ vi.stubGlobal("fetch", vi.fn().mockResolvedValue({ ok: true, json: async () => inventory }));+ render(<Gallery />);+ await screen.findByRole("heading", { name: "ChatList · 会话列表" });+ const preview = within(screen.getByRole("region", { name: "Component preview" }));+ const setMode = async (mode: string) => {+ await userEvent.click(preview.getByRole("combobox", { name: "会话列表状态" }));+ await userEvent.click(screen.getByRole("option", { name: mode, exact: true }));+ };++ expect(preview.getByRole("button", { name: "@design 组件设计" })).toBeVisible();+ expect(preview.getByRole("button", { name: "@tests 验证交互" })).toBeVisible();+ expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(2);++ await setMode("loading");+ expect(preview.getByText("Loading…")).toBeVisible();+ await setMode("empty");+ expect(preview.getByText("No sessions yet.")).toBeVisible();+ await setMode("archived");+ const archived = within(preview.getByRole("region", { name: "Archived" }));+ expect(archived.getByRole("button", { name: "@history 历史方案" })).toBeVisible();+ expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(3);++ await setMode("ready");+ expect(preview.getByRole("button", { name: "@design 组件设计" })).toHaveAttribute("aria-current", "page");+ expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(2);+});+it("edits a pairing route without mounting a client or making a gateway mutation", async () => {const source = "webui/src/components/remote/PairRouteSettingsView.tsx";window.history.replaceState({}, "", `/gallery.html#${new URLSearchParams({ component: source })}`);diff --git a/webui/src/tests/nanobot-client.test.ts b/webui/src/tests/nanobot-client.test.tsindex 5883fa5c5..c6a254b74 100644--- a/webui/src/tests/nanobot-client.test.ts+++ b/webui/src/tests/nanobot-client.test.ts@@ -1328,8 +1328,6 @@ describe("NanobotClient", () => {workbench: { version: 1, tabs: {} },view: {density: "comfortable",- show_previews: false,- show_timestamps: false,show_archived: false,sort: "manual",},@@ -1392,8 +1390,6 @@ describe("NanobotClient", () => {},view: {density: "comfortable",- show_previews: false,- show_timestamps: false,show_archived: false,sort: "updated_desc",},