fix(ui): stack mobile host metrics (#2959)
This commit is contained in:
@@ -10,6 +10,16 @@ import { StatusSurfaceMetrics } from "./status-surface-metrics";
|
||||
const responsiveState = vi.hoisted(() => ({ isMobile: false }));
|
||||
const subscribeMock = vi.hoisted(() => vi.fn());
|
||||
const metricsTestId = "app-status-metrics";
|
||||
const cpuAccessibleName = "CPU 42%";
|
||||
const memoryAccessibleName = "Memory 51%";
|
||||
const allHostMetricAccessibleNames = [
|
||||
cpuAccessibleName,
|
||||
memoryAccessibleName,
|
||||
"Disk 63%",
|
||||
"System load (1 min) 2.5",
|
||||
"CPU temperature 71°C",
|
||||
"network_rx 12.3MB/s",
|
||||
];
|
||||
|
||||
vi.mock("@/hooks/use-responsive-breakpoint", () => ({
|
||||
useResponsiveBreakpoint: () => ({
|
||||
@@ -73,6 +83,20 @@ function renderMetrics(drawerOpen = false, simplified = false, loading = false)
|
||||
available: true,
|
||||
},
|
||||
{ id: "io_load", label: "Load average", value: 2.5, available: true },
|
||||
{
|
||||
id: "cpu_temp",
|
||||
label: "CPU temperature",
|
||||
unit: "°C",
|
||||
value: 71,
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
id: "network_rx",
|
||||
label: "Network receive",
|
||||
unit: "MB/s",
|
||||
value: 12.3,
|
||||
available: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -120,8 +144,8 @@ describe("StatusSurfaceMetrics", () => {
|
||||
|
||||
expect(subscribeMock).toHaveBeenCalledWith(true);
|
||||
expect(screen.getByTestId(metricsTestId)).toBeTruthy();
|
||||
expect(screen.getByLabelText("CPU 42%")).toBeTruthy();
|
||||
expect(screen.getByLabelText("Memory 51%")).toBeTruthy();
|
||||
expect(screen.getByLabelText(cpuAccessibleName)).toBeTruthy();
|
||||
expect(screen.getByLabelText(memoryAccessibleName)).toBeTruthy();
|
||||
expect(screen.getByLabelText("Disk 63%")).toBeTruthy();
|
||||
expect(screen.getAllByTestId("system-metric-meter")).toHaveLength(3);
|
||||
const systemLoad = screen.getByLabelText("System load (1 min) 2.5");
|
||||
@@ -134,6 +158,8 @@ describe("StatusSurfaceMetrics", () => {
|
||||
).not.toHaveLength(0);
|
||||
expect(screen.queryByLabelText("Executor metrics")).toBeNull();
|
||||
expect(screen.queryByLabelText("Memory 99%")).toBeNull();
|
||||
expect(screen.queryByLabelText("CPU temperature 71°C")).toBeNull();
|
||||
expect(screen.queryByLabelText("network_rx 12.3MB/s")).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps the desktop metrics item hidden while the first snapshot is loading", () => {
|
||||
@@ -163,6 +189,16 @@ describe("StatusSurfaceMetrics", () => {
|
||||
expect(metricsRow?.className).toContain("min-w-0");
|
||||
});
|
||||
|
||||
it("renders every received host metric in the phone Status drawer", () => {
|
||||
responsiveState.isMobile = true;
|
||||
renderMetrics(true);
|
||||
|
||||
expect(screen.getByLabelText(cpuAccessibleName).parentElement?.className).toContain("grid");
|
||||
for (const accessibleName of allHostMetricAccessibleNames) {
|
||||
expect(screen.getByLabelText(accessibleName)).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps the phone metrics row hidden while the first snapshot is loading", () => {
|
||||
responsiveState.isMobile = true;
|
||||
renderMetrics(true, false, true);
|
||||
@@ -177,8 +213,8 @@ describe("StatusSurfaceMetrics", () => {
|
||||
|
||||
expect(screen.queryByLabelText("Host metrics")).toBeNull();
|
||||
expect(screen.queryAllByTestId("system-metric-meter")).toHaveLength(0);
|
||||
expect(screen.getByLabelText("CPU 42%")).toBeTruthy();
|
||||
expect(screen.getByLabelText("Memory 51%")).toBeTruthy();
|
||||
expect(screen.getByLabelText(cpuAccessibleName)).toBeTruthy();
|
||||
expect(screen.getByLabelText(memoryAccessibleName)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("omits the host marker and meters in simplified phone drawer mode", () => {
|
||||
@@ -187,7 +223,8 @@ describe("StatusSurfaceMetrics", () => {
|
||||
|
||||
expect(screen.queryByLabelText("Host metrics")).toBeNull();
|
||||
expect(screen.queryAllByTestId("system-metric-meter")).toHaveLength(0);
|
||||
expect(screen.getByLabelText("CPU 42%")).toBeTruthy();
|
||||
expect(screen.getByLabelText("Memory 51%")).toBeTruthy();
|
||||
for (const accessibleName of allHostMetricAccessibleNames) {
|
||||
expect(screen.getByLabelText(accessibleName)).toBeTruthy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ export function StatusSurfaceMetrics({
|
||||
return (
|
||||
<section
|
||||
data-testid="app-status-metrics"
|
||||
className="space-y-2 py-0.5"
|
||||
className="w-full min-w-0 space-y-2 py-0.5"
|
||||
aria-label={t("system:systemMetrics")}
|
||||
>
|
||||
<h3 className="text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground">
|
||||
@@ -136,6 +136,7 @@ function BarSourceMetrics({
|
||||
source={source}
|
||||
updatedAt={updatedAt}
|
||||
limit={metricLimit}
|
||||
layout="inline"
|
||||
simplified={simplified}
|
||||
iconSize={iconSize}
|
||||
/>
|
||||
@@ -155,19 +156,19 @@ function DrawerSourceMetrics({
|
||||
iconSize: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-h-11 w-full min-w-0 items-center gap-2 px-0 text-sm">
|
||||
<div className="flex min-h-11 w-full min-w-0 flex-col items-stretch gap-1 px-0 text-sm">
|
||||
{!simplified ? (
|
||||
<SourceBadge source={source} updatedAt={updatedAt} showLabel iconSize={iconSize} />
|
||||
<div className="flex min-h-11 w-full min-w-0 items-center">
|
||||
<SourceBadge source={source} updatedAt={updatedAt} showLabel iconSize={iconSize} />
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex min-w-0 flex-1 items-center justify-end gap-3 overflow-hidden">
|
||||
<MetricValues
|
||||
source={source}
|
||||
updatedAt={updatedAt}
|
||||
limit={4}
|
||||
simplified={simplified}
|
||||
iconSize={iconSize}
|
||||
/>
|
||||
</div>
|
||||
<MetricValues
|
||||
source={source}
|
||||
updatedAt={updatedAt}
|
||||
layout="grid"
|
||||
simplified={simplified}
|
||||
iconSize={iconSize}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -213,43 +214,53 @@ function MetricValues({
|
||||
source,
|
||||
updatedAt,
|
||||
limit,
|
||||
layout,
|
||||
simplified,
|
||||
iconSize,
|
||||
}: {
|
||||
source: SystemMetricsSource;
|
||||
updatedAt?: string;
|
||||
limit: number;
|
||||
limit?: number;
|
||||
layout: "inline" | "grid";
|
||||
simplified: boolean;
|
||||
iconSize: string;
|
||||
}) {
|
||||
const metrics = source.metrics.slice(0, limit);
|
||||
const metrics = limit === undefined ? source.metrics : source.metrics.slice(0, limit);
|
||||
if (metrics.length === 0) return <span className="text-muted-foreground">-</span>;
|
||||
return (
|
||||
<span className="flex min-w-0 items-center gap-3 overflow-hidden">
|
||||
{metrics.map((metric) => (
|
||||
<MetricValue
|
||||
key={metric.id}
|
||||
metric={metric}
|
||||
source={source}
|
||||
updatedAt={updatedAt}
|
||||
simplified={simplified}
|
||||
iconSize={iconSize}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
const values = metrics.map((metric) => (
|
||||
<MetricValue
|
||||
key={metric.id}
|
||||
metric={metric}
|
||||
source={source}
|
||||
updatedAt={updatedAt}
|
||||
layout={layout}
|
||||
simplified={simplified}
|
||||
iconSize={iconSize}
|
||||
/>
|
||||
));
|
||||
if (layout === "grid") {
|
||||
return (
|
||||
// Keep detailed cells compact enough for two columns in the Pixel 5 drawer.
|
||||
<div className="grid w-full min-w-0 grid-cols-[repeat(auto-fit,minmax(8rem,1fr))] gap-x-3 gap-y-1">
|
||||
{values}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <span className="flex min-w-0 items-center gap-3 overflow-hidden">{values}</span>;
|
||||
}
|
||||
|
||||
function MetricValue({
|
||||
metric,
|
||||
source,
|
||||
updatedAt,
|
||||
layout,
|
||||
simplified,
|
||||
iconSize,
|
||||
}: {
|
||||
metric: SystemMetricSample;
|
||||
source: SystemMetricsSource;
|
||||
updatedAt?: string;
|
||||
layout: "inline" | "grid";
|
||||
simplified: boolean;
|
||||
iconSize: string;
|
||||
}) {
|
||||
@@ -260,7 +271,7 @@ function MetricValue({
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
className={`inline-flex shrink-0 items-center gap-1.5 tabular-nums ${metricColor(metric)}`}
|
||||
className={`${layout === "grid" ? "flex min-h-11 min-w-0 w-full" : "inline-flex shrink-0"} items-center gap-1.5 tabular-nums ${metricColor(metric)}`}
|
||||
aria-label={`${metricLabel(t, metric.id)} ${formatMetric(metric)}`}
|
||||
>
|
||||
{metricIcon(metric.id, iconSize)}
|
||||
|
||||
@@ -9,20 +9,39 @@ import {
|
||||
metricsUnavailableWasRendered,
|
||||
observeMetricsUnavailable,
|
||||
} from "./metrics-loading-observer";
|
||||
import type { SystemMetricId, SystemMetricsGlobalSettings } from "@/lib/types/system";
|
||||
|
||||
type SystemMetricsDisplay = {
|
||||
show_in_topbar: boolean;
|
||||
simplified?: boolean;
|
||||
};
|
||||
|
||||
const ALL_HOST_METRICS = [
|
||||
"cpu_percent",
|
||||
"memory_percent",
|
||||
"disk_percent",
|
||||
"cpu_temp",
|
||||
"io_load",
|
||||
] satisfies SystemMetricId[];
|
||||
|
||||
test.describe("Mobile resource metrics display", () => {
|
||||
let baseline: SystemMetricsDisplay;
|
||||
let statusBarBaseline: AppStatusBarSettingsBaseline;
|
||||
let globalMetricsBaseline: SystemMetricsGlobalSettings;
|
||||
|
||||
test.beforeEach(async ({ apiClient }) => {
|
||||
const settings = await apiClient.getUserSettings();
|
||||
baseline = settings.settings.system_metrics_display as SystemMetricsDisplay;
|
||||
statusBarBaseline = await captureAppStatusBarSettings(apiClient);
|
||||
const globalMetricsResponse = await apiClient.rawRequest(
|
||||
"GET",
|
||||
"/api/v1/system/metrics/settings",
|
||||
);
|
||||
expect(globalMetricsResponse.ok).toBe(true);
|
||||
const globalMetrics = (await globalMetricsResponse.json()) as {
|
||||
settings: SystemMetricsGlobalSettings;
|
||||
};
|
||||
globalMetricsBaseline = globalMetrics.settings;
|
||||
await setAppStatusBarEnabled(apiClient, true);
|
||||
});
|
||||
|
||||
@@ -30,9 +49,73 @@ test.describe("Mobile resource metrics display", () => {
|
||||
await apiClient.rawRequest("PATCH", "/api/v1/user/settings", {
|
||||
system_metrics_display: baseline,
|
||||
});
|
||||
const globalMetricsRestore = await apiClient.rawRequest(
|
||||
"PATCH",
|
||||
"/api/v1/system/metrics/settings",
|
||||
globalMetricsBaseline,
|
||||
);
|
||||
expect(globalMetricsRestore.ok).toBe(true);
|
||||
await restoreAppStatusBarSettings(apiClient, statusBarBaseline);
|
||||
});
|
||||
|
||||
test("stacks all enabled metrics inside the Status drawer", async ({ testPage, apiClient }) => {
|
||||
const globalMetricsUpdate = await apiClient.rawRequest(
|
||||
"PATCH",
|
||||
"/api/v1/system/metrics/settings",
|
||||
{ ...globalMetricsBaseline, metrics: ALL_HOST_METRICS },
|
||||
);
|
||||
expect(globalMetricsUpdate.ok).toBe(true);
|
||||
const displayUpdate = await apiClient.rawRequest("PATCH", "/api/v1/user/settings", {
|
||||
system_metrics_display: { show_in_topbar: true, simplified: false },
|
||||
});
|
||||
expect(displayUpdate.ok).toBe(true);
|
||||
|
||||
await testPage.goto("/");
|
||||
await testPage.getByRole("button", { name: "Open menu" }).click();
|
||||
await testPage.getByTestId("mobile-home-status-button").click();
|
||||
|
||||
const drawer = testPage.getByTestId("app-status-drawer");
|
||||
const metrics = drawer.getByTestId("app-status-metrics");
|
||||
await expect(metrics.getByLabel(/^CPU (?!temperature)/)).toBeVisible();
|
||||
const geometry = await metrics.evaluate((element) => {
|
||||
const indicators = Array.from(
|
||||
element.querySelectorAll<HTMLElement>('span[aria-label]:not([aria-label="Host metrics"])'),
|
||||
);
|
||||
const values = indicators[0]?.parentElement;
|
||||
const valuesRect = values?.getBoundingClientRect();
|
||||
const indicatorRects = indicators.map((indicator) => indicator.getBoundingClientRect());
|
||||
const rowTops: number[] = [];
|
||||
for (const rect of indicatorRects) {
|
||||
if (!rowTops.some((top) => Math.abs(top - rect.top) <= 1)) rowTops.push(rect.top);
|
||||
}
|
||||
const firstRowTop = rowTops[0];
|
||||
return {
|
||||
count: indicators.length,
|
||||
firstRowCount: indicatorRects.filter(
|
||||
(rect) => firstRowTop !== undefined && Math.abs(rect.top - firstRowTop) <= 1,
|
||||
).length,
|
||||
rowCount: rowTops.length,
|
||||
valuesClientWidth: values?.clientWidth ?? 0,
|
||||
valuesScrollWidth: values?.scrollWidth ?? 0,
|
||||
contained:
|
||||
valuesRect !== undefined &&
|
||||
indicatorRects.every(
|
||||
(rect) => rect.left >= valuesRect.left - 1 && rect.right <= valuesRect.right + 1,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
expect(geometry.rowCount).toBe(3);
|
||||
expect(geometry.firstRowCount).toBe(2);
|
||||
expect(geometry.count).toBe(5);
|
||||
expect(geometry.contained).toBe(true);
|
||||
expect(geometry.valuesScrollWidth).toBeLessThanOrEqual(geometry.valuesClientWidth + 1);
|
||||
expect(await drawer.locator("[class*='overflow-y-auto']").count()).toBe(1);
|
||||
expect(await testPage.evaluate(() => document.documentElement.scrollWidth)).toBe(
|
||||
await testPage.evaluate(() => document.documentElement.clientWidth),
|
||||
);
|
||||
});
|
||||
|
||||
test("renders simplified metrics in the Status drawer", async ({ testPage }) => {
|
||||
await testPage.goto("/settings");
|
||||
await testPage.getByTestId("settings-index").getByRole("link", { name: "Appearance" }).click();
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
spec: docs/specs/ui/app-status-bar.md
|
||||
created: 2026-08-23
|
||||
status: completed
|
||||
---
|
||||
|
||||
# Implementation Plan: Mobile Status Metrics Grid
|
||||
|
||||
## Overview
|
||||
|
||||
Replace the phone Status drawer's single-line host-metrics strip with a width-aware grid while leaving desktop, tablet, and topbar presentations unchanged. The phone drawer will use its vertical space to show every enabled host metric, then targeted component and Pixel 5 Playwright regressions will prove wrapping and containment.
|
||||
|
||||
## Confirmed root cause
|
||||
|
||||
`DrawerSourceMetrics` in `apps/web/components/system-metrics/status-surface-metrics.tsx` puts the detailed Host marker and `MetricValues` in one horizontal flex row. `MetricValues` is another non-wrapping flex row with `overflow-hidden`, while every `MetricValue` is `shrink-0`; their combined minimum width therefore cannot reflow when it exceeds the drawer row. The drawer path also passes `limit={4}`, carrying a desktop strip constraint into a vertically scrollable phone surface. The mobile metrics section is an auto-width child of the drawer row, so it shrink-wraps its contents instead of claiming the available row width. Existing mobile E2E checks only document-level overflow and the outer status-row height, so clipped or internally overflowing metric indicators are not detected.
|
||||
|
||||
Smallest reproduction: enable the app status surface and all five current host metrics, open Status in the configured Pixel 5 project, and inspect `[data-status-item-id="builtin:metrics"]`. The metric children remain one horizontal row and the fifth enabled metric is absent rather than continuing below.
|
||||
|
||||
## Frontend
|
||||
|
||||
### Presentation-specific metric layout
|
||||
|
||||
- `apps/web/components/system-metrics/status-surface-metrics.tsx`: keep `BarSourceMetrics` on the current bounded inline layout and density limits. Change `DrawerSourceMetrics` to a vertical source-and-values composition: detailed mode renders `SourceBadge` as the leading source line, followed by a full-width responsive grid; simplified mode renders only that grid.
|
||||
- Give `MetricValues` an explicit inline-versus-grid layout input instead of making shared metric rendering infer presentation from viewport state. The grid uses an auto-fit/minimum-cell rule so its column count derives from actual available width, produces two columns at Pixel 5 width, and falls back to fewer or grows to more columns only when space requires it.
|
||||
- The drawer grid consumes all `source.metrics` entries in their received order. Keep the existing slice limits for bar/topbar paths. Grid cells remain touch-inspectable, use the existing icon, meter, value, color, accessible name, and tooltip behavior, and never create an internal horizontal scroll owner.
|
||||
|
||||
## Mobile design contract
|
||||
|
||||
- **Desktop outcome:** the 24 px status bar and pre-status-bar topbar fallback retain their current inline density, ordering, limits, and drag behavior.
|
||||
- **Mobile entry point:** existing native Status triggers continue opening the global inset bottom drawer; no new route or control is added.
|
||||
- **Nearest shipped exemplars:** `apps/web/components/app-status-bar/app-status-drawer.tsx` supplies the inset surface, fixed header, safe-area clearance, and one vertical scroll owner. `apps/web/components/task/chat/messages/kandev/rich-output/metrics-block.tsx` supplies the closest shipped width-aware metric-grid geometry.
|
||||
- **Hierarchy and presentation:** System metrics remains one saved status item. In detailed mode, source identity precedes the metric grid; metrics then scan left-to-right and top-to-bottom. This read-only, frequently scanned content stays inline in the existing drawer rather than opening another surface.
|
||||
- **Scrolling and touch:** `app-status-drawer-scroll-region` remains the sole scroll owner. Metric cells fit the item width, remain touch-inspectable, and add height to the drawer content instead of horizontal scrolling. Existing dynamic viewport and bottom safe-area handling remain unchanged.
|
||||
- **Shared versus responsive behavior:** source selection, subscriptions, ordering, formatting, thresholds, simplified preference, and tooltips stay shared. Only drawer composition and its removal of the desktop display limit are phone-specific.
|
||||
- **Mobile proof:** the configured Pixel 5 project enables all five current host metrics, opens Status, and proves two columns, three occupied rows, complete indicator visibility, item containment, and zero metric-item/drawer/document horizontal overflow.
|
||||
|
||||
## Tests
|
||||
|
||||
- **What:** phone rendering keeps every received metric and selects the grid layout, while desktop/bar rendering retains its four-metric limit and inline layout.
|
||||
- **File:** `apps/web/components/system-metrics/status-surface-metrics.test.tsx`
|
||||
- **How:** extend the existing state-provider harness with six ordered samples; assert all six mobile indicators render under the grid test surface in detailed and simplified modes, while the bar still renders only its configured first four. Keep the existing subscription, source filtering, host-marker, meter, and loading assertions.
|
||||
|
||||
## E2E Tests
|
||||
|
||||
- **Scenario:** **GIVEN** all five supported host metrics and detailed Status metrics are enabled, **WHEN** a phone user opens Status, **THEN** all five indicators render left-to-right across two Pixel 5 columns and continue into three rows without exceeding the metrics item, drawer, or document width.
|
||||
- **File:** `apps/web/e2e/tests/settings/mobile-resource-metrics-display.spec.ts`
|
||||
- **What to verify:** capture and restore both user display settings and global metrics settings; assert indicator count and bounding-box row/column relationships rather than fixed pixel widths; assert grid `scrollWidth <= clientWidth`, every indicator's horizontal bounds stay inside the grid/status item, the drawer keeps one vertical scroll owner, and document horizontal overflow remains zero. Preserve the existing simplified-mode scenario.
|
||||
|
||||
## Implementation Waves And Parallel Candidates
|
||||
|
||||
Wave 1:
|
||||
|
||||
- [x] [Task 01: Reflow mobile host metrics](task-01-reflow-mobile-host-metrics.md) - sequential
|
||||
|
||||
No task is parallel-safe because component, unit, and E2E changes form one Red-Green regression path over the same responsive behavior.
|
||||
|
||||
## Risks and out of scope
|
||||
|
||||
- Auto-fit minimum cell width must yield two columns in the configured Pixel 5 viewport without forcing two columns below the legal content width. Geometry assertions should test relationships with a small subpixel tolerance, not frozen coordinates.
|
||||
- The E2E mutation of install-wide metrics settings must restore its baseline in `afterEach`, including after failure, because the backend is worker-scoped.
|
||||
- Desktop/tablet status-bar geometry, status-item ordering, metrics collection, metric definitions, persisted preferences, APIs, translations, and plugin contributions are unchanged.
|
||||
|
||||
## Verification Results
|
||||
|
||||
- Component RED: the added phone assertion failed on the fifth metric (`CPU temperature 71°C`); 1 failed and 7 passed.
|
||||
- Pixel 5 RED: the original renderer produced one occupied row instead of three; 1 failed and the existing simplified scenario passed.
|
||||
- Component GREEN: `pnpm --filter @kandev/web test -- components/system-metrics/status-surface-metrics.test.tsx` passed all 8 tests.
|
||||
- Mobile GREEN: a fresh production build completed, then `pnpm e2e:run --no-build --project mobile-chrome tests/settings/mobile-resource-metrics-display.spec.ts` passed both scenarios. The geometry regression observed five indicators in two columns and three rows with no internal or document overflow.
|
||||
- Static checks: `pnpm run typecheck` passed. Targeted ESLint passed with no findings.
|
||||
- Visual check: `/tmp/mobile-status-metrics-grid.png` was captured from the final Pixel 5 metrics section and inspected. It shows the Host line followed by a two-column, three-row grid with the final unpaired metric on the left and no clipping.
|
||||
- Cleanup: both Playwright scenarios completed their asserted `afterEach` restoration of user display settings, global metric settings, and app-status settings; the managed runner exited normally.
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: "01-reflow-mobile-host-metrics"
|
||||
title: "Reflow mobile host metrics"
|
||||
status: done
|
||||
wave: 1
|
||||
depends_on: []
|
||||
plan: "plan.md"
|
||||
spec: "../../specs/ui/app-status-bar.md"
|
||||
---
|
||||
|
||||
# Task 01: Reflow mobile host metrics
|
||||
|
||||
## Acceptance
|
||||
|
||||
1. The phone Status drawer renders every received host metric in enabled order through a width-aware grid; Pixel 5 uses two columns and adds rows as the count grows, with the detailed Host marker on its own leading line.
|
||||
2. Every metric indicator stays horizontally inside the grid and status item, no metric-specific horizontal scroll exists, and the drawer retains one safe-area-aware vertical scroll owner.
|
||||
3. Simplified-mode semantics remain intact, while desktop/tablet status bars and topbar fallback retain current inline layout, density limits, formatting, subscriptions, and tooltips.
|
||||
|
||||
## Inputs
|
||||
|
||||
- [App status bar What](../../specs/ui/app-status-bar.md#what), [responsive contract](../../specs/ui/app-status-bar.md#responsive-and-layout-contract), [accessibility](../../specs/ui/app-status-bar.md#accessibility), and [scenarios](../../specs/ui/app-status-bar.md#scenarios)
|
||||
- [Mobile Status metrics grid plan](plan.md), especially **Confirmed root cause**, **Presentation-specific metric layout**, and **Mobile design contract**
|
||||
- `apps/web/components/app-status-bar/app-status-drawer.tsx` for drawer geometry and scroll ownership
|
||||
- `apps/web/components/task/chat/messages/kandev/rich-output/metrics-block.tsx` for responsive metric-grid precedent
|
||||
|
||||
## TDD sequence
|
||||
|
||||
1. **RED:** extend `status-surface-metrics.test.tsx` with six ordered host samples. Prove the phone currently truncates after four and lacks the grid surface; retain a bar assertion that four remains its limit.
|
||||
2. **RED:** extend `mobile-resource-metrics-display.spec.ts` to enable all five supported host metrics and assert complete two-column/three-row Pixel 5 geometry plus metric-item containment. Confirm the current single-row renderer fails for the expected count/layout reason.
|
||||
3. **GREEN:** separate inline and grid `MetricValues` layouts, make the drawer consume every received host metric, and move the detailed Host marker above the grid without changing shared formatting or subscription logic.
|
||||
4. **REFACTOR:** keep presentation-specific classes at the drawer/bar boundary, reuse `MetricValue`, and avoid a second responsive state branch or scroll container.
|
||||
|
||||
## Files likely touched
|
||||
|
||||
- `apps/web/components/system-metrics/status-surface-metrics.tsx`
|
||||
- `apps/web/components/system-metrics/status-surface-metrics.test.tsx`
|
||||
- `apps/web/e2e/tests/settings/mobile-resource-metrics-display.spec.ts`
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Parallelism
|
||||
|
||||
`sequential`. Unit, implementation, and E2E changes share one responsive renderer and one global-settings fixture.
|
||||
|
||||
## Verification
|
||||
|
||||
```sh
|
||||
cd apps && \
|
||||
pnpm install --frozen-lockfile && \
|
||||
pnpm --filter @kandev/web test -- components/system-metrics/status-surface-metrics.test.tsx && \
|
||||
cd web && \
|
||||
pnpm run typecheck && \
|
||||
pnpm e2e:run --project mobile-chrome tests/settings/mobile-resource-metrics-display.spec.ts
|
||||
```
|
||||
|
||||
Confirm Playwright discovers the intended mobile spec/tests. Inspect the final Pixel 5 rendering or screenshot and record its artifact path; if visual capture cannot run, record the exact blocker. Record baseline restoration and any managed-runner cleanup evidence.
|
||||
|
||||
## Output contract
|
||||
|
||||
Return intent/acceptance, changed files, exact RED and GREEN commands/results with discovered test counts, Pixel 5 rendered evidence, settings restoration/cleanup evidence, blockers, risks, and synchronized task/plan statuses. Reconcile **Files likely touched** with the actual diff before marking done.
|
||||
|
||||
## Results
|
||||
|
||||
- Intent and acceptance met. The phone Status surface now claims the drawer row width, places the detailed Host marker above a responsive metric grid, and renders every received host metric. Desktop keeps its existing inline layout and density limit.
|
||||
- Changed production file: `apps/web/components/system-metrics/status-surface-metrics.tsx`.
|
||||
- Changed regression files: `apps/web/components/system-metrics/status-surface-metrics.test.tsx` and `apps/web/e2e/tests/settings/mobile-resource-metrics-display.spec.ts`.
|
||||
- Durable artifacts updated: `docs/specs/ui/app-status-bar.md`, this task, and `plan.md`.
|
||||
- RED component command: `cd apps && pnpm --filter @kandev/web test -- components/system-metrics/status-surface-metrics.test.tsx`. Result: 1 failed, 7 passed; the phone could not find `CPU temperature 71°C` because the drawer stopped after four metrics.
|
||||
- RED mobile command: `cd apps/web && pnpm e2e:run --no-build --project mobile-chrome tests/settings/mobile-resource-metrics-display.spec.ts`. Result: the new geometry scenario failed with one row instead of three while the existing simplified scenario passed. An intermediate run then exposed the auto-width root as 128 px, producing five single-cell rows, while its parent row was 353 px.
|
||||
- GREEN component command: `cd apps && pnpm --filter @kandev/web test -- components/system-metrics/status-surface-metrics.test.tsx`. Result: 1 file and all 8 tests passed, including all six received metrics in detailed and simplified phone rendering and the unchanged desktop four-metric limit.
|
||||
- GREEN mobile command: `cd apps/web && pnpm e2e:run --no-build --project mobile-chrome tests/settings/mobile-resource-metrics-display.spec.ts`. Result: both tests passed. The Pixel 5 regression found five enabled metrics in two columns and three occupied rows, all inside the grid, with `scrollWidth <= clientWidth`, one drawer vertical scroll owner, and no document overflow.
|
||||
- Additional checks: a fresh managed E2E production build completed; `cd apps/web && pnpm run typecheck` passed; targeted ESLint passed with no findings.
|
||||
- Rendered evidence: `/tmp/mobile-status-metrics-grid.png` was captured and inspected at Pixel 5 geometry. It shows the Host line plus the expected two-column/three-row layout without clipping.
|
||||
- Cleanup: the passing E2E `afterEach` assertions restored the baseline user metrics display, install-wide metric selection, and app-status settings. The managed runner exited normally. No blockers remain.
|
||||
@@ -4,7 +4,7 @@ system: ui
|
||||
requirements:
|
||||
- REQ-UI-APP-STATUS-BAR-001
|
||||
created: 2026-07-21
|
||||
updated: 2026-08-11
|
||||
updated: 2026-08-23
|
||||
owners:
|
||||
- kandev
|
||||
---
|
||||
@@ -33,8 +33,9 @@ Kandev has useful app-wide state, but it is scattered through route headers. A s
|
||||
- The portable **Show status bar** preference in Settings > Preferences > Appearance controls both general-purpose presentations and defaults off. Turning it on adds the desktop/tablet bar and ordinary phone Status entry points as soon as the shared Appearance save succeeds; no Kandev restart is required. An active [WebSocket connectivity warning](../requirements/ws-connectivity-warning.md) is the sole visibility exception: it uses problem-only fallback chrome and a connection-only phone drawer without mounting the bar, metrics, or plugin contributions. The preference changes visibility only; it does not stop connections, metrics collection requested by other clients, or plugin execution.
|
||||
- Built-ins are limited to Kandev-owned state:
|
||||
- Canonical connection state and error from `state.connection.status` / `state.connection.error`, with a restrained semantic dot, the connected detail **Connected to Kandev**, accessible text, and readable failure detail.
|
||||
- Existing Kandev-host CPU/memory metrics, preserving enabled-metric order, formatting, thresholds, limits, and tooltips. The built-in surface does not render active-task, active-session, or executor metrics.
|
||||
- Existing Kandev-host CPU/memory metrics, preserving enabled-metric order, formatting, thresholds, and tooltips. Desktop and tablet retain their density limits. The phone Status drawer renders every enabled host metric because its vertical surface does not need the bar's horizontal limit. The built-in surface does not render active-task, active-session, or executor metrics.
|
||||
- Resource metrics offer two persisted presentation styles. **Detailed** is the default and shows the host marker plus percentage meter bars. **Simplified** shows only each metric icon and formatted value, with no host marker or meter bars. The selected style applies consistently to the desktop/tablet bar, the pre-status-bar topbar fallback, and the phone Status drawer.
|
||||
- Phone metrics use a width-aware grid instead of one horizontal strip. The detailed Host marker occupies its own leading line, then the grid chooses the number of columns that fit the available row width, uses two columns in the configured Pixel 5 viewport, and adds vertical rows as indicators increase (six indicators form two columns by three rows there). Every indicator remains inside the metrics item without clipping or horizontal scrolling.
|
||||
- `userSettings.systemMetricsDisplay.showInTopbar` remains the persisted/wire compatibility key. User-visible copy calls this the Status bar setting; no migration or API break occurs.
|
||||
- Existing composer-local `ChatStatusBar` remains separate. Queue, PR, share, and next-step affordances stay with chat.
|
||||
- The connection indicator, complete metrics cluster, and each plugin component registration are individual status items. Holding Cmd on macOS or Ctrl on other platforms while dragging with the mouse reorders an item horizontally across the full bar, including across its flexible spacer.
|
||||
@@ -139,6 +140,7 @@ Visual interaction is a clean Kandev adaptation of Orca's public status-bar idea
|
||||
- **GIVEN** the detailed metrics style or no stored style preference, **WHEN** host metrics render in a status surface, **THEN** the host marker and percentage meter bars remain visible.
|
||||
- **GIVEN** the user selects **Simplified metrics** and saves Appearance settings, **WHEN** host metrics render in the desktop/tablet status bar or pre-status-bar topbar fallback, **THEN** each enabled metric shows its icon and formatted value without a host marker or percentage meter bar, and the choice survives reload.
|
||||
- **GIVEN** the simplified metrics preference, **WHEN** a phone user opens Status, **THEN** the metrics row shows the same icon-and-value presentation without a host marker or percentage meter bar.
|
||||
- **GIVEN** all host metrics are enabled on a phone, **WHEN** the user opens Status, **THEN** every host metric is visible in enabled order inside a width-aware grid; the configured Pixel 5 viewport uses two columns and additional metrics continue on later rows without widening the metrics item, drawer, or document.
|
||||
- **GIVEN** metrics preference disabled, or a phone Status drawer closed, **WHEN** the app runs, **THEN** no system-metrics WebSocket subscription is held by this feature.
|
||||
- **GIVEN** **Show status bar** is on for a phone user, **WHEN** they choose Status from a native entry point, **THEN** the drawer shows the same built-ins and plugin regions; dismissing it restores focus and leaves no persistent status bar.
|
||||
- **GIVEN** a user turns off **Show status bar** and saves Appearance, **WHEN** the save succeeds, **THEN** the bar/drawer and ordinary native Status triggers disappear immediately, remain absent after reload and on another client, and no restart is required.
|
||||
@@ -165,3 +167,4 @@ Visual interaction is a clean Kandev adaptation of Orca's public status-bar idea
|
||||
|
||||
- [Original App status bar plan](../../../plans/app-status-bar/plan.md)
|
||||
- [Status bar Appearance setting promotion plan](../../../plans/app-status-bar-appearance-setting/plan.md)
|
||||
- [Mobile Status metrics grid repair plan](../../../plans/mobile-status-metrics-grid/plan.md)
|
||||
|
||||
Reference in New Issue
Block a user