Skip to content

ui-react: the hygiene card's state copy describes a file edit for a managed-worktree finding #2837

Closed

Description

@schlessera

Context

#2431 puts host-only managed-worktree findings into the hygiene review. Their path is the logical reference-worktree://<worktree id>, and their one repair removes a worktree; nothing is written to a brain file (docs/decisions/managed-worktrees.md#hygiene-and-cleanup).

While fixing #2723 (the card no longer offers "Open file ›" for such a finding), the pinned browser captures of a worktree card showed that the card's state copy still describes a Markdown file edit:

  • postCheck reads "Then re-runs validation on this file." for any non-broken-link repair, including delete-worktree (postCheck=, packages/ui-react/src/components/activity/hygiene-review.tsx:842-848).
  • A failed removal reaches the card as check_failed and reads "The change was written, but the check still fails: cleanup-failed." (stateText, packages/ui-kit/src/decisions/HygieneCard.tsx:54). Nothing was written.
  • stale reads "This file changed since the finding was shown." and refused reads "Couldn't write reference-worktree://…" (packages/ui-kit/src/decisions/HygieneCard.tsx:50-52).
  • fixed reads "Finding no longer detected in reference-worktree://…" (packages/ui-kit/src/decisions/HygieneCard.tsx:75).
  • An unknown worktree finding has no repair, so its commit button reads "Done, check again" (packages/ui-react/src/components/activity/hygiene-review.tsx:850), although the user has nothing to edit; the host's explanation says "Check again later."

Observed in the ui-react-layout captures for hygiene-review.layout.tsx, both themes, 320 and 1280.

The maintainer has approved caller-supplied display copy and the corrected worktree wording below. Related: #2734 (owner-only detail view), which does not cover this copy.

Scope and maintainer decision (2026-10-24)

Option A selected: extend the presentational HygieneCard with optional caller-supplied inert state/status, busy and fixed-outcome copy. Preserve existing file defaults and meanings. The feature layer selects copy from actual action/outcome evidence; do not add worktree-domain branching or a finding-kind prop to the generic kit. Exact prop names are implementation design, not preapproved here. This is an additive public-prop change.

The maintainer approved the corrected copy direction:

  • No-repair commit action: Check again.
  • Check explanation: Checks its current state. A worktree verified clean and unused may be reclaimed automatically.
  • Confirmed removal: Worktree removed.
  • Finding cleared without confirmed removal: No longer needs review.
  • Uncertain reply: The outcome wasn't confirmed. Check again.
  • Other states describe the actual worktree checking/removal stage, preserve opaque inert reasons, and make no unsupported nothing-changed or nothing-removed claim. No Markdown-write, file-validation or real-file-URI wording.
  • There is no Undo state for this category; the caller must not select undone copy. Existing file copy, state machine, interaction, confirmation, focus and announcement behavior stay unchanged.

The earlier design brief is useful for layout and tests, but its claim that check-only reassessment never removes anything is superseded. Source evidence: run(check) calls reassess with remove:true (reference-worktree-hygiene.ts); reassess may invoke automatic removal only when fresh assessment proves a clean, unheld worktree (reference-worktrees.ts). A sent action alone is not proof of removal. Choose Worktree removed only with confirmed outcome evidence; otherwise use the finding-cleared text. Never infer nothing was removed from a reassessment or an uncertain/failed reply. No server policy or outcome-shape change is authorized.

Implement the complete worktree state/post-check and check-only copy under these rules; supplied display values are inert strings with safe wrapping, never callbacks, Markdown or new authority. Optional-copy omissions must preserve every current file default, including busy/fixed rendering.

Out of scope

