Activity page agent terminal view (#1723)
* fix(activity): align unread dot with row icon Anchor the unread mini-dot to the icon's own bounding box (relative inline-flex with -top-1 -left-1) instead of the 24x24 cell. The previous absolute positioning was relative to the cell, so the dot landed visibly off-center against the centered AgentStateDot/Plus glyph. Adds a ring-2 ring-background halo for contrast against the row's tinted unread background. Applies to both AgentEventRow and WorktreeEventRow. Co-authored-by: Orca <help@stably.ai> * fix(activity): drop top padding so content sits flush with titlebar Outer wrapper used py-3, plus the right-pane <section> had pt-2 and the thread-list header had py-2 — the stacked top whitespace produced a visible gap above the first row against the titlebar. The ActivityTitlebarControls bar already provides the breathing-room band. Drop the wrapper's top padding (py-3 → pb-3), drop the right-pane section's pt-2, and tighten the thread-list header to pt-1.5 pb-2 so the WORKTREES label aligns with the right-pane worktree title row. Co-authored-by: Orca <help@stably.ai> * fix(activity): make event row the click target for navigate + ack The inline "Jump to agent" button only rendered when agentAlive was true, so retained-done rows had no jump affordance, and in compact mode it was hover-only. Users naturally click anywhere on the row expecting it to navigate. Move the navigate-and-ack logic onto the row's onClick (with role, tabIndex, and Enter/Space keyboard support) and drop the inline buttons. Per the design doc (option 1), drop the agentAlive gate entirely: activateAndRevealWorktree is safe unconditionally and activateTabAndFocusPane silently no-ops on a missing tab id, so a stale-tab click is a soft no-op. Mirror the same pattern on WorktreeEventRow so clicking a "Worktree created" row navigates to that worktree. Co-authored-by: Orca <help@stably.ai> * fix(activity): bell glyph for unread + larger row state icon The unread mini-dot stacked on the AgentStateDot competed with the dot itself for the eye and read like a status badge on the agent state. Replace it with a small BellDot glyph at the icon's top-right corner so the unread cue rhymes with the bell button on ThreadRow — one unread vocabulary across both surfaces. While here, bump the row state icon to a new 'lg' AgentStateDot size (18px) so the green check sits center-of-mass in its 32px column instead of floating small and high. Bump the WorktreeEventRow Plus glyph to match. Co-authored-by: Orca <help@stably.ai> * fix(activity): drop left padding so thread list reaches the window edge The page wrapper used px-4, which left a 16px gap to the left of the thread list — visually inconsistent with how sidebars abut the window chrome elsewhere. Switch to pr-4 (keep right padding for the right pane). Inner thread-list and right-pane padding remain unchanged. Co-authored-by: Orca <help@stably.ai> * fix(activity): use left-edge bar for unread instead of an icon overlay Mini-dot and bell-glyph attempts both crowded the AgentStateDot/Plus icon column. Switch to the same left-edge primary bar that ThreadRow already uses for unread — a row-level cue keeps the icon column clean and unifies the unread vocabulary across both panes. Co-authored-by: Orca <help@stably.ai> * fix(activity): page extends to both edges, restore right-pane top padding, rename to "workspace" - Drop horizontal padding on the page wrapper (pr-4 → none) so the thread list reaches the left edge and the right pane reaches the right edge — matches how sidebars abut the chrome elsewhere. - Restore a small top padding (pt-2) on the right-pane title row so the workspace heading isn't pinned to the titlebar. Earlier Fix 2 over-corrected by removing it entirely. - Rename user-facing "Worktree(s)" → "Workspace(s)" (column label, event title "Worktree created", description copy, "Jump to worktree" button, empty state). Internal identifiers stay as worktree* since that's the data-model name. Co-authored-by: Orca <help@stably.ai> * fix(activity): remove redundant "Jump to workspace" header button Clicking any event row already calls markThreadRead + activateAndRevealWorktree (plus a tab focus, so it's a strict superset of what the header button did). The button's only unique behavior was "go to the workspace without picking a tab" — thin justification when the latest event is one row down. cursor-pointer + hover already signal that rows are clickable. Co-authored-by: Orca <help@stably.ai> * fix(activity): wrap agent summary instead of truncating The summary line used 'truncate' with a max-width, hiding the rest of the agent's message behind an ellipsis. The Activity page is meant to let users scan what each agent said without leaving the surface, so truncation defeats its purpose. Switch to break-words + whitespace-pre-wrap so the full message renders and multi-line output keeps its line breaks. Co-authored-by: Orca <help@stably.ai> * fix(activity): clamp agent summary to 3 lines Showing the full message made tall rows for chatty agents. Cap at 3 lines (line-clamp-3) — long enough to convey what happened, short enough that rows stay scannable. Users open the workspace if they want the full transcript. Co-authored-by: Orca <help@stably.ai> * feat(activity): switch left list from workspaces to agent panes Restructure the activity feed so each thread is one *agent pane* (a terminal tab + pane id) rather than one workspace. Internal model goes from WorktreeThread → AgentPaneThread keyed on paneKey. Renderer changes: - Left list: each row shows the pane title (with agent icon + repo badge), then the workspace name as secondary context. Section label changes "Workspaces" → "Agents". - Right pane: header shows the pane title, agent icon, repo badge, and the workspace name beneath. Drops the Today/Yesterday/Earlier day grouping per design — the relative timestamp on each row is enough orientation, and a flat chronological list scans more cleanly. - Drops the workspace-created event kind entirely (and the WorktreeEventRow + ActivityRow union dispatcher), since the surface is now strictly agent activity. Side effects: - Mark-read no longer needs the locallyReadEventIds layer or the worktree-unread store calls (markWorktreeUnread/clearWorktreeUnread). Acknowledge by paneKey is the only persistence path. - Removes Plus and groupForTimestamp (unused after the refactor). Co-authored-by: Orca <help@stably.ai> * feat(activity): label panes like the per-workspace agents dropdown Pane labels now follow the same hierarchy DashboardAgentRow uses inside the WorktreeCardAgents dropdown: customTitle (user rename) > non-default OSC title > last prompt > defaultTitle / "Terminal" The prompt fallback is the important one — agents that haven't been renamed and don't set an OSC title now render with what the user asked the agent to do (e.g. "Fix the unread dot alignment") instead of the generic "Terminal 1" placeholder. Matches the visual + naming pattern on each workspace card so the activity page reads as a flat-feed extension of that surface. Co-authored-by: Orca <help@stably.ai> * fix(activity): smaller titles, allow 2-line prompt clamp Long prompts were getting truncated at one line, hiding most of the ask. Switch the thread row title from truncate to line-clamp-2, with break-words so long words wrap, and tighten size to text-[13px] + leading-snug so two clamped lines don't dominate the row vertically. Anchor the agent icon to the first line via items-start + pt-[3px]. Right-pane heading drops text-base → text-sm to match. Co-authored-by: Orca <help@stably.ai> * fix(activity): right-pane title gets the same 2-line clamp + smaller size Mirror the ThreadRow change on the right-pane heading: line-clamp-2 + break-words + leading-snug so a long prompt title shows two lines instead of a single-line ellipsis. The repo badge moves down to the secondary line (next to the workspace name) so it doesn't shift with the title height. Co-authored-by: Orca <help@stably.ai> * fix(activity): match WorktreeCard's selected/hover/unread cues Three stacked tints (selected + unread row tint + hover) made an unread hovered row look identical to a selected row, and hover even fought selected. Mirror WorktreeCard: - selected → solid black/white tint + faint shadow, hover suppressed (the active class wins so the row stays visually fixed) - non-selected → only then does hover apply (bg-accent/40) - unread → weight + left-edge primary bar carry the cue; row tint removed (matches WorktreeCard's "weight alone carries the unread signal") Co-authored-by: Orca <help@stably.ai> * feat(activity): portal selected agent terminal Co-authored-by: Orca <help@stably.ai> * fix(activity): keep completed entries after terminal input Co-authored-by: Orca <help@stably.ai> * fix(activity): tighten portal target, unread count, and selection edges - activity-terminal-portal: replace document.body MutationObserver with a module-level pub/sub registry; the page publishes the target via a ref callback, Terminal subscribes. Removes body-wide DOM observation. - Terminal: memoize activityTerminalPortal so WorktreeSplitSurface's React.memo bail-out is preserved across unrelated Terminal re-renders. - ActivityPrototypePage: cap events per-pane (5) so a chatty pane can't push quiet panes off the left list; render an empty-state when a retained thread's tab is gone; skip workspace mutation in activateThreadTerminal when the tab is no longer live; keep the selected thread visible in unread-only mode after auto-mark-read. - ActivityTitlebarControls: walk stateHistory in the unread accumulator (mirrors the new feed semantics); drop worktree-created counting since the new feed has no surface to dismiss them. - AgentStateDot: remove the dead 'lg' size variant. - App: hide worktree sidebar on the Activity view and include it in the back/forward shortcut + button cluster. Co-authored-by: Orca <help@stably.ai> * fix(activity): double-buffer portal slots to remove cold-mount flash Switching threads on the Activity page used to expose xterm's empty canvas for ~133ms while a newly-mounted TerminalPane attached. Replace the single portal target with a double-buffered set of slots: keep the previously displayed terminal visible while the next selected terminal mounts in an invisible same-size slot, then flip slots once the staged slot contains the selected terminal DOM with xterm's screen and PTY binding (with one extra frame only after observing an empty mount). Skips publishing a portal target when the selected retained thread no longer has a live tab so the previous tab's target doesn't linger. Co-authored-by: Orca <help@stably.ai> * fix(activity): remove single-option Display style settings dropdown The activity page's gear menu only held a "Compact list" toggle. Drop the dropdown along with the leftSidebarCompact state, the ActivityDensity type, and the unused dropdown-menu / Settings imports. The thread list keeps the compact layout (the previous default). Co-authored-by: Orca <help@stably.ai> * fix(activity): vertically center Jump to workspace button The header row uses items-start so a 2-line prompt clamps without the badge jumping. self-center on the button overrides that just for the action so it sits in the middle of the title block instead of pinned to the top edge. Co-authored-by: Orca <help@stably.ai> * fix(activity): prefer prompt over OSC live title for thread label paneTitleForEvent put the non-default tab.title ahead of the prompt, so agent CLIs that set "Claude Code" / "Codex" via OSC pinned every row and the right-pane heading to the agent name. The dashboard row this function claims to mirror uses the prompt directly. Re-order to: customTitle (explicit rename) → prompt → non-default liveTitle → defaultTitle, so sending "hi" actually shows "hi" in the title. Co-authored-by: Orca <help@stably.ai> * fix(activity): drop extra row height when prompt is one line The thread row's right column stacked time over the count badge with a gap, which forced the row to ~48px even when the left column's prompt was a single line. Collapse the right column into one horizontal cluster (count + time/bell) so single-line rows stay tight, while two-line prompts still drive the row taller as before. Co-authored-by: Orca <help@stably.ai> * fix(activity): add top/bottom padding to thread rows Bump py-1.5 → py-2.5 so single-line rows breathe and don't sit flush against the row dividers. Co-authored-by: Orca <help@stably.ai> * fix(activity): even out optical row padding (top read heavier than bottom) Symmetric py-2.5 looked top-heavy because the title's leading-snug adds internal whitespace above the cap-height that the secondary row doesn't have below it. Trim the top to pt-2 / pb-2.5 so the row reads balanced. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -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 {
|
||||
</div>
|
||||
{/* 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') && (
|
||||
<div className="ml-auto mr-3 flex items-center">
|
||||
<Tooltip>
|
||||
|
||||
@@ -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}
|
||||
>
|
||||
<CodexRestartChip worktreeId={worktree.id} />
|
||||
{(tabsByWorktree[worktree.id] ?? []).map((tab) => (
|
||||
<TerminalPane
|
||||
key={`${tab.id}-${tab.generation ?? 0}`}
|
||||
tabId={tab.id}
|
||||
worktreeId={worktree.id}
|
||||
cwd={worktree.path}
|
||||
isActive={
|
||||
isVisible && tab.id === activeTabId && activeTabType === 'terminal'
|
||||
}
|
||||
// Why: the bootstrap fallback still uses the legacy
|
||||
// workspace-level terminal host, where only the active
|
||||
// tab should render. Keeping `isVisible` explicit avoids
|
||||
// multiple panes stacking during the short window before
|
||||
// the split-group root layout is ready.
|
||||
isVisible={
|
||||
isVisible && tab.id === activeTabId && activeTabType === 'terminal'
|
||||
}
|
||||
onPtyExit={(ptyId) => 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 = (
|
||||
<TerminalPane
|
||||
key={`${tab.id}-${tab.generation ?? 0}`}
|
||||
tabId={tab.id}
|
||||
worktreeId={worktree.id}
|
||||
cwd={worktree.path}
|
||||
isActive={isActiveTerminalTab || activityTerminalPortal?.active === true}
|
||||
// Why: the activity page hosts this existing pane via
|
||||
// portal while the workspace surface remains hidden.
|
||||
// Keeping `isVisible` true for the portaled tab lets
|
||||
// xterm fit and stream foreground output in-place.
|
||||
isVisible={isActiveTerminalTab || isActivityPortalTab}
|
||||
onPtyExit={(ptyId) => handlePtyExit(tab.id, ptyId)}
|
||||
onCloseTab={() => handleCloseTab(tab.id)}
|
||||
/>
|
||||
)
|
||||
if (activityTerminalPortal) {
|
||||
return createPortal(
|
||||
terminalPane,
|
||||
activityTerminalPortal.target,
|
||||
`activity-terminal-${tab.id}`
|
||||
)
|
||||
}
|
||||
return terminalPane
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
@@ -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 (
|
||||
<div
|
||||
@@ -1496,6 +1526,7 @@ const WorktreeSplitSurface = React.memo(function WorktreeSplitSurface({
|
||||
worktreeId={worktreeId}
|
||||
focusedGroupId={focusedGroupId}
|
||||
isWorktreeActive={isVisible}
|
||||
activityTerminalPortals={activityTerminalPortals}
|
||||
/>
|
||||
<BrowserPaneOverlayLayer worktreeId={worktreeId} isWorktreeActive={isVisible} />
|
||||
</div>
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,34 @@
|
||||
import { Bell } from 'lucide-react'
|
||||
import { ArrowLeft, Bell } from 'lucide-react'
|
||||
|
||||
import { useAppStore } from '@/store'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
import type { AgentStatusEntry, AgentStatusState } from '../../../../shared/agent-status-types'
|
||||
|
||||
function useActivityUnreadCount(): number {
|
||||
return useAppStore((s) => {
|
||||
let count = 0
|
||||
for (const worktrees of Object.values(s.worktreesByRepo)) {
|
||||
for (const worktree of worktrees) {
|
||||
if (worktree.createdAt && worktree.isUnread) {
|
||||
const isUnreadState = (state: AgentStatusState): boolean =>
|
||||
state === 'done' || state === 'blocked' || state === 'waiting'
|
||||
// Why: Activity feed surfaces every historical done/blocked/waiting event from
|
||||
// stateHistory plus the live state, so the badge must mirror the same walk —
|
||||
// counting only on entry.state under-counts panes that started a new turn.
|
||||
const accumulate = (entry: AgentStatusEntry, ackAt: number): void => {
|
||||
for (const history of entry.stateHistory) {
|
||||
if (isUnreadState(history.state) && ackAt < history.startedAt) {
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
if (isUnreadState(entry.state) && ackAt < entry.stateStartedAt) {
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
for (const [paneKey, entry] of Object.entries(s.agentStatusByPaneKey)) {
|
||||
if (entry.state !== 'done' && entry.state !== 'blocked' && entry.state !== 'waiting') {
|
||||
continue
|
||||
}
|
||||
if ((s.acknowledgedAgentsByPaneKey[paneKey] ?? 0) < entry.stateStartedAt) {
|
||||
count += 1
|
||||
}
|
||||
accumulate(entry, s.acknowledgedAgentsByPaneKey[paneKey] ?? 0)
|
||||
}
|
||||
for (const [paneKey, retained] of Object.entries(s.retainedAgentsByPaneKey)) {
|
||||
if (retained.entry.state !== 'done') {
|
||||
continue
|
||||
}
|
||||
if ((s.acknowledgedAgentsByPaneKey[paneKey] ?? 0) < retained.entry.stateStartedAt) {
|
||||
count += 1
|
||||
}
|
||||
accumulate(retained.entry, s.acknowledgedAgentsByPaneKey[paneKey] ?? 0)
|
||||
}
|
||||
return count
|
||||
})
|
||||
@@ -37,31 +37,43 @@ function useActivityUnreadCount(): number {
|
||||
export function ActivityTitlebarControls(): React.JSX.Element {
|
||||
const unreadCount = useActivityUnreadCount()
|
||||
const acknowledgeAgents = useAppStore((s) => s.acknowledgeAgents)
|
||||
const clearWorktreeUnread = useAppStore((s) => s.clearWorktreeUnread)
|
||||
const closeActivityPage = useAppStore((s) => s.closeActivityPage)
|
||||
|
||||
const markAllRead = (): void => {
|
||||
const state = useAppStore.getState()
|
||||
// Why: ack every pane (live + retained) — Date.now() exceeds all historical
|
||||
// startedAt values, clearing the per-history-event unread flags too.
|
||||
acknowledgeAgents([
|
||||
...Object.values(state.agentStatusByPaneKey)
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.state === 'done' || entry.state === 'blocked' || entry.state === 'waiting'
|
||||
)
|
||||
.map((entry) => entry.paneKey),
|
||||
...Object.values(state.agentStatusByPaneKey).map((entry) => entry.paneKey),
|
||||
...Object.values(state.retainedAgentsByPaneKey).map((retained) => retained.entry.paneKey)
|
||||
])
|
||||
for (const worktrees of Object.values(state.worktreesByRepo)) {
|
||||
for (const worktree of worktrees) {
|
||||
if (worktree.createdAt && worktree.isUnread) {
|
||||
clearWorktreeUnread(worktree.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-full min-w-0 flex-1 items-center justify-between gap-3 border-l border-border px-3">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<div
|
||||
className="flex min-w-0 items-center gap-2"
|
||||
style={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties}
|
||||
>
|
||||
{/* Why: Activity hides the worktree sidebar (full-page surface), so the
|
||||
sidebar's nav row isn't available as the back path. This Back button
|
||||
is the dedicated exit, mirroring Settings' onBack pattern. */}
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
onClick={closeActivityPage}
|
||||
aria-label="Close activity"
|
||||
>
|
||||
<ArrowLeft className="size-3.5" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" sideOffset={6}>
|
||||
Close activity
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Bell className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<span className="truncate text-xs font-medium">Activity</span>
|
||||
<Badge variant="secondary" className="h-5 px-1.5 text-[11px] font-normal">
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useLayoutEffect, useState } from 'react'
|
||||
|
||||
export type ActivityTerminalPortalTarget = {
|
||||
slotId: string
|
||||
target: HTMLElement
|
||||
worktreeId: string
|
||||
tabId: string
|
||||
active: boolean
|
||||
}
|
||||
|
||||
let currentTargets: ActivityTerminalPortalTarget[] = []
|
||||
const subscribers = new Set<(targets: ActivityTerminalPortalTarget[]) => void>()
|
||||
|
||||
// Why: the portal target is published with its {worktreeId, tabId} already
|
||||
// attached so consumers don't have to derive routing from the global
|
||||
// activeTabId/activeWorktreeId. The activity page knows which agent pane it
|
||||
// wants to display; deriving from global active state introduced a race where
|
||||
// repo/worktree updates landed before the matching setActiveTab, briefly
|
||||
// portaling a different terminal into the activity slot ("flash" of the wrong
|
||||
// terminal for a few ms).
|
||||
export function setActivityTerminalPortals(targets: ActivityTerminalPortalTarget[]): void {
|
||||
if (currentTargets === targets) {
|
||||
return
|
||||
}
|
||||
currentTargets = targets
|
||||
for (const subscriber of subscribers) {
|
||||
subscriber(targets)
|
||||
}
|
||||
}
|
||||
|
||||
export function useActivityTerminalPortals(enabled: boolean): ActivityTerminalPortalTarget[] {
|
||||
const [targets, setTargets] = useState<ActivityTerminalPortalTarget[]>(
|
||||
enabled ? currentTargets : []
|
||||
)
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!enabled) {
|
||||
setTargets([])
|
||||
return
|
||||
}
|
||||
setTargets(currentTargets)
|
||||
const subscriber = (next: ActivityTerminalPortalTarget[]): void => setTargets(next)
|
||||
subscribers.add(subscriber)
|
||||
return () => {
|
||||
subscribers.delete(subscriber)
|
||||
}
|
||||
}, [enabled])
|
||||
|
||||
return targets
|
||||
}
|
||||
|
||||
export function findActivityTerminalPortal(
|
||||
targets: ActivityTerminalPortalTarget[],
|
||||
worktreeId: string,
|
||||
tabId: string
|
||||
): ActivityTerminalPortalTarget | null {
|
||||
return (
|
||||
targets.find((target) => target.worktreeId === worktreeId && target.tabId === tabId) ?? null
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { lazy, Suspense, useEffect, useMemo, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useDroppable } from '@dnd-kit/core'
|
||||
import { Columns2, Ellipsis, Rows2, X } from 'lucide-react'
|
||||
import { useAppStore } from '../../store'
|
||||
@@ -20,6 +21,10 @@ import {
|
||||
type HoveredTabInsertion,
|
||||
type TabDropZone
|
||||
} from './useTabDragSplit'
|
||||
import {
|
||||
findActivityTerminalPortal,
|
||||
type ActivityTerminalPortalTarget
|
||||
} from '../activity/activity-terminal-portal'
|
||||
|
||||
const EditorPanel = lazy(() => import('../editor/EditorPanel'))
|
||||
|
||||
@@ -35,7 +40,8 @@ export default function TabGroupPanel({
|
||||
reserveCollapsedSidebarHeaderSpace,
|
||||
isTabDragActive = false,
|
||||
activeDropZone = null,
|
||||
hoveredTabInsertion = null
|
||||
hoveredTabInsertion = null,
|
||||
activityTerminalPortals = []
|
||||
}: {
|
||||
groupId: string
|
||||
worktreeId: string
|
||||
@@ -49,6 +55,7 @@ export default function TabGroupPanel({
|
||||
isTabDragActive?: boolean
|
||||
activeDropZone?: TabDropZone | null
|
||||
hoveredTabInsertion?: HoveredTabInsertion | null
|
||||
activityTerminalPortals?: ActivityTerminalPortalTarget[]
|
||||
}): React.JSX.Element {
|
||||
const rightSidebarOpen = useAppStore((state) => state.rightSidebarOpen)
|
||||
const sidebarOpen = useAppStore((state) => state.sidebarOpen)
|
||||
@@ -351,36 +358,47 @@ export default function TabGroupPanel({
|
||||
{activeDropZone ? <TabGroupDropOverlay zone={activeDropZone} /> : null}
|
||||
{model.groupTabs
|
||||
.filter((item) => item.contentType === 'terminal')
|
||||
.map((item) => (
|
||||
<TerminalPane
|
||||
key={`${item.entityId}-${runtimeTerminalTabById.get(item.entityId)?.generation ?? 0}`}
|
||||
tabId={item.entityId}
|
||||
worktreeId={worktreeId}
|
||||
cwd={worktreePath}
|
||||
isActive={
|
||||
isFocused && activeTab?.id === item.id && activeTab.contentType === 'terminal'
|
||||
}
|
||||
// Why: in multi-group splits, the active terminal in each group
|
||||
// must remain visible (display:flex) so the user sees its output,
|
||||
// but only the focused group's terminal should receive keyboard
|
||||
// input. Hidden worktrees stay mounted offscreen, so `isVisible`
|
||||
// must also respect worktree visibility or those detached panes
|
||||
// keep their WebGL renderers alive and exhaust Chromium's context
|
||||
// budget across worktrees.
|
||||
isVisible={
|
||||
isWorktreeActive &&
|
||||
activeTab?.id === item.id &&
|
||||
activeTab.contentType === 'terminal'
|
||||
}
|
||||
onPtyExit={(ptyId) => {
|
||||
if (commands.consumeSuppressedPtyExit(ptyId)) {
|
||||
return
|
||||
}
|
||||
commands.closeItem(item.id)
|
||||
}}
|
||||
onCloseTab={() => commands.closeItem(item.id)}
|
||||
/>
|
||||
))}
|
||||
.map((item) => {
|
||||
const activityTerminalPortal = findActivityTerminalPortal(
|
||||
activityTerminalPortals,
|
||||
worktreeId,
|
||||
item.entityId
|
||||
)
|
||||
const isActivityPortalTab = activityTerminalPortal !== null
|
||||
const isActiveTerminalTab =
|
||||
isFocused && activeTab?.id === item.id && activeTab.contentType === 'terminal'
|
||||
const isVisibleTerminalTab =
|
||||
isWorktreeActive && activeTab?.id === item.id && activeTab.contentType === 'terminal'
|
||||
const terminalPane = (
|
||||
<TerminalPane
|
||||
key={`${item.entityId}-${runtimeTerminalTabById.get(item.entityId)?.generation ?? 0}`}
|
||||
tabId={item.entityId}
|
||||
worktreeId={worktreeId}
|
||||
cwd={worktreePath}
|
||||
isActive={isActiveTerminalTab || activityTerminalPortal?.active === true}
|
||||
// Why: the Activity page shows the selected agent's existing
|
||||
// terminal while the workspace group stays hidden. The portaled
|
||||
// tab must still be visible so xterm fits against the activity
|
||||
// pane and continues foreground output scheduling.
|
||||
isVisible={isVisibleTerminalTab || isActivityPortalTab}
|
||||
onPtyExit={(ptyId) => {
|
||||
if (commands.consumeSuppressedPtyExit(ptyId)) {
|
||||
return
|
||||
}
|
||||
commands.closeItem(item.id)
|
||||
}}
|
||||
onCloseTab={() => commands.closeItem(item.id)}
|
||||
/>
|
||||
)
|
||||
if (activityTerminalPortal) {
|
||||
return createPortal(
|
||||
terminalPane,
|
||||
activityTerminalPortal.target,
|
||||
`activity-terminal-${item.entityId}`
|
||||
)
|
||||
}
|
||||
return terminalPane
|
||||
})}
|
||||
|
||||
{activeTab &&
|
||||
activeTab.contentType !== 'terminal' &&
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useAppStore } from '../../store'
|
||||
import TabGroupPanel from './TabGroupPanel'
|
||||
import TabDragPreview from '../tab-bar/TabDragPreview'
|
||||
import { type HoveredTabInsertion, type TabDropZone, useTabDragSplit } from './useTabDragSplit'
|
||||
import type { ActivityTerminalPortalTarget } from '../activity/activity-terminal-portal'
|
||||
|
||||
const MIN_RATIO = 0.15
|
||||
const MAX_RATIO = 0.85
|
||||
@@ -95,7 +96,8 @@ function SplitNode({
|
||||
isTabDragActive,
|
||||
activeDropGroupId,
|
||||
activeDropZone,
|
||||
hoveredTabInsertion
|
||||
hoveredTabInsertion,
|
||||
activityTerminalPortals
|
||||
}: {
|
||||
node: TabGroupLayoutNode
|
||||
nodePath: string
|
||||
@@ -110,6 +112,7 @@ function SplitNode({
|
||||
activeDropGroupId: string | null
|
||||
activeDropZone: TabDropZone | null
|
||||
hoveredTabInsertion: HoveredTabInsertion | null
|
||||
activityTerminalPortals: ActivityTerminalPortalTarget[]
|
||||
}): React.JSX.Element {
|
||||
const setTabGroupSplitRatio = useAppStore((state) => state.setTabGroupSplitRatio)
|
||||
|
||||
@@ -134,6 +137,7 @@ function SplitNode({
|
||||
hoveredTabInsertion={
|
||||
hoveredTabInsertion?.groupId === node.groupId ? hoveredTabInsertion : null
|
||||
}
|
||||
activityTerminalPortals={activityTerminalPortals}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -161,6 +165,7 @@ function SplitNode({
|
||||
activeDropGroupId={activeDropGroupId}
|
||||
activeDropZone={activeDropZone}
|
||||
hoveredTabInsertion={hoveredTabInsertion}
|
||||
activityTerminalPortals={activityTerminalPortals}
|
||||
/>
|
||||
</div>
|
||||
<ResizeHandle
|
||||
@@ -182,6 +187,7 @@ function SplitNode({
|
||||
activeDropGroupId={activeDropGroupId}
|
||||
activeDropZone={activeDropZone}
|
||||
hoveredTabInsertion={hoveredTabInsertion}
|
||||
activityTerminalPortals={activityTerminalPortals}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -192,12 +198,14 @@ export default function TabGroupSplitLayout({
|
||||
layout,
|
||||
worktreeId,
|
||||
focusedGroupId,
|
||||
isWorktreeActive
|
||||
isWorktreeActive,
|
||||
activityTerminalPortals = []
|
||||
}: {
|
||||
layout: TabGroupLayoutNode
|
||||
worktreeId: string
|
||||
focusedGroupId?: string
|
||||
isWorktreeActive: boolean
|
||||
activityTerminalPortals?: ActivityTerminalPortalTarget[]
|
||||
}): React.JSX.Element {
|
||||
const dragSplit = useTabDragSplit({ worktreeId, enabled: isWorktreeActive })
|
||||
const hasSplits = layout.type === 'split'
|
||||
@@ -254,6 +262,7 @@ export default function TabGroupSplitLayout({
|
||||
activeDropGroupId={dragSplit.hoveredDropTarget?.groupId ?? null}
|
||||
activeDropZone={dragSplit.hoveredDropTarget?.zone ?? null}
|
||||
hoveredTabInsertion={dragSplit.hoveredTabInsertion}
|
||||
activityTerminalPortals={activityTerminalPortals}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user