Skip to content

feat(newtab): one leader row with machine, direct-report attention and linear aggregation - #34101

Draft
teamleaderleo wants to merge 9 commits into
feat-cmux-nextfrom
probe/hq-6236-18-leaders-attention-20261103
Draft

teamleaderleo wants to merge 9 commits into
feat-cmux-nextfrom
probe/hq-6236-18-leaders-attention-20261103

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Brief 18 — one leader row with machine and attention, even at thousands of sessions

Source-backed follow-up to HQ #6236 brief 18 and the already merged Leads #32103 / duplicate-group cleanup #32107. Original base: feat-cmux-next@6c3fe3648ba4b44e7bf38c4982a665ec2d5d5712.

Problem / why this is a bounded change

The New Tab All view repeated a working leader in both Leads and Active. Leads displayed only a report count, leaving its machine and direct reports awaiting human input invisible. The TypeScript leaders() builder copied the entire accumulated report array for every new report, O(k²) for one large reporting group. HQ #4878 documents a real census of 3,055 sessions, including 38 streaming, so fan-out costs deserve attention.

Change

  • Keep the leader in Leads once and remove its same-machine duplicate from Active, while retaining other local/remote sessions with a coincidentally equal bare ID. Other filters still show active sessions.
  • Show the leader's known host/peer and Needs input (N) for itself plus direct reporters explicitly marked indicator: input. Preserve existing translations for report count and input label.
  • Keep peer on live-chat cards for identity-safe React keys and list deduplication.
  • Replace repeated report-array spreading with in-place append; row order stays stable.
  • Add targeted pure-model tests for host collisions, direct-report input, archived/closed exclusion, and a 3,000-report fan-out; add a DOM test for one lead row, location, attention and a same-bare-ID local chat.

Validation and evidence tier

Source change + authored tests; app test execution pending. This connector session has GitHub write access but no Bun/React app environment or approved live machine, so I did not claim a full web suite, signed build, or runtime capture. Run:

cd webviews
bun test src/agent-session/acpmux/leads.test.ts src/agent-session/acpmux/newtab/leaderCards.test.ts src/agent-session/acpmux/newtab/leadsList.test.tsx
bun run typecheck
../scripts/web-lint.sh

An isolated Node 22 synthetic 3,000-report fan-out benchmark (9 trials, median) improved from 5.617 ms with repeated spreads to 0.025 ms with appended arrays. This is a focused algorithm measurement, not a NEXT app CPU or wall-clock improvement claim. The meaningful verification is the web suite and a New Tab gallery/capture on the merged app head.

Boundaries / review requests

  • #32218 remains the native opening identity problem: onOpenSession calls chat.select({sessionId}) with the bare ID. Distinct React keys and deduplication prevent visual collisions here but do not solve wrong-chat opening between peers. Address with peer-qualified selection all the way through the host before promising safe cross-machine navigation.
  • lane.reportsTo derives local-daemon direct reporting only; remote-to-remote delegation, nested leadership and stale/disconnected peer status still need explicit coverage. Current Needs input count deliberately excludes errors and ambiguous offline signals.
  • This work does not touch group tidy, mutate live sidebar groups, change machine/account permissions or create Cloud VMs.
  • New Tab Leads appearance changed; request gallery before/after plus peer-collision and filtered-view review. Draft until checks and owner review.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the New Tab All view so each working leader appears once, in Leads, showing its machine and how many direct reports need input — previously leaders were duplicated in Leads and Active, and Leads showed only a report count. Also removes the O(k²) cost of accumulating large report groups in the leader builder.

Refactors

  • Leader rows are deduplicated by the owning machine; a chat with the same bare session ID on another machine stays visible in Active.
  • The leads builder appends to its report groups in place, preserving row order.

Written for commit ebd3696. Summary will update on new commits.

View guided diff Turn on auto-fix

Copy link
Copy Markdown
Collaborator Author

Reproducible synthetic report-fan-out benchmark (Node 22)

This is the isolated Map-bucket aggregation from leads.ts, with one leader and all reports on the same peer. It excludes normalization, React, transport, streaming, native rendering, and garbage collector behavior from a full app soak. Run with node brief18_lead_fanout_bench.mjs:

import { performance } from "node:perf_hooks";

const oldGather = (rows) => {
  const reports = new Map();
  for (const entry of rows) {
    const at = "huge-blue\\0leader";
    reports.set(at, [...(reports.get(at) ?? []), entry]);
  }
  return reports.get("huge-blue\\0leader");
};
const newGather = (rows) => {
  const reports = new Map();
  for (const entry of rows) {
    const at = "huge-blue\\0leader";
    const group = reports.get(at);
    if (group) group.push(entry);
    else reports.set(at, [entry]);
  }
  return reports.get("huge-blue\\0leader");
};
const median = (fn, rows) => {
  const times = [];
  for (let i = 0; i < 9; i++) {
    const start = performance.now();
    const out = fn(rows);
    const elapsed = performance.now() - start;
    if (out.length !== rows.length) throw new Error("lost reports");
    times.push(elapsed);
  }
  times.sort((a, b) => a - b);
  return times[4].toFixed(3);
};
for (const n of [1_000, 3_000, 10_000]) {
  const rows = Array.from({ length: n }, (_, i) => ({ sessionId: `lane-${i}` }));
  console.log(n, median(oldGather, rows), median(newGather, rows));
}

Observed medians on the isolated environment (ms):

Reports to one leader Repeated spread In-place append
1,000 1.555 0.074
3,000 5.617 0.025
10,000 80.573 0.090

All cases assert the output length; the committed leads.test.ts additionally checks the first and last report's order. Run independent Bun/DOM tests and app capture before making any product performance claim.

@blacksmith-sh

blacksmith-sh Bot commented Nov 3, 2026

Copy link
Copy Markdown

Found 4 test failures on Blacksmith runners:

Failures

Test View Logs
test/accent-glass-invariants-3.test.ts/accent-glass-invariants-3.test View Logs
test/accent-glass-invariants-3.test.ts/accent-glass-invariants-3.test View Logs
test/composer-menu-dismiss.test.ts/composer-menu-dismiss.test View Logs
test/composer-menu-dismiss.test.ts/composer-menu-dismiss.test View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Probably yours: accent-glass-invariants-3.test.ts fails here but not on main's latest full suite. Seen on other PRs too (likely flaky): composer-menu-dismiss.test.ts, composer-menu-dismiss.test.ts, composer-menu-dismiss.test.ts. CI was cancelled before it finished.

CI stopped on ebd369607f (run 41684285391 attempt 1): 1 code, 1 unknown.

Job Verdict Why
web / react-apps-base-check (4) code a web test failed
web / react-apps-check unknown no known signature; failed step: Check webview test shards

Failures:

  • new in this PR accent-glass-invariants-3.test.ts (unnamed): failed (job)
  • seen on other PRs composer-menu-dismiss.test.ts webkit: agent-pane.new-tab reasoning-chip at 760 px: with a menu open, one press on another chip ope...: failed (job)
  • seen on other PRs composer-menu-dismiss.test.ts webkit: agent-pane.new-tab reasoning-chip at 760 px: a press outside an open menu only closes it; no...: failed (job)
  • seen on other PRs composer-menu-dismiss.test.ts webkit: agent-pane.new-tab reasoning-chip at 300 px: a press outside an open menu only closes it; no...: failed (job)
Matched log lines
web / react-apps-base-check (4): (fail) (unnamed) [100297.75ms]

Not re-run automatically: web / react-apps-base-check (4), web / react-apps-check are not machine failures.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

red: web / Web status; a job it gathers is red on this change (its line here); do not merge until green; see lane-rules
red: web / react-apps-base-check (4); NEW webview test reds: test/composer-menu-dismiss.test.ts > (unnamed); test/reasoning-own-control.test.ts; do not merge until green; see lane-rules
red: web / react-apps-check; a job it gathers is red on this change (its line here); do not merge until green; see lane-rules

This branch was previously deployed

1 inactive deployment
ci-routing-agent — ebd36960 Deployed Nov 3, 2026 by teamleaderleo via wait for same-key tree publisher #107024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant