diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 092309492..f8b7ce125 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -612,7 +612,10 @@ function App(): React.JSX.Element {
activeWorktreeId !== null &&
!hasTabBar &&
effectiveActiveTabExpanded
- const showSidebar = activeView !== 'settings'
+ // Why: Activity is a full-page navigation surface — same treatment as
+ // Settings — so the worktree sidebar is removed for that view, letting the
+ // thread list + agent terminal span edge-to-edge.
+ const showSidebar = activeView !== 'settings' && activeView !== 'activity'
// Why: only the terminal workspace replaces the full-width titlebar with
// split-column chrome. Full-page navigation views keep the draggable app
// titlebar so their page-level controls can live in that window strip.
@@ -881,7 +884,9 @@ function App(): React.JSX.Element {
{/* Why: Back/Forward traverse mixed worktree + Tasks history, so the
cluster is shown wherever the history shortcut is live (terminal or
- tasks). Hidden in Settings to keep that view modal-ish. */}
+ tasks). Hidden in Settings to keep that view modal-ish, and in
+ Activity since that page owns its own back-out via the Close button
+ in ActivityTitlebarControls. */}
{(activeView === 'terminal' || activeView === 'tasks') && (
diff --git a/src/renderer/src/components/Terminal.tsx b/src/renderer/src/components/Terminal.tsx
index db6fcc4fe..f00a42a32 100644
--- a/src/renderer/src/components/Terminal.tsx
+++ b/src/renderer/src/components/Terminal.tsx
@@ -54,6 +54,11 @@ import {
} from './terminal/split-group-mount'
import { appendUniqueOpenFileIds } from './terminal/unsaved-close-queue'
import CodexRestartChip from './CodexRestartChip'
+import {
+ findActivityTerminalPortal,
+ useActivityTerminalPortals,
+ type ActivityTerminalPortalTarget
+} from './activity/activity-terminal-portal'
const EditorPanel = lazy(() => import('./editor/EditorPanel'))
@@ -102,6 +107,15 @@ function Terminal(): React.JSX.Element | null {
const setTabBarOrder = useAppStore((s) => s.setTabBarOrder)
const tabBarOrderByWorktree = useAppStore((s) => s.tabBarOrderByWorktree)
const tabBarOrder = activeWorktreeId ? tabBarOrderByWorktree[activeWorktreeId] : undefined
+ // Why (anchored to selected thread, not active tab): the activity page
+ // publishes the full {target, worktreeId, tabId} descriptor sourced from
+ // its selectedThread. Deriving worktreeId/tabId from activeWorktreeId/
+ // activeTabId here used to flash the wrong terminal — selectThread updates
+ // the store in multiple steps and intermediate renders briefly pointed the
+ // portal at the new worktree's stale last-active tab.
+ const activityTerminalPortals: ActivityTerminalPortalTarget[] = useActivityTerminalPortals(
+ activeView === 'activity'
+ )
const tabs = useMemo(
() => (activeWorktreeId ? (tabsByWorktree[activeWorktreeId] ?? []) : []),
@@ -1247,6 +1261,7 @@ function Terminal(): React.JSX.Element | null {
layout={layout}
focusedGroupId={activeGroupIdByWorktree[worktree.id]}
isVisible={isVisible}
+ activityTerminalPortals={activityTerminalPortals}
/>
)
})}
@@ -1299,27 +1314,40 @@ function Terminal(): React.JSX.Element | null {
aria-hidden={!isVisible}
>
- {(tabsByWorktree[worktree.id] ?? []).map((tab) => (
- handlePtyExit(tab.id, ptyId)}
- onCloseTab={() => handleCloseTab(tab.id)}
- />
- ))}
+ {(tabsByWorktree[worktree.id] ?? []).map((tab) => {
+ const activityTerminalPortal = findActivityTerminalPortal(
+ activityTerminalPortals,
+ worktree.id,
+ tab.id
+ )
+ const isActivityPortalTab = activityTerminalPortal !== null
+ const isActiveTerminalTab =
+ isVisible && tab.id === activeTabId && activeTabType === 'terminal'
+ const terminalPane = (
+ handlePtyExit(tab.id, ptyId)}
+ onCloseTab={() => handleCloseTab(tab.id)}
+ />
+ )
+ if (activityTerminalPortal) {
+ return createPortal(
+ terminalPane,
+ activityTerminalPortal.target,
+ `activity-terminal-${tab.id}`
+ )
+ }
+ return terminalPane
+ })}
)
})}
@@ -1478,12 +1506,14 @@ const WorktreeSplitSurface = React.memo(function WorktreeSplitSurface({
worktreeId,
layout,
focusedGroupId,
- isVisible
+ isVisible,
+ activityTerminalPortals
}: {
worktreeId: string
layout: TabGroupLayoutNode
focusedGroupId?: string
isVisible: boolean
+ activityTerminalPortals: ActivityTerminalPortalTarget[]
}): React.JSX.Element {
return (
diff --git a/src/renderer/src/components/activity/ActivityPrototypePage.test.ts b/src/renderer/src/components/activity/ActivityPrototypePage.test.ts
new file mode 100644
index 000000000..a04a56fab
--- /dev/null
+++ b/src/renderer/src/components/activity/ActivityPrototypePage.test.ts
@@ -0,0 +1,96 @@
+import { describe, expect, it } from 'vitest'
+import type { AgentStatusEntry } from '../../../../shared/agent-status-types'
+import type { Repo, TerminalTab, Worktree } from '../../../../shared/types'
+import { buildActivityEvents } from './ActivityPrototypePage'
+
+function makeRepo(): Repo {
+ return {
+ id: 'repo-1',
+ path: '/repo',
+ displayName: 'Repo',
+ badgeColor: '#000',
+ addedAt: 1
+ }
+}
+
+function makeWorktree(): Worktree {
+ return {
+ id: 'wt-1',
+ repoId: 'repo-1',
+ path: '/repo/wt-1',
+ head: 'abc123',
+ branch: 'feature',
+ isBare: false,
+ isMainWorktree: false,
+ displayName: 'feature',
+ comment: '',
+ linkedIssue: null,
+ linkedPR: null,
+ linkedLinearIssue: null,
+ isArchived: false,
+ isUnread: false,
+ isPinned: false,
+ sortOrder: 0,
+ lastActivityAt: 1
+ }
+}
+
+function makeTab(): TerminalTab {
+ return {
+ id: 'tab-1',
+ ptyId: 'pty-1',
+ worktreeId: 'wt-1',
+ title: 'Claude',
+ customTitle: null,
+ color: null,
+ sortOrder: 0,
+ createdAt: 1
+ }
+}
+
+function makeWorkingEntryWithPriorDone(): AgentStatusEntry {
+ return {
+ state: 'working',
+ prompt: 'Second prompt',
+ updatedAt: 2_000,
+ stateStartedAt: 2_000,
+ paneKey: 'tab-1:1',
+ terminalTitle: 'Claude',
+ stateHistory: [
+ {
+ state: 'done',
+ prompt: 'First prompt',
+ startedAt: 1_000
+ }
+ ],
+ agentType: 'claude'
+ }
+}
+
+describe('buildActivityEvents', () => {
+ it('keeps a prior done event after the same pane starts working again', () => {
+ const repo = makeRepo()
+ const worktree = makeWorktree()
+ const tab = makeTab()
+
+ const events = buildActivityEvents({
+ agentStatusByPaneKey: {
+ 'tab-1:1': makeWorkingEntryWithPriorDone()
+ },
+ retainedAgentsByPaneKey: {},
+ tabsByWorktree: {
+ [worktree.id]: [tab]
+ },
+ worktreeMap: new Map([[worktree.id, worktree]]),
+ repoMap: new Map([[repo.id, repo]]),
+ acknowledgedAgentsByPaneKey: {}
+ })
+
+ expect(events).toHaveLength(1)
+ expect(events[0]).toMatchObject({
+ state: 'done',
+ timestamp: 1_000
+ })
+ expect(events[0].entry.prompt).toBe('First prompt')
+ })
+})
diff --git a/src/renderer/src/components/activity/ActivityPrototypePage.tsx b/src/renderer/src/components/activity/ActivityPrototypePage.tsx
index 404bf3534..1dcdc8c00 100644
--- a/src/renderer/src/components/activity/ActivityPrototypePage.tsx
+++ b/src/renderer/src/components/activity/ActivityPrototypePage.tsx
@@ -1,18 +1,9 @@
/* eslint-disable max-lines -- Why: this prototype keeps the real-data adapter
and current visual skeleton together until the next refinement pass decides
which pieces become production modules. */
-import React, { useEffect, useMemo, useState } from 'react'
+import React, { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
import { useShallow } from 'zustand/react/shallow'
-import {
- Bell,
- BellDot,
- BellOff,
- GitBranch,
- MessageSquareText,
- Plus,
- Search,
- Settings
-} from 'lucide-react'
+import { Bell, BellDot, BellOff, MessageSquareText, Search, TerminalSquare } from 'lucide-react'
import { AgentIcon } from '@/lib/agent-catalog'
import { agentTypeToIconAgent, formatAgentTypeLabel } from '@/lib/agent-status'
@@ -22,35 +13,30 @@ import { useAppStore } from '@/store'
import type { RetainedAgentEntry } from '@/store/slices/agent-status'
import { getRepoMapFromState, getWorktreeMapFromState } from '@/store/selectors'
import { useSidebarResize } from '@/hooks/useSidebarResize'
-import { AgentStateDot, agentStateLabel, type AgentDotState } from '@/components/AgentStateDot'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
-import {
- DropdownMenu,
- DropdownMenuCheckboxItem,
- DropdownMenuContent,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuTrigger
-} from '@/components/ui/dropdown-menu'
import { Input } from '@/components/ui/input'
import { Toggle } from '@/components/ui/toggle'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/utils'
+import {
+ setActivityTerminalPortals,
+ type ActivityTerminalPortalTarget
+} from './activity-terminal-portal'
import type { Repo, TerminalTab, Worktree } from '../../../../shared/types'
import type {
+ AgentStateHistoryEntry,
AgentStatusEntry,
AgentStatusState,
AgentType
} from '../../../../shared/agent-status-types'
type ThreadReadFilter = 'all' | 'unread'
-type ActivityDensity = 'compact' | 'comfortable'
+type ActivityEventState = Extract
-type AgentActivityEvent = {
+type ActivityEvent = {
id: string
- kind: 'agent'
- state: Extract
+ state: ActivityEventState
timestamp: number
worktree: Worktree
repo: Repo | null
@@ -61,25 +47,35 @@ type AgentActivityEvent = {
unread: boolean
}
-type WorktreeActivityEvent = {
- id: string
- kind: 'worktree-created'
- timestamp: number
- worktree: Worktree
- repo: Repo | null
- unread: boolean
-}
-
-type ActivityEvent = AgentActivityEvent | WorktreeActivityEvent
-
-type WorktreeThread = {
+// Why (per-pane thread): the activity feed is keyed on the agent pane (a
+// terminal tab + pane id) rather than on the workspace, so the left list
+// shows one entry per agent. paneKey is the stable identity (`${tabId}:${paneId}`).
+type AgentPaneThread = {
+ paneKey: string
+ paneTitle: string
worktree: Worktree
repo: Repo | null
+ agentType: AgentType
latestEvent: ActivityEvent
events: ActivityEvent[]
unread: boolean
}
+type ActivityTerminalPortalReadiness = {
+ target: HTMLElement | null
+ tabId: string | null
+ ready: boolean
+}
+
+type ActivityTerminalPortalDomStatus = {
+ hasSelectedRoot: boolean
+ ready: boolean
+}
+
+type ActivityTerminalPortalSlotId = 'primary' | 'secondary'
+
+const ACTIVITY_TERMINAL_LOADING_LABEL_DELAY_MS = 180
+
const absoluteDateFormatter = new Intl.DateTimeFormat(undefined, {
year: 'numeric',
month: 'short',
@@ -108,13 +104,6 @@ function formatRelativeTime(timestamp: number): string {
return relativeTimeFormatter.format(diffDays, 'day')
}
-function asDotState(state: AgentStatusState): AgentDotState {
- if (state === 'blocked' || state === 'waiting' || state === 'done') {
- return state
- }
- return 'idle'
-}
-
function paneIdFromPaneKey(paneKey: string): number | null {
const colon = paneKey.indexOf(':')
const tail = colon > 0 ? paneKey.slice(colon + 1) : ''
@@ -122,14 +111,145 @@ function paneIdFromPaneKey(paneKey: string): number | null {
return Number.isFinite(parsed) && parsed > 0 ? parsed : null
}
-function agentTitle(event: AgentActivityEvent): string {
+function getSelectedActivityTerminalPortalStatus(
+ target: HTMLElement,
+ tabId: string
+): ActivityTerminalPortalDomStatus {
+ let selectedRoot: HTMLElement | null = null
+ for (const candidate of target.querySelectorAll('[data-terminal-tab-id]')) {
+ if (candidate.dataset.terminalTabId === tabId) {
+ selectedRoot = candidate
+ break
+ }
+ }
+ if (!selectedRoot) {
+ return { hasSelectedRoot: false, ready: false }
+ }
+ const hasPtyBinding =
+ selectedRoot.hasAttribute('data-pty-id') ||
+ selectedRoot.querySelector('[data-pty-id]') !== null
+ const hasXtermScreen = selectedRoot.querySelector('.xterm-screen') !== null
+ return { hasSelectedRoot: true, ready: hasPtyBinding && hasXtermScreen }
+}
+
+function useActivityTerminalPortalReadiness(
+ target: HTMLElement | null,
+ tabId: string | null
+): boolean {
+ const [readiness, setReadiness] = useState({
+ target: null,
+ tabId: null,
+ ready: false
+ })
+
+ useLayoutEffect(() => {
+ if (!target || !tabId) {
+ setReadiness((prev) =>
+ prev.target === null && prev.tabId === null && !prev.ready
+ ? prev
+ : { target: null, tabId: null, ready: false }
+ )
+ return
+ }
+
+ let disposed = false
+ let readyFrame: number | null = null
+ let sawUnreadySelectedRoot = false
+
+ const updateReadiness = (ready: boolean): void => {
+ setReadiness((prev) =>
+ prev.target === target && prev.tabId === tabId && prev.ready === ready
+ ? prev
+ : { target, tabId, ready }
+ )
+ }
+
+ const cancelReadyFrame = (): void => {
+ if (readyFrame !== null) {
+ cancelAnimationFrame(readyFrame)
+ readyFrame = null
+ }
+ }
+
+ const checkReadiness = (): void => {
+ const status = getSelectedActivityTerminalPortalStatus(target, tabId)
+ if (status.ready) {
+ if (!sawUnreadySelectedRoot) {
+ cancelReadyFrame()
+ updateReadiness(true)
+ return
+ }
+ if (readyFrame !== null) {
+ return
+ }
+ // Why: the PTY id can appear before xterm has painted replayed output.
+ // Waiting one frame keeps Activity's cover in place for the blank canvas
+ // frame without moving terminal lifecycle work into global layout effects.
+ readyFrame = requestAnimationFrame(() => {
+ readyFrame = null
+ if (!disposed && getSelectedActivityTerminalPortalStatus(target, tabId).ready) {
+ updateReadiness(true)
+ }
+ })
+ return
+ }
+ if (status.hasSelectedRoot) {
+ sawUnreadySelectedRoot = true
+ }
+ cancelReadyFrame()
+ updateReadiness(false)
+ }
+
+ updateReadiness(false)
+ checkReadiness()
+
+ const observer = new MutationObserver(checkReadiness)
+ observer.observe(target, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeFilter: ['data-terminal-tab-id', 'data-pty-id']
+ })
+
+ return () => {
+ disposed = true
+ cancelReadyFrame()
+ observer.disconnect()
+ }
+ }, [target, tabId])
+
+ return readiness.target === target && readiness.tabId === tabId && readiness.ready
+}
+
+function otherActivityTerminalSlot(
+ slotId: ActivityTerminalPortalSlotId
+): ActivityTerminalPortalSlotId {
+ return slotId === 'primary' ? 'secondary' : 'primary'
+}
+
+function useActivityTerminalLoadingLabel(loading: boolean): boolean {
+ const [visible, setVisible] = useState(false)
+
+ useEffect(() => {
+ if (!loading) {
+ setVisible(false)
+ return
+ }
+ const timer = setTimeout(() => setVisible(true), ACTIVITY_TERMINAL_LOADING_LABEL_DELAY_MS)
+ return () => clearTimeout(timer)
+ }, [loading])
+
+ return visible
+}
+
+function agentTitle(event: ActivityEvent): string {
if (event.state === 'done') {
return event.entry.interrupted ? 'Agent interrupted' : 'Agent finished'
}
return event.state === 'waiting' ? 'Agent waiting for input' : 'Agent needs input'
}
-function agentSummary(event: AgentActivityEvent): string {
+function agentSummary(event: ActivityEvent): string {
const prompt = event.entry.prompt.trim()
if (event.state === 'done') {
const message = event.entry.lastAssistantMessage?.trim()
@@ -138,7 +258,7 @@ function agentSummary(event: AgentActivityEvent): string {
return prompt || event.entry.lastAssistantMessage?.trim() || 'The agent paused for user input.'
}
-function agentMeta(event: AgentActivityEvent): string {
+function agentMeta(event: ActivityEvent): string {
const agent = formatAgentTypeLabel(event.agentType)
if (event.state === 'done') {
return event.entry.interrupted ? `${agent} interrupted` : `${agent} completed`
@@ -146,31 +266,134 @@ function agentMeta(event: AgentActivityEvent): string {
return event.state === 'waiting' ? `${agent} waiting` : `${agent} blocked`
}
-function eventTitle(event: ActivityEvent): string {
- return event.kind === 'agent' ? agentTitle(event) : 'Worktree created'
-}
-
-function eventSummary(event: ActivityEvent): string {
- return event.kind === 'agent' ? agentSummary(event) : event.worktree.displayName
-}
-
-function eventMeta(event: ActivityEvent): string {
- if (event.kind === 'agent') {
- return agentMeta(event)
+// Why (label hierarchy): mirror DashboardAgentRow — the agent's last prompt
+// IS what the agent is working on and is the primary signal users want at a
+// glance. A user-renamed customTitle still wins (explicit rename intent), but
+// the OSC-set live title ("Claude Code", "Codex", …) must NOT shadow the
+// prompt: agent CLIs set that title eagerly, so preferring it would pin every
+// row to the agent name and hide the actual turn. Fall back to a non-default
+// liveTitle only when there is no prompt at all.
+function paneTitleForEvent(event: ActivityEvent): string {
+ const tab = event.tab
+ const customTitle = tab.customTitle?.trim()
+ if (customTitle) {
+ return customTitle
}
- return event.worktree.branch
+ const prompt = event.entry.prompt.trim()
+ if (prompt) {
+ return prompt
+ }
+ const liveTitle = tab.title?.trim()
+ const defaultTitle = tab.defaultTitle?.trim()
+ if (liveTitle && liveTitle !== defaultTitle) {
+ return liveTitle
+ }
+ return defaultTitle || liveTitle || 'Terminal'
}
-function buildActivityEvents(args: {
+function isActivityEventState(state: AgentStatusState): state is ActivityEventState {
+ return state === 'done' || state === 'blocked' || state === 'waiting'
+}
+
+// Why: per-pane cap guarantees each agent appears in the left list even when one pane has a long history.
+const EVENTS_PER_PANE_CAP = 5
+
+function historyEntrySnapshot(
+ entry: AgentStatusEntry,
+ history: AgentStateHistoryEntry
+): AgentStatusEntry {
+ return {
+ ...entry,
+ state: history.state,
+ prompt: history.prompt,
+ updatedAt: history.startedAt,
+ stateStartedAt: history.startedAt,
+ stateHistory: [],
+ toolName: undefined,
+ toolInput: undefined,
+ lastAssistantMessage: undefined,
+ interrupted: history.interrupted
+ }
+}
+
+function appendActivityEvent(args: {
+ events: ActivityEvent[]
+ seenEventIds: Set
+ state: ActivityEventState
+ timestamp: number
+ worktree: Worktree
+ repo: Repo | null
+ entry: AgentStatusEntry
+ tab: TerminalTab
+ agentType: AgentType
+ agentAlive: boolean
+ acknowledgedAt: number
+}): void {
+ const id = `agent:${args.entry.paneKey}:${args.state}:${args.timestamp}`
+ if (args.seenEventIds.has(id)) {
+ return
+ }
+ args.seenEventIds.add(id)
+ args.events.push({
+ id,
+ state: args.state,
+ timestamp: args.timestamp,
+ worktree: args.worktree,
+ repo: args.repo,
+ entry: args.entry,
+ tab: args.tab,
+ agentType: args.agentType,
+ agentAlive: args.agentAlive,
+ unread: args.acknowledgedAt < args.timestamp
+ })
+}
+
+function appendActivityEventsForEntry(args: {
+ events: ActivityEvent[]
+ seenEventIds: Set
+ entry: AgentStatusEntry
+ worktree: Worktree
+ repo: Repo | null
+ tab: TerminalTab
+ agentType: AgentType
+ agentAlive: boolean
+ acknowledgedAt: number
+}): void {
+ // Why: Activity is an append-only history surface. When a user continues in
+ // the same terminal pane, the live entry moves done→working; stateHistory is
+ // the only place the previous done/blocking event still exists.
+ for (const history of args.entry.stateHistory) {
+ if (!isActivityEventState(history.state)) {
+ continue
+ }
+ appendActivityEvent({
+ ...args,
+ state: history.state,
+ timestamp: history.startedAt,
+ entry: historyEntrySnapshot(args.entry, history)
+ })
+ }
+
+ if (!isActivityEventState(args.entry.state)) {
+ return
+ }
+ appendActivityEvent({
+ ...args,
+ state: args.entry.state,
+ timestamp: args.entry.stateStartedAt
+ })
+}
+
+export function buildActivityEvents(args: {
agentStatusByPaneKey: Record
retainedAgentsByPaneKey: Record
tabsByWorktree: Record
worktreeMap: Map
repoMap: Map
acknowledgedAgentsByPaneKey: Record
- locallyReadEventIds: Set
}): ActivityEvent[] {
const events: ActivityEvent[] = []
+ const seenEventIds = new Set()
const tabContext = new Map()
for (const worktree of args.worktreeMap.values()) {
@@ -178,23 +401,9 @@ function buildActivityEvents(args: {
for (const tab of tabs) {
tabContext.set(tab.id, { worktree, tab })
}
- if (worktree.createdAt) {
- const id = `worktree-created:${worktree.id}`
- events.push({
- id,
- kind: 'worktree-created',
- timestamp: worktree.createdAt,
- worktree,
- repo: args.repoMap.get(worktree.repoId) ?? null,
- unread: worktree.isUnread && !args.locallyReadEventIds.has(id)
- })
- }
}
for (const [paneKey, entry] of Object.entries(args.agentStatusByPaneKey)) {
- if (entry.state !== 'done' && entry.state !== 'blocked' && entry.state !== 'waiting') {
- continue
- }
const separatorIndex = paneKey.indexOf(':')
if (separatorIndex <= 0) {
continue
@@ -205,53 +414,68 @@ function buildActivityEvents(args: {
continue
}
const ackAt = args.acknowledgedAgentsByPaneKey[paneKey] ?? 0
- events.push({
- id: `agent-live:${paneKey}:${entry.stateStartedAt}`,
- kind: 'agent',
- state: entry.state,
- timestamp: entry.stateStartedAt,
+ appendActivityEventsForEntry({
+ events,
+ seenEventIds,
worktree: context.worktree,
repo: args.repoMap.get(context.worktree.repoId) ?? null,
entry,
tab: context.tab,
agentType: entry.agentType ?? 'unknown',
agentAlive: true,
- unread: ackAt < entry.stateStartedAt
+ acknowledgedAt: ackAt
})
}
for (const [paneKey, retained] of Object.entries(args.retainedAgentsByPaneKey)) {
const worktree = args.worktreeMap.get(retained.worktreeId)
- if (!worktree || retained.entry.state !== 'done') {
+ if (!worktree) {
continue
}
const ackAt = args.acknowledgedAgentsByPaneKey[paneKey] ?? 0
- events.push({
- id: `agent-retained:${paneKey}:${retained.entry.stateStartedAt}`,
- kind: 'agent',
- state: 'done',
- timestamp: retained.entry.stateStartedAt,
+ appendActivityEventsForEntry({
+ events,
+ seenEventIds,
worktree,
repo: args.repoMap.get(worktree.repoId) ?? null,
entry: retained.entry,
tab: retained.tab,
agentType: retained.agentType,
agentAlive: false,
- unread: ackAt < retained.entry.stateStartedAt
+ acknowledgedAt: ackAt
})
}
- return events.sort((a, b) => b.timestamp - a.timestamp).slice(0, 80)
+ const sorted = events.sort((a, b) => b.timestamp - a.timestamp)
+ const perPaneCount = new Map()
+ const capped: ActivityEvent[] = []
+ for (const event of sorted) {
+ const paneKey = event.entry.paneKey
+ const count = perPaneCount.get(paneKey) ?? 0
+ if (count >= EVENTS_PER_PANE_CAP) {
+ continue
+ }
+ perPaneCount.set(paneKey, count + 1)
+ capped.push(event)
+ if (capped.length >= 80) {
+ break
+ }
+ }
+ return capped
}
-function buildWorktreeThreads(events: ActivityEvent[]): WorktreeThread[] {
- const byWorktreeId = new Map()
+function buildAgentPaneThreads(events: ActivityEvent[]): AgentPaneThread[] {
+ const byPaneKey = new Map()
for (const event of events) {
- const existing = byWorktreeId.get(event.worktree.id)
+ const paneKey = event.entry.paneKey
+ const existing = byPaneKey.get(paneKey)
if (!existing) {
- byWorktreeId.set(event.worktree.id, {
+ byPaneKey.set(paneKey, {
+ paneKey,
+ paneTitle: paneTitleForEvent(event),
worktree: event.worktree,
repo: event.repo,
+ agentType: event.agentType,
latestEvent: event,
events: [event],
unread: event.unread
@@ -262,13 +486,15 @@ function buildWorktreeThreads(events: ActivityEvent[]): WorktreeThread[] {
existing.unread = existing.unread || event.unread
if (event.timestamp > existing.latestEvent.timestamp) {
existing.latestEvent = event
+ existing.paneTitle = paneTitleForEvent(event)
+ existing.agentType = event.agentType
}
}
- return Array.from(byWorktreeId.values())
+ return Array.from(byPaneKey.values())
.map((thread) => ({
...thread,
- events: [...thread.events].sort((a, b) => a.timestamp - b.timestamp)
+ events: [...thread.events].sort((a, b) => b.timestamp - a.timestamp)
}))
.sort((a, b) => b.latestEvent.timestamp - a.latestEvent.timestamp)
}
@@ -308,207 +534,18 @@ function EventRepoBadge({ repo }: { repo: Repo | null }): React.JSX.Element | nu
)
}
-function AgentEventRow({
- event,
- density,
- onMarkRead
-}: {
- event: AgentActivityEvent
- density: ActivityDensity
- onMarkRead: (event: ActivityEvent) => void
-}): React.JSX.Element {
- const compact = density === 'compact'
- const dotState = asDotState(event.state)
-
- const jumpToAgent = (clickEvent: React.MouseEvent): void => {
- clickEvent.stopPropagation()
- onMarkRead(event)
- activateAndRevealWorktree(event.worktree.id)
- activateTabAndFocusPane(event.tab.id, paneIdFromPaneKey(event.entry.paneKey))
- }
-
- return (
-