Skip to content

refactor: split the security and remote crew panels into owners - #21592

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-f06-securitypanel
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-f06-securitypanel

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: SecurityPanel.tsx and RemoteCrewPanel.tsx each drop under the 2,000-line file cap, with unchanged behaviour, by moving their parts into owner modules beside them.

The two Settings panels are 3,503 and 2,938 lines, among the largest hand-written files in website/. The campaign rule in #20192 caps a hand-written file at 2,000 lines, and the Remote Crew panel gets regular feature work (seven commits in the last week).

Why it matters

A panel this size is where merge conflicts and missed side effects collect: the Security panel's eleven sections (approval, denied commands, governance, trust grants, redaction, ...) share one 3,500-line file, so a change to one section's card sits in the same diff hunk space as every other. Giving each section one module that new work for it goes to keeps the panels reviewable and keeps the line-cap guard satisfied.

Not a goal

  • Any behaviour, layout, styling or wording change. Bodies move verbatim.
  • Refactoring the moved code, or decomposing the 1,442-line RemoteCrewPanel component itself (it moves nowhere; only its helpers and child components leave the file).
  • Splitting the panels' existing tests.

What changed (motivation → approach → change)

Each panel stays its own facade: the same module id and every named export, so SettingsPage.tsx, the story, the captures and every vi.mock('.../SecurityPanel') work unchanged. Whole top-level declarations move into sibling owners, one per rail group of the Security panel and one per part of the Remote Crew panel; owners never import a facade, and nothing but a panel's own specs imports an owner. A recipe script performs the whole move from BASE by declaration name, never line numbers, so moved bodies are byte-identical; each component moves whole, so every hook registers in BASE order.

Panel Lines Owners beside it
SecurityPanel.tsx 3,503 → 331 SecurityPanelPosture.tsx (Live security posture, status row/chip) · SecurityPanelApprovals.tsx (auto-approve duration, flagged-file delivery consent) · SecurityPanelDeniedCommands.tsx (built-in and custom deny rules) · SecurityPanelTailnet.tsx (tailnet origin) · SecurityPanelTrust.tsx (third-party app and registry trust grants) · SecurityPanelRedaction.tsx (credential-redaction switch, allowed hosts) · SecurityPanelLayers.tsx (defense-in-depth registry) · SecurityPanelGovernance.tsx (governance-policy viewer)
RemoteCrewPanel.tsx 2,938 → 1,562 remoteCrewPanelModel.ts (launch-job predicates, size tiers, remembered keys) · RemoteCrewPanelLaunch.tsx (setup-tab cards, progress card, sign-in block) · RemoteCrewPanelCrewRow.tsx (one crew row, turn-API URL field)

