Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(sidebar): print one running count per project header
v_wyxgwang7c40272713b7
diff --git a/apps/desktop/src/components/ProjectRunIndicator.tsx b/apps/desktop/src/components/ProjectRunIndicator.tsxindex 3beba70ba..0eee673f4 100644--- a/apps/desktop/src/components/ProjectRunIndicator.tsx+++ b/apps/desktop/src/components/ProjectRunIndicator.tsx@@ -74,6 +74,10 @@ export function ProjectRunRail({ summary }: { summary: ProjectRunSummary }) {/*** The "n" figure that accompanies the rail: a coloured pip per kind, so the* colour ties the number to its meaning instead of leaving a bare count.+ *+ * It is the badge's stand-in, not an addition to it: callers gate it on+ * `railCount`, so it appears only while the badge is switched off and the same+ * figure never renders twice on one header.*/export function ProjectRunCount({ summary }: { summary: ProjectRunSummary }) {const { t } = useTranslation();diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsxindex 9727e8e9e..95a9d6320 100644--- a/apps/desktop/src/components/Sidebar.tsx+++ b/apps/desktop/src/components/Sidebar.tsx@@ -2284,6 +2284,9 @@ export function Sidebar({const runIsLive = projectRunSummaryIsLive(runSummary);const showRunBadge = runningAffordances.badge && runIsLive;const showRunRail = runningAffordances.rail && runIsLive;+ // Counts belong to one affordance only: the rail's figures stand in for+ // the badge when it is switched off, so both on never prints them twice.+ const showRunCount = runningAffordances.railCount && runIsLive;const renderProjectSessions = (sessions: SessionSummary[]) => {const result: React.ReactNode[] = [@@ -2404,7 +2407,7 @@ export function Sidebar({)}<span>{entry.name}</span>{showRunBadge ? <ProjectRunBadge summary={runSummary} /> : null}- {showRunRail ? <ProjectRunCount summary={runSummary} /> : null}+ {showRunCount ? <ProjectRunCount summary={runSummary} /> : null}{entry.active ? <span className="sidebar-project-active-dot" aria-label={t("project.active", { defaultValue: "Active" })} /> : null}</TooltipButton><span id={`${projectId}-path-description`} className="sr-only">diff --git a/apps/desktop/src/components/remote/RemoteProjectGroups.tsx b/apps/desktop/src/components/remote/RemoteProjectGroups.tsxindex c7f75e741..212ff44ce 100644--- a/apps/desktop/src/components/remote/RemoteProjectGroups.tsx+++ b/apps/desktop/src/components/remote/RemoteProjectGroups.tsx@@ -36,6 +36,9 @@ export function RemoteProjectGroups({ groups, renderSessions }: {const runIsLive = projectRunSummaryIsLive(runSummary);const showRunBadge = runAffordances.badge && runIsLive;const showRunRail = runAffordances.rail && runIsLive;+ // Same exclusivity rule as the local sidebar: one set of numbers, owned by+ // the badge while it is on and by the rail when it is off.+ const showRunCount = runAffordances.railCount && runIsLive;return <sectionclassName={`sidebar-session-group project-group ${runIsLive ? "has-running-sessions" : ""} ${showRunRail ? "has-run-rail" : ""}`}key={project.key}@@ -46,7 +49,7 @@ export function RemoteProjectGroups({ groups, renderSessions }: {title={`${project.hostLabel} · ${project.label}`} onClick={() => void open(project)}><IconFolder size={13} aria-hidden /><span>{project.label} · {project.hostLabel}</span>{showRunBadge ? <ProjectRunBadge summary={runSummary} /> : null}- {showRunRail ? <ProjectRunCount summary={runSummary} /> : null}+ {showRunCount ? <ProjectRunCount summary={runSummary} /> : null}</Button><TooltipButton tooltip={t("nav.newTask")} ariaLabel={`${t("nav.newTask")}: ${project.label} · ${project.hostLabel}`}disabled={busy !== null} onClick={() => void open(project)}><IconNewProject size={14} /></TooltipButton>diff --git a/apps/desktop/src/lib/sidebar-project-runs.ts b/apps/desktop/src/lib/sidebar-project-runs.tsindex 95405f0b3..4a94d12f8 100644--- a/apps/desktop/src/lib/sidebar-project-runs.ts+++ b/apps/desktop/src/lib/sidebar-project-runs.ts@@ -31,14 +31,24 @@ export const EMPTY_PROJECT_RUN_SUMMARY: ProjectRunSummary = {export type ProjectRunSession = { id: string };/**- * The two sidebar affordances, each gated by the master switch. Absent- * settings mean "on" so an existing install keeps the affordances without a- * migration, and turning the master switch off disables both regardless of+ * The two sidebar affordances plus the numeric readout that travels with the+ * rail. The master switch gates all of them; absent sub-switches mean "on"+ * while the master must be explicitly enabled, so an install that never opted+ * in stays quiet, and turning the master off disables everything regardless of* how the sub-switches are stored.*/export type SidebarRunningAffordances = {+ /** Count capsules after the project name. */badge: boolean;+ /** Activity track down the group's left edge. */rail: boolean;+ /**+ * The figures that accompany the rail. They restate the badge, so they only+ * render while the badge is off: with both sub-switches on the header would+ * otherwise print the same counts twice (`.project-run-count` is documented+ * as the badge's stand-in, not an addition to it).+ */+ railCount: boolean;};export function resolveSidebarRunningAffordances(@@ -51,10 +61,9 @@ export function resolveSidebarRunningAffordances(| null,): SidebarRunningAffordances {const master = settings?.sidebarRunningIndicators === true;- return {- badge: master && settings?.sidebarRunningBadge !== false,- rail: master && settings?.sidebarRunningRail !== false,- };+ const badge = master && settings?.sidebarRunningBadge !== false;+ const rail = master && settings?.sidebarRunningRail !== false;+ return { badge, rail, railCount: rail && !badge };}/**diff --git a/apps/desktop/test/sidebar-project-runs.test.mjs b/apps/desktop/test/sidebar-project-runs.test.mjsindex 247939d7e..9a52ed765 100644--- a/apps/desktop/test/sidebar-project-runs.test.mjs+++ b/apps/desktop/test/sidebar-project-runs.test.mjs@@ -47,12 +47,10 @@ test("totalRunningProjects counts groups with live work, not sessions", () => {});test("affordances default off so a fresh install shows a clean sidebar", () => {- assert.deepEqual(resolveSidebarRunningAffordances(undefined), {- badge: false,- rail: false,- });- assert.deepEqual(resolveSidebarRunningAffordances({}), { badge: false, rail: false });- assert.deepEqual(resolveSidebarRunningAffordances(null), { badge: false, rail: false });+ const off = { badge: false, rail: false, railCount: false };+ assert.deepEqual(resolveSidebarRunningAffordances(undefined), off);+ assert.deepEqual(resolveSidebarRunningAffordances({}), off);+ assert.deepEqual(resolveSidebarRunningAffordances(null), off);});test("the master switch gates both sub-switches", () => {@@ -63,7 +61,7 @@ test("the master switch gates both sub-switches", () => {sidebarRunningBadge: true,sidebarRunningRail: true,}),- { badge: false, rail: false },+ { badge: false, rail: false, railCount: false },);// Master off by absence (default), sub-switches on: still off.assert.deepEqual(@@ -71,7 +69,7 @@ test("the master switch gates both sub-switches", () => {sidebarRunningBadge: true,sidebarRunningRail: true,}),- { badge: false, rail: false },+ { badge: false, rail: false, railCount: false },);});@@ -82,7 +80,7 @@ test("each sub-switch turns off independently while the master stays on", () =>sidebarRunningBadge: false,sidebarRunningRail: true,}),- { badge: false, rail: true },+ { badge: false, rail: true, railCount: true },);assert.deepEqual(resolveSidebarRunningAffordances({@@ -90,7 +88,30 @@ test("each sub-switch turns off independently while the master stays on", () =>sidebarRunningBadge: true,sidebarRunningRail: false,}),- { badge: true, rail: false },+ { badge: true, rail: false, railCount: false },+ );+});++test("both sub-switches on leave a single set of numbers", () => {+ // The reported duplicate: badge and rail both on printed the same running+ // count twice, side by side, because the rail's figures are the badge's+ // stand-in rather than an addition to it.+ assert.deepEqual(+ resolveSidebarRunningAffordances({+ sidebarRunningIndicators: true,+ sidebarRunningBadge: true,+ sidebarRunningRail: true,+ }),+ { badge: true, rail: true, railCount: false },+ );+ // The rail is on without the badge: its figures carry the count instead.+ assert.deepEqual(+ resolveSidebarRunningAffordances({+ sidebarRunningIndicators: true,+ sidebarRunningBadge: false,+ sidebarRunningRail: true,+ }),+ { badge: false, rail: true, railCount: true },);});@@ -110,6 +131,10 @@ test("the sidebar renders both affordances from the resolved switches", async ()assert.match(sidebar, /showRunBadge \? <ProjectRunBadge summary=\{runSummary\} \/>/);assert.match(sidebar, /showRunRail \? <ProjectRunRail summary=\{runSummary\} \/>/);assert.match(sidebar, /\{entry\.name\}<\/span>[\s\S]{0,220}ProjectRunBadge/);+ // The rail's count is the badge's stand-in, so the header must gate it on the+ // exclusive flag instead of the rail switch.+ assert.match(sidebar, /showRunCount \? <ProjectRunCount summary=\{runSummary\} \/>/);+ assert.doesNotMatch(sidebar, /showRunRail \? <ProjectRunCount/);});test("remote project groups carry the same affordances", async () => {@@ -120,6 +145,8 @@ test("remote project groups carry the same affordances", async () => {assert.match(remote, /summarizeProjectRuns\(sessions, runningSessions, pendingPermissions\)/);assert.match(remote, /showRunRail \? <ProjectRunRail summary=\{runSummary\} \/>/);assert.match(remote, /showRunBadge \? <ProjectRunBadge summary=\{runSummary\} \/>/);+ assert.match(remote, /showRunCount \? <ProjectRunCount summary=\{runSummary\} \/>/);+ assert.doesNotMatch(remote, /showRunRail \? <ProjectRunCount/);});test("both affordance colours resolve through theme tokens", async () => {diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.mdindex 4f8fdab70..30e37501d 100644--- a/docs/spec/04-ux/01-ui-ia.md+++ b/docs/spec/04-ux/01-ui-ia.md@@ -236,7 +236,10 @@ destination, chat as the home surface, tools and permissions inline.never read as one number;- an **activity rail**: a 2px track down the group's left edge with atravelling pulse, spanning the opened conversation list and shrinking to- the header while the group is collapsed, plus a matching count.+ the header while the group is collapsed. It also carries the counts while+ the badge is switched off; with both affordances on the badge owns the+ figures and the rail stays a pure track, so one count is never printed+ twice for the same group.Remote host groups carry the same pair. Settings → Appearance → Sidebar ownsone master switch (`AppSettings.sidebarRunningIndicators`) gating twosub-switches (`sidebarRunningBadge`, `sidebarRunningRail`). When unset, thediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex f8f645084..c140c8fb5 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -19385,7 +19385,9 @@ host-created files. The full app's file-preview viewer is covered separately.header shows only the count badge by default; the activity rail is off.Running and permission-waiting counts are separate figures and never mergeinto one number. The remote host group shows the same default. Turning on the- activity rail displays it alongside the badge. The master switch removes+ activity rail displays it alongside the badge, while the counts stay in the+ badge alone; with the badge switched off the rail takes them over, so no+ group ever shows the same figure twice. The master switch removesboth affordances at once and leaves the two sub-switches disabled whileretaining their stored value, sore-enabling the master restores the previous choice. Each sub-switch hidesdiff --git a/docs/zh-CN/spec/04-ux/01-ui-ia.md b/docs/zh-CN/spec/04-ux/01-ui-ia.mdindex af314aebc..6a4abc8d9 100644--- a/docs/zh-CN/spec/04-ux/01-ui-ia.md+++ b/docs/zh-CN/spec/04-ux/01-ui-ia.md@@ -180,7 +180,8 @@揭示完整的项目路径。- **运行活动**:有任务正在运行的项目组会在标题上显示状态,因为折叠组会隐藏所有会话行状态。项目名后面的**数量徽标**把运行中和等待权限的会话数分开显示;左侧的**活动流光**- 则是带有移动脉冲的 2px 轨道,展开时沿会话列表显示,折叠时收缩至标题。远程项目组使用相同显示。+ 则是带有移动脉冲的 2px 轨道,展开时沿会话列表显示,折叠时收缩至标题。计数只归属一个标识:+ 数量徽标开启时数字在徽标里,徽标关闭后才由流光接管,两者同开不会把同一个数字显示两遍。远程项目组使用相同显示。“设置 → 外观 → 侧边栏”控制一个总开关及两个子开关。未设置时总开关和数量徽标默认开启,活动流光默认关闭;已保存的值优先生效。关闭总开关会隐藏两种提示,但保留子开关的已保存选项。减少动态效果时两种提示都保持静态且可辨识。diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 8c437598a..ef9c7b725 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -10102,7 +10102,7 @@ host-created files. The full app's file-preview viewer is covered separately.6. 只关闭“数量徽标”并检查效果,然后重新开启徽标。7. 只关闭“活动流光”并检查效果,然后重新开启活动流光。8. 开启操作系统的“减少动态效果”并检查活动流光。-- **预期**:默认时有运行活动的项目标题只显示数量徽标,活动流光关闭;运行中与等待权限的数量分开呈现。远程主机项目也遵循相同默认值。启用活动流光后,它与徽标同时显示。关闭总开关会隐藏两种提示,子开关置灰但保留已存值;重新开启后恢复此前选择。每个子开关只隐藏自身提示。减少动态效果时两种提示仍可见,但不播放动画。设置在渲染进程重载后保留。+- **预期**:默认时有运行活动的项目标题只显示数量徽标,活动流光关闭;运行中与等待权限的数量分开呈现。远程主机项目也遵循相同默认值。启用活动流光后,它与徽标同时显示,但计数仍只出现在徽标里;关闭数量徽标后计数改由流光承担,因此同一组不会把同一个数字显示两遍。关闭总开关会隐藏两种提示,子开关置灰但保留已存值;重新开启后恢复此前选择。每个子开关只隐藏自身提示。减少动态效果时两种提示仍可见,但不播放动画。设置在渲染进程重载后保留。- **关联规格**:`04-ux/01-ui-ia.md` §3.2、`04-ux/06-settings-ia.md`(常规 → 侧边栏卡片)。- **验收**:项目折叠时仍能回答“这里是否有正在运行的工作”,且两种提示可从持久化设置独立控制。- **状态**:草稿。现有 `apps/desktop/test/sidebar-project-runs.test.mjs` 覆盖数量分类、总开关与子开关门控、两种渲染入口,以及主题令牌和减少动态效果保证;它不覆盖设置 API 缺省值规范化或完整交互,相关场景仍需在可用环境手动验证。