From 4a3ec0232f1723c915d61316cf98cf4d2cc74d80 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:05:04 -0700 Subject: [PATCH] Show repo icons on compact worktree cards (#5673) Co-authored-by: Orca --- .../src/components/settings/general-search.ts | 19 +--- .../settings/general-support-search.ts | 20 ++++ .../src/components/sidebar/WorktreeCard.tsx | 7 +- .../status-bar/ResourceUsageStatusSegment.tsx | 17 ++-- .../mergeSnapshotAndSessions.test.ts | 8 +- .../status-bar/mergeSnapshotAndSessions.ts | 91 ++----------------- .../status-bar/resource-usage-merge-types.ts | 61 +++++++++++++ 7 files changed, 107 insertions(+), 116 deletions(-) create mode 100644 src/renderer/src/components/settings/general-support-search.ts create mode 100644 src/renderer/src/components/status-bar/resource-usage-merge-types.ts diff --git a/src/renderer/src/components/settings/general-search.ts b/src/renderer/src/components/settings/general-search.ts index a463222c6..0750db8b1 100644 --- a/src/renderer/src/components/settings/general-search.ts +++ b/src/renderer/src/components/settings/general-search.ts @@ -4,8 +4,10 @@ import { translate } from '@/i18n/i18n' import { searchKeywords, translateSearchKeyword } from './settings-search-keywords' import { createLocalizedCatalog } from '@/i18n/localized-catalog' import { getGeneralProjectRuntimeSearchEntries } from './general-project-runtime-search' +import { getGeneralSupportSearchEntries } from './general-support-search' export { getGeneralEditorSearchEntries } from './general-editor-search' +export { getGeneralSupportSearchEntries } from './general-support-search' export const getGeneralWorkspaceSearchEntries = createLocalizedCatalog(() => [ { @@ -274,23 +276,6 @@ export const getGeneralAgentSearchEntries = createLocalizedCatalog(() => [ } ]) -export const getGeneralSupportSearchEntries = createLocalizedCatalog(() => [ - { - title: translate('auto.components.settings.general.search.36a72f0d9e', 'Star Orca on GitHub'), - description: translate( - 'auto.components.settings.general.search.e0b8c8bc25', - 'Support the project with a GitHub star via the gh CLI.' - ), - keywords: [ - ...translateSearchKeyword('auto.components.settings.general.search.e4fb4516d0', 'star'), - ...translateSearchKeyword('auto.components.settings.general.search.06ea5a69a6', 'github'), - ...translateSearchKeyword('auto.components.settings.general.search.b65665703a', 'support'), - ...translateSearchKeyword('auto.components.settings.general.search.e6b01c8e30', 'feedback'), - ...translateSearchKeyword('auto.components.settings.general.search.bdfb6dc21b', 'like') - ] - } -]) - type GeneralPaneSearchOptions = { includeProjectRuntime?: boolean } diff --git a/src/renderer/src/components/settings/general-support-search.ts b/src/renderer/src/components/settings/general-support-search.ts new file mode 100644 index 000000000..fbc7af9a2 --- /dev/null +++ b/src/renderer/src/components/settings/general-support-search.ts @@ -0,0 +1,20 @@ +import { translate } from '@/i18n/i18n' +import { createLocalizedCatalog } from '@/i18n/localized-catalog' +import { translateSearchKeyword } from './settings-search-keywords' + +export const getGeneralSupportSearchEntries = createLocalizedCatalog(() => [ + { + title: translate('auto.components.settings.general.search.36a72f0d9e', 'Star Orca on GitHub'), + description: translate( + 'auto.components.settings.general.search.e0b8c8bc25', + 'Support the project with a GitHub star via the gh CLI.' + ), + keywords: [ + ...translateSearchKeyword('auto.components.settings.general.search.e4fb4516d0', 'star'), + ...translateSearchKeyword('auto.components.settings.general.search.06ea5a69a6', 'github'), + ...translateSearchKeyword('auto.components.settings.general.search.b65665703a', 'support'), + ...translateSearchKeyword('auto.components.settings.general.search.e6b01c8e30', 'feedback'), + ...translateSearchKeyword('auto.components.settings.general.search.bdfb6dc21b', 'like') + ] + } +]) diff --git a/src/renderer/src/components/sidebar/WorktreeCard.tsx b/src/renderer/src/components/sidebar/WorktreeCard.tsx index 5d77f34de..707804281 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.tsx @@ -1210,7 +1210,12 @@ const WorktreeCard = React.memo(function WorktreeCard({ {showInlineRepoBadge && ( - + )} diff --git a/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx b/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx index 4f97e0ec7..f9f9e72af 100644 --- a/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx +++ b/src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx @@ -40,15 +40,14 @@ import type { AppMemory, UsageValues, Worktree } from '../../../../shared/types' import { ORPHAN_WORKTREE_ID } from '../../../../shared/constants' import { isFolderRepo } from '../../../../shared/repo-kind' import { isWorkspaceOldForCleanup } from '../../../../shared/workspace-cleanup' -import { - mergeSnapshotAndSessions, - UNATTRIBUTED_REPO_ID, - type DaemonSession, - type Metric, - type UnifiedProjectGroup, - type UnifiedSessionRow, - type UnifiedWorktreeRow -} from './mergeSnapshotAndSessions' +import { mergeSnapshotAndSessions, UNATTRIBUTED_REPO_ID } from './mergeSnapshotAndSessions' +import type { + DaemonSession, + Metric, + UnifiedProjectGroup, + UnifiedSessionRow, + UnifiedWorktreeRow +} from './resource-usage-merge-types' import { WorkspaceSpaceCompactPanel } from './WorkspaceSpaceCompactPanel' import { STATUS_BAR_CONTEXT_MENU_EXEMPT_PROPS } from './status-bar-context-menu-policy' import { diff --git a/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts b/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts index 71adc8288..06ed8b088 100644 --- a/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts +++ b/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.test.ts @@ -3,12 +3,8 @@ single-source view of how snapshot + daemon-session inputs combine. */ import { describe, expect, it } from 'vitest' import type { MemorySnapshot, TerminalTab, WorktreeMemory } from '../../../../shared/types' -import { - mergeSnapshotAndSessions, - UNATTRIBUTED_REPO_ID, - type DaemonSession, - type MergeContext -} from './mergeSnapshotAndSessions' +import { mergeSnapshotAndSessions, UNATTRIBUTED_REPO_ID } from './mergeSnapshotAndSessions' +import type { DaemonSession, MergeContext } from './resource-usage-merge-types' function emptyAppMemory() { return { diff --git a/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts b/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts index 95bf3cd05..82aa54835 100644 --- a/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts +++ b/src/renderer/src/components/status-bar/mergeSnapshotAndSessions.ts @@ -1,8 +1,3 @@ -/* eslint-disable max-lines -- Why: this module deliberately co-locates the - renderer-local view-model types, the merge function, and its supporting - string-manipulation helpers because they exist solely to feed the popover - in ResourceUsageStatusSegment.tsx. Splitting would scatter logic that has - exactly one consumer. See docs/resource-usage-merge-spec.md. */ /** * Resource Manager popover merge helper. * @@ -22,90 +17,20 @@ * See docs/resource-usage-merge-spec.md for the full design. */ -import type { - MemorySnapshot, - SessionMemory, - TerminalTab, - WorktreeMemory -} from '../../../../shared/types' +import type { MemorySnapshot, SessionMemory, WorktreeMemory } from '../../../../shared/types' import { parsePtySessionId } from '../../../../shared/pty-session-id-format' import { parsePaneKey as parseStablePaneKey } from '../../../../shared/stable-pane-id' import { getRepoIdFromWorktreeId, getWorktreePathBasenameFromId } from '../../../../shared/worktree-id' - -// ─── View-model types (renderer-local) ────────────────────────────── - -/** `null` === "no local sample" (e.g. SSH PTY); UI renders as em-dash. */ -export type Metric = number | null - -export type DaemonSession = { - id: string - cwd: string - title: string -} - -export type UnifiedSessionRow = { - sessionId: string - paneKey: string | null - pid: number - label: string - bound: boolean - tabId: string | null - cpu: Metric - memory: Metric - hasLocalSamples: boolean -} - -export type UnifiedWorktreeRow = { - worktreeId: string - worktreeName: string - repoId: string - repoName: string - cpu: Metric - memory: Metric - history: number[] - hasLocalSamples: boolean - /** Why: the chip in ResourceUsageStatusSegment now keys on this — the repo - * has an SSH connectionId — instead of `!hasLocalSamples`, which used to - * mislabel warm-reattached *local* PTYs as REMOTE. */ - isRemote: boolean - sessions: UnifiedSessionRow[] -} - -export type UnifiedProjectGroup = { - repoId: string - repoName: string - cpu: Metric - memory: Metric - /** Why: renamed in spirit but kept as `hasRemoteChildren` for callsite - * stability — the repo-level chip predicate is now "the repo's - * connectionId is non-null", which is the only way a repo can have - * remote children. */ - hasRemoteChildren: boolean - worktrees: UnifiedWorktreeRow[] -} - -// ─── Inputs that the renderer already has on hand ─────────────────── - -export type MergeContext = { - /** From useAppStore: maps tabId → worktreeId for tab-walk resolution. */ - tabsByWorktree: Record - /** From useAppStore: maps tabId → ptyIds[] for the bound check. */ - ptyIdsByTabId: Record - /** From useAppStore: per-tab live pane titles (for label resolution). */ - runtimePaneTitlesByTabId: Record> - /** From useAppStore: false until the renderer has booted enough state to - * trust the bound/orphan distinction. Mirrors the existing gate. */ - workspaceSessionReady: boolean - /** Repo display names by repo id. Used for new groups synthesized from - * daemon sessions whose repo isn't in the snapshot (typical SSH case). */ - repoDisplayNameById: Map - /** Repo connectionId by repo id (null/missing == local). Drives the - * `· remote` chip predicate, decoupling label from data-coverage. */ - repoConnectionIdById: Map -} +import type { + DaemonSession, + MergeContext, + UnifiedProjectGroup, + UnifiedSessionRow, + UnifiedWorktreeRow +} from './resource-usage-merge-types' // ─── Helpers ──────────────────────────────────────────────────────── diff --git a/src/renderer/src/components/status-bar/resource-usage-merge-types.ts b/src/renderer/src/components/status-bar/resource-usage-merge-types.ts new file mode 100644 index 000000000..5cf962fcd --- /dev/null +++ b/src/renderer/src/components/status-bar/resource-usage-merge-types.ts @@ -0,0 +1,61 @@ +import type { TerminalTab } from '../../../../shared/types' + +/** `null` === "no local sample" (e.g. SSH PTY); UI renders as em-dash. */ +export type Metric = number | null + +export type DaemonSession = { + id: string + cwd: string + title: string +} + +export type UnifiedSessionRow = { + sessionId: string + paneKey: string | null + pid: number + label: string + bound: boolean + tabId: string | null + cpu: Metric + memory: Metric + hasLocalSamples: boolean +} + +export type UnifiedWorktreeRow = { + worktreeId: string + worktreeName: string + repoId: string + repoName: string + cpu: Metric + memory: Metric + history: number[] + hasLocalSamples: boolean + /** Why: repo connectionId, not sample presence, drives the remote chip. */ + isRemote: boolean + sessions: UnifiedSessionRow[] +} + +export type UnifiedProjectGroup = { + repoId: string + repoName: string + cpu: Metric + memory: Metric + /** Why: kept for callsite stability; this now means SSH-backed repo rows. */ + hasRemoteChildren: boolean + worktrees: UnifiedWorktreeRow[] +} + +export type MergeContext = { + /** From useAppStore: maps worktreeId -> tabs[] for tab-walk resolution. */ + tabsByWorktree: Record + /** From useAppStore: maps tabId -> ptyIds[] for the bound check. */ + ptyIdsByTabId: Record + /** From useAppStore: per-tab live pane titles (for label resolution). */ + runtimePaneTitlesByTabId: Record> + /** From useAppStore: false until renderer state can distinguish bound/orphan. */ + workspaceSessionReady: boolean + /** Repo display names by repo id for daemon-only groups. */ + repoDisplayNameById: Map + /** Repo connectionId by repo id (null/missing == local). */ + repoConnectionIdById: Map +}