The Open action (#2723), the owner-only detail view (#2734), server finding or outcome shapes, and Markdown finding copy.

Acceptance criteria

  • Implement the approved optional caller-copy boundary and exact action, check-explanation, confirmed-removal, cleared-finding and uncertain-reply strings above. Cover every remaining worktree state with truthful operation-specific copy and preserved opaque reasons; no claim of absence of effects without evidence.
  • Managed-worktree states make only supported outcome claims: no Markdown write, no file-validation promise, no reference-worktree URI presented as a real file. Unknown work/check outcome remains unknown; failure does not imply data was removed.
  • No-repair findings offer Check again with the approved explanation that freshly verified clean, unused worktrees may be reclaimed; never promise reassessment cannot remove anything or imply a user file edit. Existing Apply/Later/Dismiss, confirmation, idempotency and recovery behavior remain unchanged.
  • Pinned native browser scenes cover every affected state at 320px and desktop, both themes, keyboard focus and long inert values, with a failing-first assertion and a mutation that restores generic file wording. Existing Markdown-finding scenes and the no-Open-file behavior from ui-react: the hygiene card opens a nonexistent file for a managed-worktree finding #2723 remain unchanged.
  • Owner-only detail remains ui-server: owner-only detail view for private managed-worktree hygiene findings #2734; replicated worktree cards stay opaque and no new owner/private detail leaks into copy.

Verification

Pinned browser proof in packages/ui-react/tests/browser/hygiene-review.layout.tsx once scoped.

Contract impact

Approved additive optional inert display-data props with existing file defaults and meanings preserved. Retain contract, use a CONTRACT: commit, update the package contract and API report in the same commit, and ship a minor changeset. Record the selected boundary/corrected worktree copy policy in the applicable decision record. No breaking file semantics, host outcome changes or new cleanup authority is approved.

2026-10-24 triage at main 77f35ef1ba34e4fab7092ada5362ae799852ea24: Completed the UX scope, exact kit-API options/consequences and checkable proof/privacy criteria. Attached the full managed-worktree review-copy deliverable to #2390; p2 is wanted unscheduled correctness work. The current file-state wording is source-verified, but no replacement copy, public API or UX is approved. A self-contained design prompt follows.

2026-10-24 triage reconciliation: priority p1 appeared concurrently with this pass's p2 classification. Preserve the newer higher priority and remove only p2 so exactly one priority remains. This supersedes the earlier unscheduled-p2 note; the outstanding design/API decisions, native #2390 parent and every other label remain. No milestone is invented by this correction.

2026-10-24 maintainer ruling: approved A with corrected copy, including possible automatic reclamation during reassessment, evidence-based confirmed-removal text, neutral cleared/uncertain outcomes and no Undo. The API and copy-direction prerequisites are resolved; implementation and browser proof remain. Preserve the already-recorded higher p1 and remove duplicate p2.

Activity

  1. added
    type: fix
    area: ui-react
    area: ui-kit
    priority: p2
    needs: design
    needs: decision
    contract
    on Oct 24, 2026
  2. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    2026-10-24 triage at main 77f35ef1ba34e4fab7092ada5362ae799852ea24: Completed the UX scope, exact kit-API options/consequences and checkable proof/privacy criteria. Attached the full managed-worktree review-copy deliverable to #2390; p2 is wanted unscheduled correctness work. The current file-state wording is source-verified, but no replacement copy, public API or UX is approved. A self-contained design prompt follows.

    Needs design: truthful state and check-only copy for managed-worktree hygiene. The host finding, private-card opacity, confirmed cleanup and no-file-Open behavior are settled. The missing judgment is the wording the owner reads at each outcome and on a finding with no repair; generic file-edit copy is false here. The separate public kit API question in the body remains a maintainer decision, not something this prompt approves.

    Design the managed-worktree hygiene card state copy for brain-kit #2837 under #2390. Do not implement it or change host outcome shapes.
    
    Read first at main 77f35ef1ba34e4fab7092ada5362ae799852ea24:
    - #2837's scope, two API options and exclusions; #2390's outcome; delivered #2431 findings/cleanup and #2723/#2838 no-file-Open fix. #2734 separately owns owner-only details and has no approved detail interaction yet.
    - HygieneCardProps, packages/ui-kit/src/decisions/HygieneCard.tsx:10-39; stateText and fixed outcome rendering in that file:46-77. Current defaults describe checking/writing a file and place the logical reference-worktree URI in file copy.
    - postCheck and commit labels, packages/ui-react/src/components/activity/hygiene-review.tsx:845-856. delete-worktree currently receives the generic validation sentence; a no-repair finding receives Done, check again.
    - docs/decisions/managed-worktrees.md, Hygiene and cleanup; docs/decisions/reference-worktrees.md, Explicit activity, safe cleanup and hygiene; docs/decisions/hygiene-review.md, identity/fingerprint/revalidation and durable dispositions; docs/decisions/async-collaboration.md, confirmed effects and uncertain recovery.
    - docs/decisions/design-kit/components-and-interactions.md and tokens-and-styles.md, existing HygieneCard/ActionCard, effective 44px targets, focus and inert untrusted text. docs/decisions/example-corpus.md binds Odysseus fixtures, 2026-07-12. docs/decisions/contract-versioning.md governs the separate supported-prop decision.
    
    Problem:
    A managed-worktree finding is operational host state. Its repair removes a worktree, and an unknown-state finding has no repair; neither writes a Markdown file. Yet the card says the change was written or that validation will run on this file. Design the smallest truthful correction using facts the current finding/outcome actually supplies.
    
    Settled:
    - Keep Apply/Later/Dismiss, removal confirmation, stable finding identity, fingerprints, stale/refusal and uncertain-effect recovery semantics. Opening or checking must not imply deletion happened.
    - Private findings' replicated card, list, preview and outcomes remain opaque. Do not add repository, commit, real path or principal details; #2734 owns its separate owner-authorized surface.
    - No Open file action for a managed-worktree finding; #2723 has delivered that behavior. Existing Markdown-finding wording and navigation are out of scope.
    - The body presents optional caller copy versus a kit finding-kind prop as unapproved API options. Supply inert display content and required facts, without inventing field names or selecting a public interface.
    
    Design:
    1. Give exact status/post-check text for applying, stale, refused, cleanup/check failure, unknown reply, still detected, fixed and undone if it can actually occur here. Name any impossible state rather than inventing it. Separate successful removal from successful reassessment without removal.
    2. Give the check-only action label and explanation when work state is unknown and no repair is offered. It must not ask the user to edit a file or imply unknown means empty/safe to remove.
    3. Define safe handling of reason/code strings, logical identifiers, long inert text and unavailable facts. Show no unsupported promise that nothing changed after an uncertain or failed operation.
    4. Preserve announcement cadence, status tone, keyboard focus/return, no double application, Escape/confirmation behavior and 44px targets at 320px and desktop in both themes. Do not redesign the card or add navigation, shortcuts or a new state machine.
    5. List the native browser assertions per state, the existing file-scene controls, and a mutation restoring generic file wording that each changed assertion can catch.
    
    Deliverable:
    A proposed design comment on #2837 with a complete state/copy table, exact check-only/post-check labels, 320px and desktop ASCII mocks, focus/announcement rules and checkable browser criteria. Mark unsupported host facts and API dependencies explicitly for the maintainer. A small wording-only treatment is acceptable if all outcomes remain honest; a documented no for a proposed state needs evidence. Approval and the separate API ruling are required before this becomes implementation-ready.
    
  3. added
    priority: p1
    on Oct 24, 2026
  4. added this to the 0.44.0 milestone on Oct 24, 2026
  5. removed
    priority: p2
    on Oct 24, 2026
  6. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    2026-10-24 triage reconciliation: priority p1 appeared concurrently with this pass's p2 classification. Preserve the newer higher priority and remove only p2 so exactly one priority remains. This supersedes the earlier unscheduled-p2 note; the outstanding design/API decisions, native #2390 parent and every other label remain. No milestone is invented by this correction.

  7. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design brief (1/2): managed-worktree state copy

    Answers the design prompt. Read at main 77f35ef1:

    • HygieneCard (stateText, the fixed callout, busyLabel)
    • managed-worktrees.md (Hygiene and cleanup) and package-api.md (managed-worktree findings)
    • the reference-worktree-hygiene.ts kinds and handler, and the browser fixture's cleanup-failed reply

    The copy below doesn't depend on which option the API ruling picks. I'm not proposing a field name. The copy is plain inert strings; where a line needs a fact the caller must know, it is marked [fact].

    Host facts the copy relies on (all existing)

    • Kinds: retained, unknown and cleanup-failed. delete-worktree is offered for retained and cleanup-failed findings, and never for unknown.
    • The deletion is revalidated right before it runs. Any change returns stale. A failed removal returns check_failed with code: "cleanup-failed" and a fixed opaque reason, and the finding reappears with a new fingerprint.
    • An unknown finding offers only "check again", which assesses it afresh.
    • Removal has no Undo, so undone can't happen for this category (see §1).

    1 · State table (exact copy)

    State Tone Status text Notes
    applying: removal neutral Removing… checking the worktree first also used as the DispositionBar busyLabel
    applying: check only neutral Checking the worktree again… [fact] which action was sent
    stale gold This worktree changed since the finding was shown. Nothing was removed. revalidation ran before any deletion, so "nothing was removed" holds
    refused red The host refused the removal: <reason>. The worktree was not removed. the host reason, as inert text; no Couldn't write <path>
    check_failed (cleanup-failed) red The worktree couldn't be removed. It's kept for review: <reason> never "the change was written". The finding comes back with a new fingerprint; existing recovery is unchanged
    check_failed (other code) red The check couldn't finish: <code>. The worktree's state wasn't confirmed. no claim that anything was or wasn't removed
    unknown reply: removal neutral Didn't hear back, so the worktree may or may not be removed. Checking again won't remove it twice. doesn't promise "nothing changed"
    unknown reply: check only neutral Didn't hear back. Checking again is safe.
    still_detected neutral Still needs review. Nothing was removed. after check-again, or after a removal the host didn't perform
    fixed: removal teal Removed · the worktree was reclaimed [fact] removal sent. The URI is not repeated in the sentence
    fixed: check only teal No longer needs review · re-checked. Nothing was removed. reassessment cleared it without a removal
    undone — Impossible. No Undo exists for delete-worktree the caller never passes it for this category

    Removal versus reassessment. fixed reads differently depending on which action the user sent. The caller already knows that action, because it sent it. No new host fact is needed; it's the [fact] above.

    2 · Check-only action (unknown kind, no repair)

    • Commit label: Check again. This replaces Done, check again, because the user had nothing to do.
    • Post-check line, shown under the controls: Its work or owner can't be established, so it's kept as is. Checking again reads its state afresh. It never removes anything.
    • Later and Dismiss are unchanged. Dismiss keeps today's meaning: it never removes a worktree.

    Post-check line for delete-worktree (replaces Then re-runs validation on this file.):

    Before removing, the host checks the worktree again. If anything changed, nothing is removed.

    3 · Inert values and unavailable facts

    • reason and code are rendered as text nodes inside the Callout, wrapped with overflow-wrap:anywhere. They are never linkified or parsed as markdown. The host reason is already fixed and opaque.
    • The logical reference-worktree://… id appears only in the existing identity PathRef. It is never inside a sentence that calls it a file or names it as a write target.
    • A missing reason falls back to no reason given, and a missing code to check unavailable. No other fallback promises an outcome.
    • No repository, commit, path or principal appears in any of this copy. Private cards stay opaque, and ui-server: owner-only detail view for private managed-worktree hygiene findings #2734 owns details.

    Part 2 covers mocks, focus, browser criteria and dependencies.

  8. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Design brief (2/2): mocks, focus, browser criteria, dependencies

    Mocks

    320px, cleanup-failed (removal failed):

    ┌──────────────────────────────────┐
    │ WARNING · managed worktree       │
    │ Removing a managed worktree      │
    │ failed                           │
    │ reference-worktree://wt_7f3a…    │  ← identity PathRef only
    │ private source · released        │
    │ ┌──────────────────────────────┐ │
    │ │ The worktree couldn't be     │ │  red Callout, role=status
    │ │ removed. It's kept for       │ │
    │ │ review: The worktree could   │ │
    │ │ not be removed; it is kept   │ │
    │ │ for review.                  │ │  ← host reason, inert, wraps
    │ └──────────────────────────────┘ │
    │ Before removing, the host checks │
    │ the worktree again. If anything  │
    │ changed, nothing is removed.     │
    │ [ Remove worktree ] [Later▾]     │
    │ [ Dismiss ]                      │
    └──────────────────────────────────┘
    

    Desktop (~560px column), unknown kind, no repair:

    ┌──────────────────────────────────────────────────────────┐
    │ UNKNOWN · managed worktree                               │
    │ A managed worktree's work or owner cannot be established │
    │ reference-worktree://wt_19c2 · private source · unknown  │
    │ Its work or owner can't be established, so it's kept as  │
    │ is. Checking again reads its state afresh. It never      │
    │ removes anything.                                        │
    │ [ Check again ]   [ Later ▾ ]   [ Dismiss ]              │
    └──────────────────────────────────────────────────────────┘
    

    Fixed by removal (replaces the card, as today):

    ┌──────────────────────────────────────────────┐
    │ ✓ Removed · the worktree was reclaimed       │  teal, role=status
    └──────────────────────────────────────────────┘
    

    4 · Focus, announcements and behavior

    The behavior below is unchanged; only the strings are new:

    • Same role="status" region and cadence: one announcement per state change, nothing on load.
    • Same tones as today (stale is gold, refused and check_failed are red, fixed is teal).
    • Same focus and return: the card title (data-hygiene-title) after an outcome, and the next card after fixed.
    • Same confirmation and Escape behavior for the removal, the same idempotency, and no double apply.
    • Check again and Remove worktree use the existing DispositionBar commit slot, so targets stay at least 44px.
    • Long reasons wrap. There is no horizontal scroll at 320px or 200% zoom, and both themes use existing tokens.

    5 · Browser assertions (pinned hygiene-review.layout.tsx, 320 + 1280, light + dark)

    Per managed-worktree state (applying ×2, stale, refused, cleanup-failed, other check_failed, unknown reply ×2, still_detected, fixed ×2):

    • The status text equals the table exactly.
    • The text contains none of file, written, validation or Couldn't write, and no reference-worktree:// outside the PathRef.
    • The unknown kind's commit name is Check again. Done, check again is absent.
    • The post-check line matches §2 for delete-worktree and for the unknown kind.
    • No repository, commit, path or principal fixture string appears in DOM text or accessible names (private fixture).
    • A fixture reason of [x](http://e.test)<b>y</b> renders literally.
    • Focus goes to the card title after stale, refused or cleanup-failed, and to the next card after fixed. Keyboard only.

    Controls (must stay unchanged): the existing Markdown broken-link and required-field scenes keep their file wording (Applying… checking the file first, Then re-runs validation on this file., Done, check again). The #2723 no-Open-file assertion still passes.

    Mutation: restoring the generic file defaults for the managed-worktree category must fail every changed assertion above. Record that in the PR.

    Dependencies for the maintainer

    1. API boundary (needs: decision, body). The copy works under either option:

      • A: the caller passes these strings.
      • B: the kit selects them by kind.

      Under A, the caller supplies the state text, the busy label and the fixed text. Under B, the kit needs the kind and the "action sent" fact.

      Recommend A, as the body does: the fixed: removal / fixed: check only split needs a fact that only the caller has, which B would have to grow a second prop for.

    2. undone is impossible for this category. Confirm that the caller should never pass it, instead of the kit guarding against it.

    3. Commit label Remove worktree. The mock assumes the existing repair label; this brief doesn't change it. If the current label differs, it's out of scope here.

  9. added
    priority: p2
    and removed
    needs: design
    on Oct 24, 2026
  10. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-10-24): Approved A with corrected copy. Add optional caller-supplied inert display copy to HygieneCard, preserving all existing file defaults. Check again explains that a freshly verified clean, unused worktree may be reclaimed automatically; the earlier never-removes claim is not approved. Use Worktree removed only with confirmed outcome evidence; otherwise a cleared finding says No longer needs review. An uncertain reply says The outcome wasn't confirmed. Check again. Other states describe actual checking/removal without unsupported nothing-changed claims, private detail or file-edit wording. No Undo for this category; preserve interaction/state-machine behavior. The body records the additive API classification, approved wording and source correction. Decision/design prerequisites are resolved; implementation and browser proof remain.

  11. added
    agent-ready
    and removed
    priority: p2
    needs: decision
    on Oct 24, 2026
  12. self-assigned this
    on Oct 24, 2026
  13. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Claimed (claim bk044-2837-card-copy), branch fix/2837-worktree-card-copy-044, stacked on the #2734 branch because both change HygieneCard and the hygiene card. Implementing decision A with the corrected copy; draft PR to follow.

  14. added a commit that references this issue on Oct 24, 2026
    2aedfc3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-kitarea: ui-reactcontractpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions