Repository navigation
fix(status): aggregate scoped component names and label zero-worker main thread as main - #3591
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the cross-thread status collection and aggregation logic to correctly handle scoped component names (e.g., @scope/app-a) and to ensure that the main thread is correctly identified as "main" (with an undefined worker index) even when running in zero-worker mode (setMainIsWorker is true). It introduces a helper function parseStatusKey to parse component names, thread labels, and public names, and updates the aggregation and request handler logic accordingly. Comprehensive unit tests are added to verify these behaviors. I have no feedback to provide as there are no review comments.
kriszyp
force-pushed
the
fix/status-thread-label-and-main
branch
from
October 27, 2026 14:11
6051b49 to
b8c71de
Compare
Use a shared parseStatusKey helper in components/status/crossThread.ts so StatusAggregator.aggregate splits on the last '@' rather than the first, keeping '@scope/pkg' component names intact instead of collapsing them under an empty-string key. Check isMainThread from node:worker_threads instead of getWorkerIndex() === undefined in CrossThreadStatusCollector and componentStatusRequestHandler so main-thread statuses stay labelled 'main' when threads.count is 0 (setMainIsWorker). Dispatch-Task: harper-status-thread-label-and-main Co-Authored-By: Gemini <noreply@google.com>
Share getLocalStatusOnly between collect() and the ITC-failure fallback, cover the worker-thread branch in unit tests, and restore prior setMainIsWorker state on teardown. Dispatch-Task: harper-status-thread-label-and-main Co-Authored-By: Gemini <noreply@google.com>
kriszyp
force-pushed
the
fix/status-thread-label-and-main
branch
from
October 27, 2026 22:36
b8c71de to
0661aa7
Compare
kriszyp
marked this pull request as ready for review
October 29, 2026 17:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⊙ Problem
@scope/app-a@main) collapse under the empty-string key""during status aggregation.StatusAggregator.aggregatesplits onindexOf('@')instead oflastIndexOf('@').get_statusmerges unrelated scoped components under"", andget_componentsreports{ status: 'unknown' }.threads.count: 0),setMainIsWorker(true)makesgetWorkerIndex()return0on the main thread, so main-thread component statuses are mislabelledworker-0instead ofmain.🤔 Why a shared parser and
isMainThread?Centralizing key parsing in one helper keeps component grouping, thread-label extraction, and abnormality normalization aligned on the last
@. CheckingisMainThreadfromnode:worker_threadsidentifies the main thread directly without changinggetWorkerIndex(), whichTable.tsrelies on for TTL ownership.💡 Solution
Parse
@<threadLabel>suffixes through a sharedparseStatusKeyhelper usinglastIndexOf('@'). CheckisMainThreadinCrossThreadStatusCollectorandcomponentStatusRequestHandler. In zero-worker mode (threads.count: 0),get_componentsandget_statusnow report main-thread status timestamps underlastChecked.main(withlastChecked.workersempty). They key main-thread abnormalities as<component>@maininstead of<component>@worker-0.🔧 Changes
components/status/crossThread.ts: ReplacestripThreadIdentityand the three separate@splits (StatusAggregator.aggregate,aggregateComponentGroup, and abnormality recording) withparseStatusKey(statusKey).components/status/crossThread.tsandserver/itc/serverHandlers.ts: UseisMainThreadfromnode:worker_threadsinCrossThreadStatusCollector.getLocalStatusOnly(shared bycollect()and the ITC-failure fallback) and incomponentStatusRequestHandler.unitTests/components/status/crossThread.test.jsandunitTests/server/itc/serverHandlers.test.js: Add regression tests for@-scoped component aggregation and zero-worker main-thread status labelling.✅ Verification
origin/mainsources before the fix (36 passing, 3 failing).npm run build) and rannpx mocha unitTests/components/status/*.test.js unitTests/server/status/*.test.js unitTests/server/itc/*.test.js(246 passing).npm run lintandnpm run typecheck.PR QA: none — surgical status-key parsing and thread-label check covered by unit tests
Author: Gemini (gemini-4-argon-high)
Release target: main — status-correctness fix for the next minor; no patch backport needed
Related PRs: #3439 overlaps, #2155 independent
Origin — the dispatch brief this PR was written from
components/status/crossThread.ts: (1) StatusAggregator.aggregate strips the @ suffix with indexOf('@') while the other two sites use lastIndexOf('@'), so scoped component names (@scope/app-a@main) aggregate under '' / truncated keys; use one shared stripping helper for all three sites. (2) In zero-worker mode (threads.count: 0) main-thread component statuses are labelled worker-0, because getWorkerIndex() (0 on the main thread) is used to pick the 'main' label in crossThread.ts and server/itc/serverHandlers.ts: use an explicit main-thread check. Leave warning/loading ranking to open PR #3439.
Acceptance
Tests: @scope/app-a@main, @scope/app-a.rest@main and @scope/app-b@worker-0 aggregate to their own names with no '' key; with threads.count: 0, main-thread statuses are labelled main. Show each new test failing on origin/main sources (forced rebuild) before the fix.
Dispatch: task
harper-status-thread-label-and-main· queued by finding-triage/wave-40 · ran by gemini/gemini-4-argon-high/low · worker kzyp-xps-1Review-Coverage: authored=claude; ran=cursor-composer,codex,gemini; adjudicated=domain; declined=cursor-grok,muse; rounds=5; full=3 @ 0661aa7
Review-Attention: read ~3m (decisions: physical-thread-identity-for-main-label, test-seam-parameter) @ 0661aa7