The Security facade keeps the rail (SECURITY_SECTIONS, SECTION_LABEL_KEY, which gen-ui-index.mjs reads from this file, the rail summaries) and the Documentation section (docs_lint's CODE_COUPLED_DOCS names this file). The rows and pins keyed on the old paths follow the code (granted PANEL_TAB_MAP rows, bare-control accounting, the restyle-ratchet entry, three re-pointed or joined source pins, docs). A new <Panel>.owners.test.tsx per facade pins the export set, its identity with the owners, and the import edges.

Backwards compatibility

Compatible: both facades keep their paths and every named export (SecurityPanel, RedactionSection, RedactionAllowedHostsCard, SECTION_LABEL_KEY, SECTION_GROUP_KEY, FEATURE_LABEL_KEY, FEATURE_DESCRIPTION_KEY, SCOPE_LABEL_KEY, GOV_PLANE_TITLE_KEY, humaniseScopeLeaf, trustFailureMessage, registryTrustFailureMessage; RemoteCrewPanel, TurnUrlField), each the very binding its owner defines; *.owners.test.tsx pins the export set and the identity.
Removes nothing: the moved code is reachable through the same import paths, and no export, route, React Query key, test id, i18n key or settings-registry id changes (settingsRegistry.gen.ts and settings-registry.generated.json regenerate byte-identical).

Tests

New

  • src/pages/settings/SecurityPanel.owners.test.tsx, src/pages/settings/RemoteCrewPanel.owners.test.tsx: the owner set, every sibling the facade imports under its name is in the family, the facade's export set and that each moved export is the owner's own binding, owners never import the facade, nothing outside the panel imports an owner, plus a self-test of the import reader.

Re-pointed or joined (assertion text unchanged; each proven by a mutation in the construct's new home, red, then restored)

  • test/test_cloud_sizes_ui_parity.py: PANEL reads remoteCrewPanelModel.ts, where SIZE_TIERS/X86_TIERS live (L30). Light tier vcpu 4 → 5 there turns test_panel_tier_matches_sizes_py[light] red.
  • src/test/hoverVariantPolicy.test.ts: the DECORATIVE row names pages/settings/SecurityPanelPosture.tsx, StatusRow's new home. Changing the glyph's size={11} there turns two cases red.
  • src/test/settingsCoverage.test.ts: the WAIVED_BARE_CONTROLS rows for both panels are split per owner. The counts sum to BASE and the reasons are BASE's, split. One extra <Toggle in SecurityPanelTailnet.tsx turns the accounting red.
  • website/scripts/settingsExtract.ts PANEL_TAB_MAP (granted): 8 rows map SecurityPanel*.tsx → security and 2 rows map RemoteCrewPanel{Launch,CrewRow}.tsx → instances. Dropping the Redaction row turns "every panel file is mapped" and "every manual entry's labelKey appears in a panel file mapped to its tab" red. Dropping the CrewRow row turns the first red.
  • src/uiLocations/autoGuide.test.ts: the negative "no auto-guide stamp in the Security tab's files" regex reads SecurityPanel[A-Za-z]*, the facade plus every owner (L40(8) join). With the Security tab dropped from TRUST_ROOT_PARENTS and the parent_ids loop removed, so that only the regex can catch it, the joined regex goes red on a stamp in SecurityPanelApprovals.tsx. The BASE exact-name regex passes blind under the same mutation.
  • website/scripts/restyle-baseline.json: the 14 shadcn/no-restyle sites are all CrewRow menu items, so the entry moves to RemoteCrewPanelCrewRow.tsx. Putting the 14 back on RemoteCrewPanel.tsx turns the ratchet red twice: shrunk, and an unlisted file.

The table and logs are in the scope's mutations.md. Every pin is green again after the mutation is restored.

Runs (local, gate_slot)

  • tsc -p tsconfig.app.json 0. eslint src/ --max-warnings 0 0. jscpd . found 0 clones.
  • vitest: 524 spec files, 14,027 tests passed. The set is run_scoped_tests.py's 377 related files plus every pages/settings, i18n, uiLocations and command-palette spec and the tree-scanning ratchets. The three new specs pass 5 times in shuffled order, once with 3 workers, and 3 times under KIROCREW_ACT_STRICT=1 with no act() warning (the layers spec waits for the section heading before it asserts). The act() warnings printed came from unrelated, load-sensitive specs (GuideLayer, ChatSidebar folder settings, KiroSignInNotice, CompactionCard, OnboardingFlow), none of which renders these panels.
  • Per-file line coverage of the split files over those specs: SecurityPanelDeniedCommands.tsx 86.9%, SecurityPanelApprovals.tsx 91.4%, SecurityPanelTrust.tsx 92.6%, SecurityPanel.tsx 93.9%, SecurityPanelTailnet.tsx 95.8%, SecurityPanelGovernance.tsx 96.2%, remoteCrewPanelModel.ts 96.7%, SecurityPanelRedaction.tsx 96.9%, RemoteCrewPanel.tsx 97.0%, RemoteCrewPanelCrewRow.tsx 97.6%, RemoteCrewPanelLaunch.tsx 98.2%, SecurityPanelPosture.tsx 100%, and SecurityPanelLayers.tsx 100% with the new layers spec (30% without it).
  • I18N_BASE_REF=<base> npm run i18n:check: every row PASS, with 0 literals and 0 number+unit literals on added lines. The one dynamic key site (i18nT(tipKey)) moved from SecurityPanel.tsx to SecurityPanelGovernance.tsx, and the dynamic total is unchanged.
  • Restyle ratchet: every file matches. gen-ui-index.mjs --check: up to date. The settings registry regenerates byte-identical (247 entries, 21 dynamic labels skipped, cmp clean on both artifacts). Phantom classes and focus cue: 0.
  • Hook order (L40): every BASE function's use* sequence is identical at HEAD, 76 calls in 13 SecurityPanel functions and 80 calls in 4 RemoteCrewPanel functions.
  • Brand, comment-history, harness-parity and feature-map checks: 0. docs_lint.py: 0. check_file_line_cap.py: 0 failures.
  • semgrep 1.78 with CI's packs and semgrep/, over the changed source and test files: 0 findings. Its TS parser partial-parses hoverVariantPolicy.test.ts:141 (a labelled tuple type), as it already did at BASE.
  • Backend: pytest -n 3 over the files that read the edited baselines, docs, registries and the parity test: 614 passed. test_flake_pattern_ratchet.py: 58 passed.
  • scripts/local-gate.py --dry-run selects 894 backend + 377 frontend files, over the ~600 limit, so the floor above ran instead; CI owns the broad matrix.

Manual verification

N/A — unit coverage sufficient: the change is a verbatim move proven by the move audit and the hook-order check below, and the panels' own specs (which render every section) run unmodified against the composed facades.

Screenshots / video

Why no screenshot: markup, classes and text move verbatim into owner components, so every Settings ▸ Security and Settings ▸ Remote Crew surface renders byte-identical DOM.

Move audit

  • website/src/pages/settings/SecurityPanel.tsx: 3503 → 331 lines. 3,068 removed non-blank lines; 3,045 of them are found unchanged in the new files (99.25%). The 23 unmatched are glue: 5 pruned import lines, 16 declarations that gain export, and the 2 pointer-comment lines below.
  • website/src/pages/settings/RemoteCrewPanel.tsx: 2938 → 1562 lines. 1,362 removed non-blank lines; 1,330 found unchanged (97.65%). The 32 unmatched are 3 pruned import lines and 29 declarations that gain export.

Lines that changed inside moved code:

  • export on the declarations another file now imports.
  • Two comments that pointed into the old file now name the owner: PINNED_TOOLTIP_KEY's "for the reason above" names FEATURE_LABEL_KEY (SecurityPanelLayers.tsx), and DISTRIBUTION_REFRESH_KEY's "TAILNET_STATE_KEY above" names SecurityPanelTailnet.tsx.
  • BASE comments whose neighbour moved stay with the declaration they describe. The governance viewer's one-line doc moves from above KirocrewCfgShape to GovernancePolicyViewer, and the "Security tab. basePath …" doc stays above SecurityPanel in the facade instead of leaving with RedactionSection. The NOTE on why the plugin install command is not hardcoded, which leads SizeCard at BASE, stays right after the launch constant it follows at BASE (PRICING_CALCULATOR_URL) in remoteCrewPanelModel.ts.

Added to the facades: the new docstring of SecurityPanel.tsx, which names the owners, and one paragraph in RemoteCrewPanel.tsx's docstring.

Diff alignment (L36): git's default diff and --minimal give an identical git diff --numstat for all 30 changed files (SecurityPanel.tsx +39/−3,211, RemoteCrewPanel.tsx +18/−1,394). The whole diff is 599,617 bytes.

CI path references

None: no workflow path filter, AUTOSDE.yaml glob or sensitive-change glob names these files.

Shared rows: both targets' rows leave .github/file-line-cap-baseline.txt (each now ends under 2,000 lines). website/scripts/restyle-baseline.json moves the Remote Crew panel's 14 shadcn/no-restyle findings, all CrewRow menu items, to RemoteCrewPanelCrewRow.tsx (the sum stays 14).
Prose citations corrected (L29): website/src/components/commandPalette/settingsManual.ts (the section owners carry the data-setting-label anchors), website/scripts/i18n-plural-codemod.mjs (the nRules site is in SecurityPanelGovernance.tsx), and docs/request-for-change/rfc-outbound-instance-transport.md and docs/request-for-change/plans/2026-09-23-outbound-instance-transport.md (connectionTypeLabel / connectionTypeHint are in RemoteCrewPanelCrewRow.tsx). Docs (SD27): docs/feature-map/README.md (six rows), docs/system-specs/modules/instances.md (coordsOf(), TurnUrlField) and the new owner map in website/docs/frontend-conventions.md.

References not edited (cost): src/kiro_crew/dashboard/handlers_instances.py:129 names coordsOf() in RemoteCrewPanel.tsx; it now lives in RemoteCrewPanelCrewRow.tsx. That file is another open split's target, so the citation is fixed after that split lands.

Related Issues

Part of #20192
Follow-up: #21320 (the deferred coordsOf() comment citation above)

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 10:21
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of f2f48a45897490a26f23f6ef5a786007c3349a4b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Nothing to check.

[UX-REVIEWED] f2f48a4

Description read

[DESCRIPTION-READ] 514a33ca60485e36291cc5e30c2c383de1305ce31b81192f4d8b11e0f62d54cd

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f2f48a45897490a26f23f6ef5a786007c3349a4b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Before merge, check that untranslated-baseline.json's 7-template ceiling for SecurityPanel.tsx still matches the facade now that its bodies live in the owner files.

[DESIGN-REVIEWED] f2f48a4

Description read

[DESCRIPTION-READ] b6af9a8965aeb21e65e75cfb602ea592c42ae345d0cbf360f6ec8b11e2099fd6

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f2f48a45897490a26f23f6ef5a786007c3349a4b — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check that CI regenerates settingsRegistry.gen.ts byte-for-byte. Only that shows every Security and Remote Crew search anchor survived the split.

What this change ships

Inventory (9 items) — 9 justified

Intent: a maintainer wants the two oversized Settings panels under the 2,000-line cap with no behaviour change. This is a REFACTOR (neither a FIX nor an ADDITION).

  1. Security panel sections move whole into eight sibling owner modules; the facade keeps its path and exports — justified
  2. Remote Crew helpers, launch cards and crew row move into three owners; the panel component stays — justified
  3. Both panels leave .github/file-line-cap-baseline.txt — justified
  4. PANEL_TAB_MAP maps each owner to its facade's settings tab — justified
  5. Source pins re-pointed to the code's new home (sizes parity, hover policy, bare-control waivers, auto-guide regex, restyle baseline) — justified
  6. New *.owners.test.tsx per facade pins the export set and import edges — justified
  7. New SecurityPanel.layers.test.tsx lifts the new SecurityPanelLayers.tsx from 30% coverage — justified
  8. Path references updated in specs, RFC, plan, feature map and two code comments — justified
  9. A frontend-conventions.md section lists each owner and what it holds — justified

[FIRST-PRINCIPLES-REVIEWED] f2f48a4

Description read

[DESCRIPTION-READ] 27160b28091719b060e3db1a9c8f6d61eec86cae5fda3066637b023e04f91ea6

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f2f48a45897490a26f23f6ef5a786007c3349a4b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f2f48a4

Verdict parsed from the review's SHA-scoped output markers for commit f2f48a45897490a26f23f6ef5a786007c3349a4b.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f2f48a45897490a26f23f6ef5a786007c3349a4b: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f2f48a45897490a26f23f6ef5a786007c3349a4b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f2f48a4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f2f48a45897490a26f23f6ef5a786007c3349a4b: <one-sentence reason>

@bolichen97
bolichen97 enabled auto-merge (squash) October 17, 2026 10:35
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • PASS punchline: the 7-template untranslated ceiling for SecurityPanel.tsx

Checked: the strict i18n eslint pass (eslint.i18n.strict.config.js, the one check-i18n-strings.mjs runs) reports 0 untranslated literals in SecurityPanel.tsx already at BASE, so the 7-template row is a stale ceiling, not 7 live strings that moved.
No owner carries a finding: I18N_BASE_REF=<base> npm run i18n:check is PASS on [added-lines] (0 literals on added lines) and [vs-base] (0 touched files worse than base), and the facade dropping under its ceiling is report-only.
The one dynamic key site, i18nT(tipKey), moved verbatim to SecurityPanelGovernance.tsx; the dynamic-site total is unchanged.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • PASS punchline: settingsRegistry.gen.ts regenerates byte-identical with the ten new PANEL_TAB_MAP rows

Checked: the generator's own extractAll/generateRegistrySource/generateAgentRegistryJson, run over panelRoots on this tree, reproduce settingsRegistry.gen.ts and src/kiro_crew/docs/settings-registry.generated.json byte for byte (247 entries, 21 dynamic labels skipped; cmp clean on both).
In CI the same claim is the settingsRegistry.test.ts anti-stale guard (live extraction deep-equals the committed registry and byte-equals the agent JSON), which runs in the frontend shards.
The mapping matters: dropping the Redaction or CrewRow row turns settingsCoverage red (mutation proofs M4/M5 in the PR body).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 17, 2026
SecurityPanel.tsx (3,503 lines) and RemoteCrewPanel.tsx (2,938) exceed
the 2,000-line cap for hand-written files. Whole top-level declarations
move verbatim into sibling owners in pages/settings, and each original
file stays the facade: same module id, every named export re-exported
as the owner's own binding, so SettingsPage, the story, the captures
and every vi.mock of a panel keep working unchanged.

SecurityPanel.tsx (331 lines) keeps the rail and the Documentation
section; each other section gets one owner: Posture, Approvals
(auto-approve, flagged-file delivery), DeniedCommands, Tailnet, Trust
(third-party apps, registries), Redaction, Layers and Governance.
RemoteCrewPanel.tsx (1,562 lines) keeps the panel component whole;
remoteCrewPanelModel.ts holds the launch-job predicates and size tiers,
RemoteCrewPanelLaunch.tsx the setup-tab cards and sign-in block,
RemoteCrewPanelCrewRow.tsx one crew row.

The rows and pins keyed on the old paths follow the code: granted
PANEL_TAB_MAP rows, the bare-control accounting, the restyle-ratchet
entry, the cloud-sizes parity test, the hover-variant DECORATIVE row,
the auto-guide stamp regex (joined over the owner family), the
line-cap baseline rows, the feature map, the instances spec cites and
an owner map in frontend-conventions.md. New owners specs pin the
export set and the import edges; a layers spec covers the one owner
no existing spec rendered.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-f06-securitypanel branch from 0b0039f to f2f48a4 Compare October 17, 2026 17:31
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main bb58b09 (supersedes head 0b0039f): main now carries #21581, which fixes the four checks that were red on the previous head (the katex golden, the codex-acp real-adapter test, the PyJWT teams pin, and the coverage merge that follows them). Context-only rebase: the change's -U0 patch is identical, and the recipe ports #21419/#21568 into their facade-kept lines unchanged. CI re-running.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • PASS punchline: the 7-template untranslated ceiling for SecurityPanel.tsx

Checked at this head: the strict i18n pass (eslint.i18n.strict.config.js) finds 0 untranslated literals in SecurityPanel.tsx and in every owner, the same 0 the file had at BASE, so the 7-template row was already a stale ceiling.
i18n:check is PASS on [added-lines] and [vs-base] (0 literals on added lines, 0 touched files worse than base); a facade under its ceiling is report-only, and no owner needs a row.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • PASS punchline: CI regenerates settingsRegistry.gen.ts byte-for-byte

On this head the frontend shards ran settingsRegistry.test.ts green: its anti-stale guard deep-equals the live extraction (extractAll over panelRoots, with the ten new PANEL_TAB_MAP owner rows) against the committed registry and byte-equals the agent JSON.
Locally the generator's own functions reproduce both artifacts byte for byte (247 entries, 21 dynamic labels skipped), and settingsCoverage's manual-anchor check passes, so every Security and Remote Crew search anchor is still found in a file mapped to its tab.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 17, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: readiness: passed, all checks green, mergeable, no changes requested.

@bolichen97
bolichen97 merged commit e0fed6d into main Oct 18, 2026
104 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-f06-securitypanel branch October 18, 2026 00:29
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants