Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(web): group the conversation list by time, and show the Agent in the session details (#389)

Yaowei Zhenge860708d99d3
diff --git a/changelog/unreleased/2026-08-21-session-list-time-grouping.md b/changelog/unreleased/2026-08-21-session-list-time-grouping.md
new file mode 100644
index 00000000..b0663eab
--- /dev/null
+++ b/changelog/unreleased/2026-08-21-session-list-time-grouping.md
@@ -0,0 +1,18 @@
+# Time grouping for the conversation list, and the Agent in the session details
+
+- **Date:** 2026-08-21
+- **Type:** feature
+- **Scope:** `web`
+- **PR:** [#389](https://github.com/Prism-Shadow/penguin-harness/pull/389)
+
+[中文版](2026-08-21-session-list-time-grouping.zh.md)
+
+The chat sidebar's list options gained a third grouping mode next to Workspace and Agent: by time, which cuts the conversations into past day / past month / earlier on each conversation's last activity — the same stamp the rows' compact timestamps and the recency sort already read. Empty buckets are dropped, and the mode persists like the other two. The chat header's details card also gained an Agent row above the Model row.
+
+## Details
+
+- A time bucket spans every Agent and every Workspace, so the Subagents / Scheduled / Archived folders and the list's paging row moved below the buckets as one Project-wide set, with counts and fetch fan-out summed over all Agents. A bucket's own "More" only reveals further loaded rows.
+- Group collapse, conversation pins and the manual drag order work in time mode as in the others; the manual order is stored per Project and per grouping mode, so the new mode starts with its own.
+- The header's create button follows the grouping mode, and in time mode starts a new conversation.
+- The Trace page's tree keeps its Workspace / Agent toggle — its rows are Trace files with no activity timestamp — and reads a stored time preference as Workspace grouping.
+- `MoreRow` gained an optional accessible name for rows whose wording is not the shared "More".
diff --git a/changelog/unreleased/2026-08-21-session-list-time-grouping.zh.md b/changelog/unreleased/2026-08-21-session-list-time-grouping.zh.md
new file mode 100644
index 00000000..e3bca136
--- /dev/null
+++ b/changelog/unreleased/2026-08-21-session-list-time-grouping.zh.md
@@ -0,0 +1,18 @@
+# 会话列表的时间分组,以及会话详情中的 Agent
+
+- **Date:** 2026-08-21
+- **Type:** feature
+- **Scope:** `web`
+- **PR:** [#389](https://github.com/Prism-Shadow/penguin-harness/pull/389)
+
+[English](2026-08-21-session-list-time-grouping.md)
+
+会话侧边栏的列表选项在「按工作区分组」「按 Agent 分组」之外新增第三种分组方式:按时间分组,按每个会话的最近活动切分为近一天 / 近一月 / 更早——与行内简短时间戳、最近更新排序读取的是同一个时间戳。空的时间段不显示,该选择与另两种一样持久化。会话页右上角的详情卡片也在 Model 上方新增了 Agent 一行。
+
+## 细节
+
+- 一个时间段横跨全部 Agent 与全部工作区,因此子智能体 / 定时任务 / 已归档三个文件夹与列表的翻页行下移到时间段之下,合为项目级的一组,计数与拉取扇出按全部 Agent 汇总;时间段自身的「更多」只展开已加载的行。
+- 分组折叠、会话置顶与手动拖拽排序在时间分组下与其他分组一致;手动顺序按项目 + 分组方式分别存储,新分组从自己的顺序开始。
+- 头部的新建按钮跟随分组方式,时间分组下新建一个对话。
+- 轨迹观测页的目录树保留「工作区 / Agent」两种切换——它的行是没有活动时间戳的 Trace 文件——存储的时间分组偏好在该页按工作区分组读取。
+- `MoreRow` 新增可选的无障碍名称,供措辞不是共用「更多」的行使用。
diff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsx
index 0385dec7..534f3e11 100644
--- a/packages/web/src/components/layout/sidebar.tsx
+++ b/packages/web/src/components/layout/sidebar.tsx
@@ -3,14 +3,19 @@
* Project switcher -> new chat (default_agent draft) + page nav (Agents → Evaluation Center,
* one collapsible group behind a nav-row-wide chevron button under its last entry: arrow
* up = click to collapse, arrow down while collapsed = the way back; state persists in
- * localStorage, the pinned new-chat block never collapses) -> Session area with two grouping modes (a small toggle in the section header; the
+ * localStorage, the pinned new-chat block never collapses) -> Session area with three grouping
+ * modes (chosen in the section header's list options; the
* choice and each Project's group collapse and pin state persist in localStorage): by Workspace
* (the default; groups loaded Sessions by their
* Workspace path, temporary workspaces merged into one trailing group, header "+" starts a
- * draft in that Workspace) or by Agent (group header = Agent name + new chat + Agent settings;
- * shows all Agents, including empty groups). Groups can be pinned via the header's hover pin
- * toggle: pinned groups sort before unpinned within their mode, keeping each partition's own
- * order. Conversations can be pinned too (row context menu; persisted per Project in
+ * draft in that Workspace), by Agent (group header = Agent name + new chat + Agent settings;
+ * shows all Agents, including empty groups), or by time (last day / last month / earlier,
+ * bucketed on last activity; the buckets span every Agent, so the Subagents / Scheduled /
+ * Archived folders and the paging row sit below them as one Project-wide set). Groups can
+ * be pinned via the header's hover pin toggle: pinned groups sort before unpinned within
+ * their mode, keeping each partition's own order — the time buckets excepted, whose order
+ * IS the timeline and which therefore carry no pin. Conversations can be pinned too (row
+ * context menu; persisted per Project in
* localStorage): pinned rows bubble to the top of their group's active list. Each row's
* trailing slot shows the compact last-active time at rest and swaps to archive + delete
* icon buttons on hover/focus; the full set (pin, rename, archive, delete) opens as a
@@ -45,12 +50,15 @@ import {
FOLDER_CATEGORIES,
SIDEBAR_GROUP_PAGE_SIZE,
SIDEBAR_PAGE_SIZE,
+ TIME_FOLDERS_GROUP_KEY,
aggregateWorkspaceCounts,
+ groupSessionsByTime,
groupSessionsByWorkspace,
matchesSessionQuery,
partitionSessions,
pinnedFirst,
sessionCategory,
+ totalCategoryCounts,
workspaceGroupKey,
workspaceLabel,
} from "../../lib/session-grouping";
@@ -427,7 +435,7 @@ export function Sidebar({
const setGroupMode = (mode: GroupMode) => {
storeGroupMode(mode);
setGroupModeState(mode);
- // The two modes have unrelated group lists: restart the reveal window, and swap in
+ // The modes have unrelated group lists: restart the reveal window, and swap in
// this mode's own manual order (the stored sequence is read within partitions, whose
// boundaries are exactly what the mode decides — one shared array would scramble).
setSessionOrder(loadSessionOrder(currentProjectId, mode));
@@ -464,9 +472,13 @@ export function Sidebar({
[workspaceGroups, pinnedGroups],
);
- /** Group key of a Session under the current mode (collapse / archived-open state). */
+ /** Group key a Session's FOLDERS hang off under the current mode (the archived-open state); time mode keeps one shared set for the whole Project. */
const sessionGroupKey = (s: SessionInfo) =>
- groupMode === "agent" ? s.agentId : workspaceGroupKey(s.workspace);
+ groupMode === "agent"
+ ? s.agentId
+ : groupMode === "time"
+ ? TIME_FOLDERS_GROUP_KEY
+ : workspaceGroupKey(s.workspace);
const toggleGroup = (key: string) => {
// Inert while searching: groups render force-opened then, so a click would change
@@ -514,6 +526,34 @@ export function Sidebar({
const filterRows = (rows: SessionInfo[]) =>
searching ? rows.filter((s) => matchesSessionQuery(s, searchQuery)) : rows;
+ /**
+ * Time mode's split of the loaded rows: the buckets take the active conversations, the
+ * shared folders below take the rest. Deliberately NOT memoized — the bucket boundary is
+ * `Date.now()`, and a memo would freeze it at its last dependency change; the compact
+ * relative timestamps rendered beside these rows are recomputed every render for exactly
+ * the same reason. Null outside time mode, so no other mode pays for the two passes.
+ */
+ const timeParts = groupMode === "time" ? partitionSessions(filterRows(sessions)) : null;
+ const timeGroups = timeParts === null ? [] : groupSessionsByTime(timeParts.active, Date.now());
+
+ /** Time mode's exact server share, Project-wide: its buckets span every Agent, so the shared folders and the whole-list "More" read the summed counts. */
+ const projectCounts = totalCategoryCounts(countsByAgent);
+
+ /** Agents holding rows of a category anywhere in this Project — time mode's fetch fan-out (the counts are kept in step locally, so they cover freshly added rows too). */
+ const projectAgentsFor = (category: SessionCategory) =>
+ [...countsByAgent].filter(([, counts]) => counts[category] > 0).map(([agentId]) => agentId);
+
+ /** Agents with an unfetched active page left; the whole-list "More" of time mode pages all of them at once. */
+ const timeMoreAgents = projectAgentsFor("active").filter((id) => hasMoreFor(id, "active"));
+
+ /** A time bucket's rows as a group partition: the buckets carry active conversations only. */
+ const bucketPartition = (rows: SessionInfo[]): SessionPartition => ({
+ active: rows,
+ subagent: [],
+ schedule: [],
+ archived: [],
+ });
+
/** Close the search row and drop the filter (the toggle button, the clear ×, and Escape all land here). */
const closeSearch = () => {
setSearchOpen(false);
@@ -548,7 +588,9 @@ export function Sidebar({
shownDrafts.length > 0 ||
(groupMode === "agent"
? orderedAgents.some((a) => filterRows(byAgent.get(a.agentId) ?? []).length > 0)
- : orderedWorkspaceGroups.some((g) => filterRows(g.sessions).length > 0));
+ : groupMode === "time"
+ ? timeParts !== null && Object.values(timeParts).some((rows) => rows.length > 0)
+ : orderedWorkspaceGroups.some((g) => filterRows(g.sessions).length > 0));
/** In-flight key of one group's category "More" (folderKey shares the same composite for folder categories). */
const loadKey = (groupKey: string, category: SessionCategory) => `${category}\0${groupKey}`;
@@ -608,7 +650,12 @@ export function Sidebar({
const guard = `${groupMode}\0${activeSessionId}`;
if (lastAutoExpandedRef.current === guard) return;
lastAutoExpandedRef.current = guard;
- const groupKey = groupMode === "agent" ? s.agentId : workspaceGroupKey(s.workspace);
+ const groupKey =
+ groupMode === "agent"
+ ? s.agentId
+ : groupMode === "time"
+ ? TIME_FOLDERS_GROUP_KEY
+ : workspaceGroupKey(s.workspace);
const key = folderKey(groupKey, category);
setOpenFolders((prev) => (prev.has(key) ? prev : new Set(prev).add(key)));
// Same on-demand load a click-expand does, for this Session's own Agent (siblings of
@@ -740,9 +787,14 @@ export function Sidebar({
/** A Session always needs an Agent, so the workspace-mode "+" uses the current Agent, falling back to default_agent. */
const workspaceNewChatAgentId = currentAgent?.agentId ?? defaultAgentId;
- /** Header create-button tooltip (the created object follows the grouping mode). */
+ /** What the header's create button makes, and its tooltip (the created object follows the grouping mode). */
+ const newEntity = newEntityForGroupMode(groupMode);
const newEntityLabel =
- newEntityForGroupMode(groupMode) === "agent" ? S.agent.create : S.chat.newWorkspaceEntity;
+ newEntity === "agent"
+ ? S.agent.create
+ : newEntity === "chat"
+ ? S.chat.newSessionMenu
+ : S.chat.newWorkspaceEntity;
/** Persist-if-changed for every registry mutation (register / alias / unregister share the same-reference fast exit). */
const applyRegistryChange = (next: readonly WorkspaceEntry[]) => {
@@ -1072,6 +1124,27 @@ export function Sidebar({
/>
);
+ /**
+ * Time mode's one shared, Project-wide set of folders (rendered once below the buckets):
+ * their rows load only on first expand, so an unloaded Session has no known bucket and no
+ * bucket could honestly claim a share of them. Counts and fetch fan-out are summed over
+ * every Agent. A null entry means the Project holds no rows of that category at all —
+ * which is also what tells the empty-list line whether it is telling the truth.
+ */
+ const timeFolders =
+ timeParts === null
+ ? []
+ : FOLDER_CATEGORIES.map((category) =>
+ renderFolder(
+ TIME_FOLDERS_GROUP_KEY,
+ category,
+ timeParts,
+ true,
+ projectAgentsFor(category),
+ projectCounts,
+ ),
+ );
+
/** Page entries of the collapsible nav group (智能体 → 评估中心, driven by the NAV_GROUP_KEYS manifest). Always mounted — the collapse animates their height to zero and turns them inert. */
const navItems: Array<{ to: string; label: string; icon: string }> = NAV_GROUP_KEYS.map(
(key) => ({ to: `/${key}`, label: S.nav[key], icon: NAV_ICONS[key] }),
@@ -1365,6 +1438,15 @@ export function Sidebar({
setListSettingsOpen(false);
}}
/>
+ <MenuRadioRow
+ icon={GROUP_MODE_ICONS.time}
+ label={S.chat.groupByTime}
+ checked={groupMode === "time"}
+ onSelect={() => {
+ setGroupMode("time");
+ setListSettingsOpen(false);
+ }}
+ />
<div className="my-1 border-t border-gray-100 dark:border-gray-800" />
<p className={menuSectionClass}>{S.chat.sortModeSection}</p>
{/* Manual order is offered only where a drag can actually happen (see canDrag). */}
@@ -1394,8 +1476,10 @@ export function Sidebar({
agent grouping opens the Agents page's existing create dialog (route
state); workspace grouping opens the SAME directory-browse menu the
draft's workspace picker uses — the picked directory registers as a
- workspace group immediately, Sessions or not. */}
- {newEntityForGroupMode(groupMode) === "agent" ? (
+ workspace group immediately, Sessions or not. Time buckets are not
+ something to create into, so that mode starts a plain new conversation
+ and wears the compose glyph without a plus badge. */}
+ {newEntity === "agent" ? (
<button
type="button"
title={newEntityLabel}
@@ -1408,6 +1492,16 @@ export function Sidebar({
>
<AddBadgeIcon base={NAV_ICONS.agents} />
</button>
+ ) : newEntity === "chat" ? (
+ <button
+ type="button"
+ title={newEntityLabel}
+ aria-label={newEntityLabel}
+ onClick={() => newChat()}
+ className={headerControlClass(false)}
+ >
+ <Icon d={NEW_CHAT_ICON} size={ICON_SIZE.iconButton} />
+ </button>
) : (
<WorkspaceSelect
// Remount per Project: the picker browses lazily and caches the listing
@@ -1539,7 +1633,7 @@ export function Sidebar({
{groupMode === "agent" && !searching && orderedAgents.length > groupCap
? moreGroupsRow(orderedAgents.length)
: null}
- {groupMode === "agent" ? null : loading && sessions.length === 0 ? (
+ {groupMode !== "workspace" ? null : loading && sessions.length === 0 ? (
<SkeletonList rows={5} />
) : orderedWorkspaceGroups.length === 0 && !searching ? (
<p className="px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600">
@@ -1629,6 +1723,74 @@ export function Sidebar({
? moreGroupsRow(orderedWorkspaceGroups.length)
: null}
+ {/* Time mode: last day / last month / earlier, bucketed on each conversation's last
+ activity — the same stamp the rows' compact timestamps and the recency sort read,
+ so a row can never sit under a bucket its own timestamp contradicts. Empty buckets
+ are dropped, and there are at most three, so this mode has no "more groups" row.
+ The buckets span every Agent and every Workspace: a bucket's "More" only reveals
+ further loaded rows, while fetching the next page and reaching the Subagents /
+ Scheduled / Archived rows happen once for the whole Project, below. */}
+ {groupMode !== "time" || timeParts === null ? null : loading && sessions.length === 0 ? (
+ <SkeletonList rows={5} />
+ ) : (
+ <>
+ {timeGroups.map((group) => {
+ const collapsed = !searching && collapsedGroups.has(group.key);
+ return (
+ <div key={group.key} className="pt-2.5">
+ <GroupHeader
+ open={!collapsed}
+ onToggle={() => toggleGroup(group.key)}
+ icon={
+ <span className="shrink-0 text-gray-400 dark:text-gray-500">
+ <Icon d={GROUP_MODE_ICONS.time} size={ICON_SIZE.groupHeaderGlyph} />
+ </span>
+ }
+ label={S.chat.timeGroups[group.bucket]}
+ uppercase
+ count={group.sessions.length}
+ />
+ {collapsed
+ ? null
+ : renderGroupBody(
+ group.key,
+ bucketPartition(group.sessions),
+ true,
+ undefined,
+ () => [],
+ )}
+ </div>
+ );
+ })}
+
+ {/* Empty only when the shared folders below are empty too (renderGroupBody's own
+ rule): "no Sessions yet" over an "Archived (3)" row would contradict it. */}
+ {timeGroups.length === 0 && !searching && timeFolders.every((f) => f === null) && (
+ <p className="px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600">
+ {S.chat.noSessions}
+ </p>
+ )}
+
+ {/* Whole-list paging: a fetched page lands in whichever bucket its rows' activity
+ puts them, so the row that pulls one belongs to the list, not to a bucket —
+ and its label says "conversations" where a bucket's says "more". */}
+ {!searching &&
+ timeParts.active.length < projectCounts.active &&
+ timeMoreAgents.length > 0 && (
+ <MoreRow
+ label={S.chat.loadMoreSessions}
+ ariaLabel={S.chat.loadMoreSessions}
+ pending={pendingLoads.has(loadKey(TIME_FOLDERS_GROUP_KEY, "active"))}
+ onClick={() => trackedLoadMore(TIME_FOLDERS_GROUP_KEY, "active", timeMoreAgents)}
+ className="mt-1"
+ />
+ )}
+
+ {/* The shared, Project-wide folders (see timeFolders). */}
+ <div className="pt-2.5">{timeFolders}</div>
+ </>
+ )}
+
{/* Quiet no-match line: the search is live and nothing — drafts included — hit. */}
{searching && !hasSearchMatches && (
<p className="px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600">
diff --git a/packages/web/src/components/ui/group-list.tsx b/packages/web/src/components/ui/group-list.tsx
index 183670d3..36f2e0b0 100644
--- a/packages/web/src/components/ui/group-list.tsx
+++ b/packages/web/src/components/ui/group-list.tsx
@@ -33,11 +33,32 @@ export const AGENT_GROUP_ICON =
/** Clock (lucide clock, drawn as one path), the "most recent" sort option. */
export const CLOCK_ICON = "M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0M12 6v6l4 2";
+/**
+ * Calendar (lucide calendar), the "by time" grouping option. Deliberately not the clock:
+ * that glyph already names the recency SORT one section below in the same menu, and two
+ * rows wearing one mark would read as one setting.
+ */
+export const CALENDAR_ICON =
+ "M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z";
+
/** Opposed up/down arrows (lucide arrow-up-down), the drag-reordered "manual order" sort option. */
export const REORDER_ICON = "m21 16-4 4-4-4M17 20V4M3 8l4-4 4 4M7 4v16";
/** Grouping mode of a Session list (persisted; Workspace is the default). */
-export type GroupMode = "workspace" | "agent";
+export type GroupMode = "workspace" | "agent" | "time";
+
+/**
+ * The grouping modes a Trace-file tree can offer. Its rows are trace files keyed by
+ * Session id and carry no activity timestamp, so there is nothing to cut time buckets
+ * on; a stored "time" preference reads there as the Workspace grouping it falls back to
+ * (treeGroupMode), and its two-icon toggle offers exactly these two.
+ */
+export type TreeGroupMode = "workspace" | "agent";
+
+/** The nearest mode a Trace-file tree supports (see TreeGroupMode). */
+export function treeGroupMode(mode: GroupMode): TreeGroupMode {
+ return mode === "agent" ? "agent" : "workspace";
+}
/**
* Leading glyph per grouping mode — the one place these are chosen, read by both the
@@ -48,6 +69,7 @@ export type GroupMode = "workspace" | "agent";
export const GROUP_MODE_ICONS: Record<GroupMode, string> = {
workspace: FOLDER_ICON,
agent: AGENT_GROUP_ICON,
+ time: CALENDAR_ICON,
};
/**
@@ -68,7 +90,8 @@ export const SORT_MODE_ICONS: Record<SessionSortMode, string> = {
const GROUP_MODE_KEY = "penguin.sidebarGroupMode";
export function initialGroupMode(): GroupMode {
- return localStorage.getItem(GROUP_MODE_KEY) === "agent" ? "agent" : "workspace";
+ const stored = localStorage.getItem(GROUP_MODE_KEY);
+ return stored === "agent" || stored === "time" ? stored : "workspace";
}
/**
@@ -77,22 +100,25 @@ export function initialGroupMode(): GroupMode {
* Agents page's existing create dialog), workspace mode → a Workspace (a new-chat
* draft — there is no Workspace entity on the server; a Workspace comes into being
* with the conversation created in it, chosen or auto-created on the draft card).
+ * Time mode groups into buckets nothing can be created in, so its button falls back to
+ * the plain new conversation — the one object every mode's list is made of.
*/
-export function newEntityForGroupMode(mode: GroupMode): "agent" | "workspace" {
- return mode === "agent" ? "agent" : "workspace";
+export function newEntityForGroupMode(mode: GroupMode): "agent" | "workspace" | "chat" {
+ if (mode === "agent") return "agent";
+ return mode === "time" ? "chat" : "workspace";
}
export function storeGroupMode(mode: GroupMode): void {
localStorage.setItem(GROUP_MODE_KEY, mode);
}
-/** The two-icon Workspace/Agent grouping toggle (the section header's mode switch). */
+/** The two-icon Workspace/Agent grouping toggle (the Trace tree's mode switch — see TreeGroupMode). */
export function GroupModeToggle({
value,
onChange,
}: {
- value: GroupMode;
- onChange: (mode: GroupMode) => void;
+ value: TreeGroupMode;
+ onChange: (mode: TreeGroupMode) => void;
}) {
return (
<div className="flex items-center gap-0.5">
@@ -133,11 +159,18 @@ export const FOLDER_ROW_CLASS =
*/
export function MoreRow({
label,
+ ariaLabel,
pending = false,
onClick,
className,
}: {
label: string;
+ /**
+ * Accessible name, when the row's own wording is not the shared "More" — a name that
+ * contradicted the visible text would announce a different row than the one on screen.
+ * Defaults to the shared label, which is what the count-carrying rows announce.
+ */
+ ariaLabel?: string;
/** A fetch is in flight: disable and show the loading label. */
pending?: boolean;
onClick: () => void;
@@ -147,7 +180,7 @@ export function MoreRow({
return (
<button
type="button"
- aria-label={S.chat.loadMore}
+ aria-label={ariaLabel ?? S.chat.loadMore}
disabled={pending}
onClick={onClick}
className={`${FOLDER_ROW_CLASS}${className ? ` ${className}` : ""} disabled:opacity-60`}
diff --git a/packages/web/src/features/chat/chat-page.tsx b/packages/web/src/features/chat/chat-page.tsx
index faf3716b..eb601d48 100644
--- a/packages/web/src/features/chat/chat-page.tsx
+++ b/packages/web/src/features/chat/chat-page.tsx
@@ -67,7 +67,7 @@ import { bucketCostUsd, liveSessionElapsedMs } from "../../lib/omni/task-stats";
import type { TaskStatsTracker } from "../../lib/omni/task-stats";
import { useAuth } from "../../state/auth";
import { useTheme } from "../../state/theme";
-import { useProject } from "../../state/project";
+import { agentDisplayName, useProject } from "../../state/project";
import { useSessions } from "../../state/sessions";
import { Modal } from "../../components/ui/modal";
import { ConfirmModal } from "../../components/ui/confirm-modal";
@@ -1600,6 +1600,12 @@ export function ChatPage() {
usageBuckets && recordedInput > 0
? `${Math.round((100 * usageBuckets.cacheRead) / recordedInput)}%`
: null;
+ // Display name of the Session's own Agent for the details card — null when the Agent has
+ // no name of its own (agentDisplayName then returns the id, which the row already shows)
+ // or when the Agent list hasn't arrived yet.
+ const sessionAgent = agents.find((a) => a.agentId === selected?.agentId);
+ const sessionAgentName =
+ sessionAgent && sessionAgent.name !== undefined ? agentDisplayName(sessionAgent) : null;
const modelInfo = models?.models.find((m) => sameModelRef(m, activeModelRef));
const contextWindow = modelInfo?.contextWindow;
// Assumed supported by default: only models explicitly marked vision=false show a blocking hint when adding images.
@@ -1813,6 +1819,23 @@ export function ChatPage() {
}
>
<div className="space-y-3 px-3.5 py-2.5 text-sm">
+ {/* Agent, above the Model: a conversation belongs to an Agent first, and the
+ Model it runs on is one of that Agent's settings. Paired the same way as the
+ Model row — the id the API speaks, then the display name, which is dropped
+ when the Agent has none of its own and the two would simply repeat. */}
+ <div>
+ <p className="text-xs font-medium text-gray-500 dark:text-gray-400">
+ {S.chat.agent}
+ </p>
+ <p className="truncate text-xs">
+ <span className="font-mono">{selected.agentId}</span>
+ {sessionAgentName !== null && (
+ <span className="ml-1.5 text-gray-400 dark:text-gray-500">
+ {sessionAgentName}
+ </span>
+ )}
+ </p>
+ </div>
<div>
<p className="text-xs font-medium text-gray-500 dark:text-gray-400">
{S.chat.model}
diff --git a/packages/web/src/features/traces/traces-page.tsx b/packages/web/src/features/traces/traces-page.tsx
index 70b30fe4..6a977215 100644
--- a/packages/web/src/features/traces/traces-page.tsx
+++ b/packages/web/src/features/traces/traces-page.tsx
@@ -40,8 +40,9 @@ import {
MoreRow,
initialGroupMode,
storeGroupMode,
+ treeGroupMode,
} from "../../components/ui/group-list";
-import type { GroupMode } from "../../components/ui/group-list";
+import type { TreeGroupMode } from "../../components/ui/group-list";
import { HiddenFileInput } from "../../components/ui/hidden-file-input";
import { DownloadIcon, UploadIcon } from "../../components/ui/icons";
import { Modal } from "../../components/ui/modal";
@@ -107,9 +108,12 @@ export function TracesPage() {
// runs): auto-selects once the target Agent's Session list is ready.
const focusSessionId = searchParams.get("sessionId");
// Grouping mode: the same persisted preference as the chat sidebar
- // (penguin.sidebarGroupMode) so the two surfaces always group alike.
- const [modePref, setModePref] = useState<GroupMode>(initialGroupMode);
- const groupMode: GroupMode = focusAgentId !== null ? "agent" : modePref;
+ // (penguin.sidebarGroupMode) so the two surfaces always group alike, narrowed to the
+ // two this tree can offer — its rows are Trace files keyed by Session id and carry no
+ // activity timestamp, so the sidebar's time buckets have nothing here to cut on and
+ // read as the Workspace grouping they fall back to (treeGroupMode).
+ const [modePref, setModePref] = useState<TreeGroupMode>(() => treeGroupMode(initialGroupMode()));
+ const groupMode: TreeGroupMode = focusAgentId !== null ? "agent" : modePref;
const [selection, setSelection] = useState<Selection | null>(null);
const [fileIndex, setFileIndex] = useState<number | null>(null);
/** Rendered groups cap (the sidebar's group paging pattern: raised a page per "more groups" click; reset per Project and on a mode switch). */
@@ -140,7 +144,7 @@ export function TracesPage() {
/** Session to auto-select once the refreshed list arrives (the import response's sessionId). */
const importedSession = useRef<{ agentId: string; sessionId: string } | null>(null);
- const setGroupMode = (mode: GroupMode) => {
+ const setGroupMode = (mode: TreeGroupMode) => {
storeGroupMode(mode);
setModePref(mode);
// The two modes have unrelated group lists: restart the reveal window.
diff --git a/packages/web/src/lib/session-grouping.ts b/packages/web/src/lib/session-grouping.ts
index ab1aa365..76ad2524 100644
--- a/packages/web/src/lib/session-grouping.ts
+++ b/packages/web/src/lib/session-grouping.ts
@@ -1,5 +1,6 @@
/**
- * Pure grouping logic for the chat sidebar's "by Workspace" mode.
+ * Pure grouping logic for the chat sidebar's Session groups — the "by Workspace" mode
+ * (below), and the time buckets of the "by time" mode (TIME_BUCKETS, near the bottom).
*
* There is no Workspace entity on the server: a Session only carries the plain
* filesystem path locked in at creation (SessionInfo.workspace), so grouping works
@@ -237,6 +238,91 @@ export function groupSessionsByWorkspace<T extends { workspace: string; createdA
return groups;
}
+/**
+ * The sidebar's time buckets, in render order: last day, last month, everything older.
+ * Bucketing is on `lastActiveAt` — the same key the recency sort and each row's compact
+ * timestamp already use, so a row labelled "3m ago" can never sit under "Earlier".
+ */
+export const TIME_BUCKETS = ["day", "month", "earlier"] as const;
+export type TimeBucket = (typeof TIME_BUCKETS)[number];
+
+const DAY_MS = 24 * 60 * 60 * 1000;
+/** "Last month" is a rolling 30-day window, not a calendar month — the boundary a user reads off a relative timestamp. */
+const MONTH_MS = 30 * DAY_MS;
+
+/** Group key of a time bucket (collapse state / React key); "\0" can never appear in a Workspace path or an Agent id, so these never collide with the other modes' keys. */
+export const timeGroupKey = (bucket: TimeBucket): string => `\0time-${bucket}`;
+
+/**
+ * Group key the folders (Subagents / Scheduled / Archived) hang off in time mode. They are
+ * NOT bucketed: their rows load only when a folder is first expanded, so an unloaded
+ * Session's bucket is unknown and no bucket could honestly advertise a share of them. One
+ * shared, Project-wide set below the buckets is what the sidebar renders instead.
+ */
+export const TIME_FOLDERS_GROUP_KEY = "\0time-folders";
+
+/** The bucket an activity timestamp falls in, against `nowMs`. An unparseable stamp counts as the oldest bucket rather than jumping to the top. */
+export function timeBucketOf(lastActiveAt: string, nowMs: number): TimeBucket {
+ const t = Date.parse(lastActiveAt);
+ if (!Number.isFinite(t)) return "earlier";
+ const age = nowMs - t;
+ if (age < DAY_MS) return "day";
+ return age < MONTH_MS ? "month" : "earlier";
+}
+
+export interface TimeGroup<T = SessionInfo> {
+ /** Stable group key (timeGroupKey of the bucket). */
+ key: string;
+ bucket: TimeBucket;
+ /** Member Sessions, newest activity first. */
+ sessions: T[];
+}
+
+/**
+ * Buckets Sessions by their last activity into the three time groups, in TIME_BUCKETS
+ * order. Empty buckets are dropped — a "Last day" header over nothing states an absence
+ * the list is not asked to report. Members are sorted by `lastActiveAt` desc (the flat
+ * store list concatenates per-Agent responses, so its order isn't globally chronological);
+ * the sidebar re-orders them again for pins and manual sort.
+ */
+export function groupSessionsByTime<T extends { lastActiveAt: string }>(
+ sessions: readonly T[],
+ nowMs: number,
+): TimeGroup<T>[] {
+ const byBucket = new Map<TimeBucket, T[]>();
+ for (const s of sessions) {
+ const bucket = timeBucketOf(s.lastActiveAt, nowMs);
+ const list = byBucket.get(bucket);
+ if (list) list.push(s);
+ else byBucket.set(bucket, [s]);
+ }
+ const groups: TimeGroup<T>[] = [];
+ for (const bucket of TIME_BUCKETS) {
+ const rows = byBucket.get(bucket);
+ if (rows === undefined) continue;
+ rows.sort((a, b) =>
+ a.lastActiveAt < b.lastActiveAt ? 1 : a.lastActiveAt > b.lastActiveAt ? -1 : 0,
+ );
+ groups.push({ key: timeGroupKey(bucket), bucket, sessions: rows });
+ }
+ return groups;
+}
+
+/** Sums per-Agent category totals into one Project-wide set (time mode's shared folders and its whole-list "More" read their share from it). */
+export function totalCategoryCounts(
+ byAgent: ReadonlyMap<string, SessionCategoryCounts>,
+): SessionCategoryCounts {
+ const totals: SessionCategoryCounts = { active: 0, subagent: 0, schedule: 0, archived: 0 };
+ for (const counts of byAgent.values()) {
+ for (const category of ALL_CATEGORIES) {
+ const n = counts[category];
+ // Same guard as aggregateWorkspaceCounts: a missing key must not poison the sum with NaN.
+ if (n > 0) totals[category] += n;
+ }
+ }
+ return totals;
+}
+
/**
* Stable pinned-first partition for sidebar groups: items whose key is in `pinned`
* come first, each partition preserving the input order (recency for Workspace
diff --git a/packages/web/src/lib/session-order.ts b/packages/web/src/lib/session-order.ts
index 3699e98b..4ae3b791 100644
--- a/packages/web/src/lib/session-order.ts
+++ b/packages/web/src/lib/session-order.ts
@@ -65,9 +65,9 @@ export function storeSessionSortMode(mode: SessionSortMode, storage?: SessionOrd
/**
* Storage key of one Project's manual order (sidebar key-naming convention,
* `penguin.pinnedSessions.<projectId>` &c.), scoped BY GROUPING MODE: the stored
- * sequence is only ever read within a partition, and the two modes cut the same
- * Sessions into different partitions — one shared array would let a drag in workspace
- * mode scramble the agent-mode order (and vice versa).
+ * sequence is only ever read within a partition, and the modes cut the same Sessions
+ * into different partitions — one shared array would let a drag in one mode scramble
+ * another mode's order.
*/
export const sessionOrderKey = (projectId: string, mode: GroupMode): string =>
`penguin.sessionOrder.${projectId}.${mode}`;
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index e7d79d56..34960ba7 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -1110,6 +1110,13 @@ export const en: Strings = {
/** Sidebar conversation-list grouping toggle (workspace is the default) + workspace groups. */
groupByWorkspace: "Group by workspace",
groupByAgent: "Group by agent",
+ groupByTime: "Group by time",
+ /** Time-mode bucket names (last day / last month / older), by last activity. */
+ timeGroups: {
+ day: "Past day",
+ month: "Past month",
+ earlier: "Earlier",
+ },
/** Session-list section header controls: search / list settings / mode-dependent create (the created object follows the grouping mode). */
searchSessions: "Search chats",
searchSessionsPlaceholder: "Search chats…",
@@ -1253,6 +1260,7 @@ Scenarios:
},
sessionList: "Sessions",
defaultSessionTitle: "New chat",
+ agent: "Agent",
model: "Model",
workspace: "Workspace",
workspaceHint:
@@ -1539,6 +1547,8 @@ Scenarios:
pinnedSession: "Pinned",
/** Sidebar group "reveal/load next page" row (display cap + server paging). */
loadMore: "More",
+ /** Time mode's whole-list paging row: its buckets span every Agent, so one row below them fetches the next page rather than each bucket claiming to. */
+ loadMoreSessions: "Load more chats",
/** Collapsed sidebar folders inside a group (lazy-loaded); the count is the group's exact server share. */
folderGroups: {
subagent: (n: number) => `Subagents (${n})`,
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 6df56578..49a1f096 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -1066,6 +1066,13 @@ export const zh = {
/** Grouping toggle of the sidebar conversation list (workspace grouping is the default) and the workspace groups. */
groupByWorkspace: "按工作区分组",
groupByAgent: "按 Agent 分组",
+ groupByTime: "按时间分组",
+ /** Time-mode bucket names (last day / last month / older), by last activity. */
+ timeGroups: {
+ day: "近一天",
+ month: "近一月",
+ earlier: "更早",
+ },
/** Session-list section header controls: search / list settings / mode-dependent create (具体新建的对象按分组方式决定). */
searchSessions: "搜索会话",
searchSessionsPlaceholder: "搜索会话…",
@@ -1210,6 +1217,7 @@ Benchmark:
},
sessionList: "Session",
defaultSessionTitle: "新对话",
+ agent: "Agent",
model: "Model",
workspace: "Workspace",
workspaceHint: "留空自动创建临时工作区;指定时必须是服务器上已存在的目录",
@@ -1491,6 +1499,8 @@ Benchmark:
pinnedSession: "已置顶",
/** Sidebar group "reveal/load next page" row (display cap + server paging). */
loadMore: "更多",
+ /** Time mode's whole-list paging row: its buckets span every Agent, so one row below them fetches the next page rather than each bucket claiming to. */
+ loadMoreSessions: "加载更多会话",
/** Collapsed sidebar folders inside a group (lazy-loaded); the count is the group's exact server share. */
folderGroups: {
subagent: (n: number) => `子智能体(${n})`,
diff --git a/packages/web/test/group-list.test.ts b/packages/web/test/group-list.test.ts
index 7ea2879b..34aee36b 100644
--- a/packages/web/test/group-list.test.ts
+++ b/packages/web/test/group-list.test.ts
@@ -4,7 +4,8 @@
* Agent grouping creates an Agent (the Agents page's existing create dialog, reached
* via route state); workspace grouping creates a Workspace (a new-chat draft — there
* is no standalone Workspace entity, one comes into being with the conversation
- * created in it).
+ * created in it); time grouping buckets by last activity, which nothing can be created
+ * into, so it falls back to the conversation itself.
*
* Plus the list-options menu's glyphs. The icons are decorative — every row keeps its
* own text label — but they are only worth drawing if they tell the options apart, so
@@ -18,6 +19,7 @@ import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import {
AGENT_GROUP_ICON,
+ CALENDAR_ICON,
CLOCK_ICON,
FOLDER_ICON,
GROUP_MODE_ICONS,
@@ -35,12 +37,20 @@ describe("newEntityForGroupMode", () => {
expect(newEntityForGroupMode("agent")).toBe("agent");
expect(newEntityForGroupMode("workspace")).toBe("workspace");
});
+
+ it("time grouping has no entity of its own, so it creates a conversation", () => {
+ expect(newEntityForGroupMode("time")).toBe("chat");
+ });
});
describe("list-options glyphs", () => {
it("names each grouping mode by what the list is grouped into", () => {
// The same glyphs the header's grouping toggle shows, so the two surfaces agree.
- expect(GROUP_MODE_ICONS).toEqual({ workspace: FOLDER_ICON, agent: AGENT_GROUP_ICON });
+ expect(GROUP_MODE_ICONS).toEqual({
+ workspace: FOLDER_ICON,
+ agent: AGENT_GROUP_ICON,
+ time: CALENDAR_ICON,
+ });
});
it("names each sort mode by what decides the order: a clock, and the reorder arrows", () => {
@@ -54,7 +64,7 @@ describe("list-options glyphs", () => {
const read = (p: string) =>
readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), p), "utf8");
const sidebar = read("../src/components/layout/sidebar.tsx");
- for (const mode of ["workspace", "agent"] satisfies GroupMode[])
+ for (const mode of ["workspace", "agent", "time"] satisfies GroupMode[])
expect(sidebar).toContain(`icon={GROUP_MODE_ICONS.${mode}}`);
for (const mode of ["recent", "manual"] satisfies SessionSortMode[])
expect(sidebar).toContain(`icon={SORT_MODE_ICONS.${mode}}`);
@@ -62,7 +72,9 @@ describe("list-options glyphs", () => {
expect(read("../src/components/ui/group-list.tsx")).toContain("GROUP_MODE_ICONS.workspace");
});
- it("gives all four rows glyphs that differ, so an icon distinguishes rather than decorates", () => {
+ it("gives every row a glyph that differs, so an icon distinguishes rather than decorates", () => {
+ // The calendar of "group by time" against the clock of "sort by recency" in particular:
+ // two rows of one menu wearing one mark would read as one setting.
const icons = [...Object.values(GROUP_MODE_ICONS), ...Object.values(SORT_MODE_ICONS)];
expect(icons.every((d) => d.length > 0)).toBe(true);
expect(new Set(icons).size).toBe(icons.length);
@@ -72,6 +84,9 @@ describe("list-options glyphs", () => {
for (const dict of [zh, en]) {
expect(dict.chat.groupByWorkspace).toBeTruthy();
expect(dict.chat.groupByAgent).toBeTruthy();
+ expect(dict.chat.groupByTime).toBeTruthy();
+ for (const bucket of ["day", "month", "earlier"] as const)
+ expect(dict.chat.timeGroups[bucket]).toBeTruthy();
expect(dict.chat.sortRecent).toBeTruthy();
expect(dict.chat.sortManual).toBeTruthy();
}
diff --git a/packages/web/test/session-grouping.test.ts b/packages/web/test/session-grouping.test.ts
index abd4d404..89d438b8 100644
--- a/packages/web/test/session-grouping.test.ts
+++ b/packages/web/test/session-grouping.test.ts
@@ -1,5 +1,7 @@
/**
- * Workspace grouping for the chat sidebar (pure logic):
+ * Workspace grouping and the time buckets for the chat sidebar (pure logic).
+ *
+ * Workspace grouping:
* - named Workspaces group by exact path, labeled by basename (full path kept for
* tooltips), newest group first;
* - temporary Workspaces (`<agentDir>/workspaces/tmp-<8hex>`, the shape produced by
@@ -13,8 +15,11 @@ import type { SessionCategoryCounts, SessionInfo } from "@prismshadow/penguin-se
import {
SIDEBAR_PAGE_SIZE,
TEMP_WORKSPACE_GROUP_KEY,
+ TIME_BUCKETS,
+ TIME_FOLDERS_GROUP_KEY,
aggregateWorkspaceCounts,
matchesSessionQuery,
+ groupSessionsByTime,
groupSessionsByWorkspace,
isTempWorkspace,
latestConversation,
@@ -22,6 +27,9 @@ import {
pinnedFirst,
sessionCategory,
splitPage,
+ timeBucketOf,
+ timeGroupKey,
+ totalCategoryCounts,
workspaceGroupKey,
workspaceLabel,
} from "../src/lib/session-grouping";
@@ -35,6 +43,7 @@ function session(
agentId?: string;
archived?: boolean;
source?: "schedule" | "subagent";
+ lastActiveAt?: string;
} = {},
): SessionInfo {
seq += 1;
@@ -47,7 +56,7 @@ function session(
workspace,
approvalMode: "allow-all",
createdAt,
- lastActiveAt: createdAt,
+ lastActiveAt: over.lastActiveAt ?? createdAt,
status: "idle",
pendingApprovalCount: 0,
pendingFollowUpCount: 0,
@@ -375,3 +384,102 @@ describe("matchesSessionQuery (sidebar live title search)", () => {
expect(matchesSessionQuery(session("/w", "2026-08-13T00:00:00Z"), "new")).toBe(false);
});
});
+
+/**
+ * Time buckets (the sidebar's "by time" grouping): last day / last month / earlier, cut on
+ * `lastActiveAt` against a caller-supplied "now" so the boundaries are testable without a
+ * clock. The bucket a row lands in must agree with the compact relative timestamp rendered
+ * beside it, which reads the same field.
+ */
+const NOW = Date.parse("2026-08-21T12:00:00.000Z");
+const ago = (ms: number) => new Date(NOW - ms).toISOString();
+const HOUR = 60 * 60 * 1000;
+const DAY = 24 * HOUR;
+
+describe("timeBucketOf", () => {
+ it("cuts at 24 hours and at 30 days, the older side of each boundary losing", () => {
+ expect(timeBucketOf(ago(0), NOW)).toBe("day");
+ expect(timeBucketOf(ago(DAY - 1), NOW)).toBe("day");
+ expect(timeBucketOf(ago(DAY), NOW)).toBe("month");
+ expect(timeBucketOf(ago(30 * DAY - 1), NOW)).toBe("month");
+ expect(timeBucketOf(ago(30 * DAY), NOW)).toBe("earlier");
+ });
+
+ it("puts a clock-skewed future stamp in the newest bucket, and an unreadable one in the oldest", () => {
+ expect(timeBucketOf(new Date(NOW + HOUR).toISOString(), NOW)).toBe("day");
+ // Never the top of the list on a value nothing can be concluded from.
+ expect(timeBucketOf("", NOW)).toBe("earlier");
+ expect(timeBucketOf("not-a-date", NOW)).toBe("earlier");
+ });
+});
+
+describe("groupSessionsByTime", () => {
+ it("renders newest bucket first and drops the empty ones", () => {
+ const groups = groupSessionsByTime(
+ [session("/w", ago(40 * DAY)), session("/w", ago(2 * HOUR))],
+ NOW,
+ );
+ expect(groups.map((g) => g.bucket)).toEqual(["day", "earlier"]);
+ expect(groups.map((g) => g.key)).toEqual([timeGroupKey("day"), timeGroupKey("earlier")]);
+ expect(groupSessionsByTime([], NOW)).toEqual([]);
+ });
+
+ it("buckets and sorts on last activity, not on creation", () => {
+ // An old conversation used today belongs where its own timestamp says it does: the row
+ // reads "2h ago", so a bucket claiming it is older would contradict the row beside it.
+ const revived = session("/w", ago(90 * DAY), {
+ sessionId: "session-revived",
+ lastActiveAt: ago(2 * HOUR),
+ });
+ const fresh = session("/w", ago(3 * DAY), {
+ sessionId: "session-fresh",
+ lastActiveAt: ago(3 * HOUR),
+ });
+ const groups = groupSessionsByTime([fresh, revived], NOW);
+ expect(groups).toHaveLength(1);
+ expect(groups[0]?.bucket).toBe("day");
+ expect(groups[0]?.sessions.map((s) => s.sessionId)).toEqual([
+ "session-revived",
+ "session-fresh",
+ ]);
+ });
+
+ it("keys buckets so they can never collide with a Workspace path or an Agent id", () => {
+ const keys = TIME_BUCKETS.map(timeGroupKey);
+ expect(new Set([...keys, TIME_FOLDERS_GROUP_KEY, TEMP_WORKSPACE_GROUP_KEY]).size).toBe(
+ keys.length + 2,
+ );
+ // "\0" is the one byte a filesystem path and an Agent id cannot contain.
+ for (const key of [...keys, TIME_FOLDERS_GROUP_KEY]) expect(key.startsWith("\0")).toBe(true);
+ });
+});
+
+describe("totalCategoryCounts", () => {
+ const counts = (over: Partial<SessionCategoryCounts>): SessionCategoryCounts => ({
+ active: 0,
+ subagent: 0,
+ schedule: 0,
+ archived: 0,
+ ...over,
+ });
+
+ it("sums every Agent's share, since a time bucket spans all of them", () => {
+ expect(
+ totalCategoryCounts(
+ new Map([
+ ["a", counts({ active: 3, archived: 2 })],
+ ["b", counts({ active: 4, subagent: 1 })],
+ ]),
+ ),
+ ).toEqual({ active: 7, subagent: 1, schedule: 0, archived: 2 });
+ });
+
+ it("reports zeros for an empty map rather than leaving fields undefined", () => {
+ expect(totalCategoryCounts(new Map())).toEqual({
+ active: 0,
+ subagent: 0,
+ schedule: 0,
+ archived: 0,
+ });
+ });
+});