Skip to content

fix(git-panel): show no-repository state - #10794

Merged
bolichen97 merged 1 commit into
mainfrom
fix/git-panel-no-repo-state
Sep 19, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/git-panel-no-repo-state

Conversation

@pepmach

@pepmach pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

The Git panel could confuse “not a repository” with “Git failed.” A failed refresh could keep stale branch, sync, clean, or changed-file data beside an error.

Why it matters

These states need different fixes. Wrong copy sends the user to choose another folder when the real problem is an unavailable or damaged repository.

What changed (motivation → approach → change)

The status route lets sandboxed Git decide whether the project belongs to a repository. Only Git’s explicit not a git repository verdict returns 200 {"repo": false, "files": []}. A confirmed repository with a corrupt HEAD, unreadable root, or failed status command returns 503 git_status_unavailable. The post-failure path check treats only a missing or non-directory project as absence; permission and other operational errors keep the 503 response.

The HEAD probe stays separate from status because HEAD = ref: refs/heads/bad.lock makes git status --porcelain=v1 -b exit 0 with ## A a.txt, while git branch --show-current exits 128. A regression test pins that pair. One bounded subprocess runner keeps the existing timeout, kill/reap, sandbox, encoding, and byte-cap behavior in one place.

The Git panel renders the no-repository state only when the status query has no error. A status failure puts muted “Branch unavailable” text in the branch slot and hides the branch, sync, clean, uncommitted, and changed-file rows. The independently loaded commit list stays visible, and the localized notice says its history may be out of date. The agent handoff keeps the raw endpoint, HTTP status, and backend code. The no-repository help tells users to click the folder name below the message box. Every shipped catalog and the pseudolocale carry both sentences. The status contract also records that the ChatPage badge, FileBrowserRail, and Pierre consumers receive 503 on operational failure and must not treat non-200 as “not a repository.”

The Files rail’s Changed mode (the Pierre workspace tree) treats the same 503 as an error state instead of a permanent loading skeleton, and one failure renders exactly one notice: Changed mode hands the failure to the tree’s own sentence, “Couldn’t read the repository status.”, and suppresses the rail’s status row, while All mode keeps the rail’s existing warning. The tree’s notice carries the structured error report, so “Ask the agent” keeps the endpoint, HTTP status, and backend code there too.

Git result Panel result
Explicitly not a repository 🟨 “Not a Git repository” with visible folder-name help
Discovery, HEAD, root, or status failure 🟨 Scoped localized error; muted “Branch unavailable” placeholder; no stale status rows; one notice in the Files rail’s Changed mode
Repository read succeeds with no changes 🟦 Clean repository state

🟨 changed · 🟦 unchanged

Scope: this change covers /api/project/git/status. /api/project/git/log still collapses discovery failures into an empty commit list; issue #10892 owns that work.

Changed areas: src/kiro_crew/dashboard/handlers/files.py, test/test_project_git_status_log.py, website/src/components/GitPanel.tsx, website/src/test/GitPanel.test.tsx, website/src/pages/chat/FileBrowserRail.tsx, website/src/pierre/PierreWorkspaceTreeImpl.tsx, website/src/test/PierreWorkspaceTreeImpl.test.tsx, website/src/i18n/locales/, and docs/system-specs/modules/learn-cron-dashboard.md.

Tests

  • .venv/bin/python -m pytest -n0 -q test/test_project_git_status_log.py test/test_project_git.py — 82 passed.
  • npx vitest run src/test/GitPanel.test.tsx — 8 passed, including the muted placeholder, stale changed-file suppression, and Chinese structured-report handoff.
  • Round 14: npx tsc -b; I18N_BASE_REF=origin/main npx vitest run src/test/GitPanel.test.tsx src/test/PierreWorkspaceTreeImpl.test.tsx src/i18n/style/bnStyle.test.ts src/i18n/catalogParity.test.ts — passed, including the red-first assertion that a 503 in Changed mode renders exactly one alert in the Files rail; npm run lint:i18n, npm run i18n:check, and npm run build — passed.
  • npm run build — passed.
  • I18N_BASE_REF=origin/main npm run i18n:check — 19 checks passed, including all diff-scoped checks.
  • Black baseline gate, isort, Flake8, mypy, and docs lint — passed.
  • Isolated pod E2E — auth, failed-refresh, and no-repository checks passed; teardown removed the pod.

Manual verification

Scripted Playwright opened the staged bundle in an isolated pod. It selected a real repository, loaded its real commit list, returned a successful dirty status payload with one changed file, and then injected 503 {"error":"server-only repository status detail","code":"git_status_unavailable"} on Refresh. The panel showed one scoped localized sentence and muted “Branch unavailable” text. It hid stale branch, sync, clean, uncommitted, and changed-file data while keeping the commit list visible.

Round 14 repeated the failure against a real repository whose HEAD reads ref: refs/heads/bad.lock, in an isolated pod on the amended bundle. The Git panel header read “Branch unavailable” beside the two-sentence notice, and the Files rail’s Changed mode showed exactly one notice with one “Ask the agent” link (the capture script fails on any other count).

The same run selected /local/home/txd, a real non-repository directory. The panel showed “Not a Git repository” and the exact instruction to click the folder name below the message box. kirocrew pod ls --json confirmed the verification pod was gone afterward.

Screenshots / video

Before

Before: false loading and clean state

After — shipped no-repository guidance

After: no-repository state with the exact folder-name instruction

Failed refresh — injected 503 (round 6; the branch slot now reads “Branch unavailable” — see the round-14 capture below)

Failed refresh (round 6): scoped error, the then-muted branch placeholder, and stale changes hidden

Failed status — Git panel header (round 14)

Git panel: “Branch unavailable” in the header and the two-sentence notice

Failed status — Files rail, Changed mode (round 14)

Files rail: exactly one notice with the Ask the agent handoff

Related Issues

Fixes #10775

Pattern harvest

Rule candidate: review-prompt
Pattern: Let sandboxed Git produce the repository verdict; map only explicit absence to an empty state and keep later failures unavailable.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

@pepmach
pepmach requested review from a team and cixuuz September 14, 2026 14:59
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify a git-less or sandbox-refused host acceptably shows the persistent 503 notice in Files→Changed, since missing-executable was quietly "not a repo" before.

[DESIGN-REVIEWED] 51d5fd0

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 51d5fd0

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

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

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

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

UX-Verdict: CONCERNS

Failed status with an empty commit list renders unexplained blank space while the notice references history that isn't on screen — reader: "no idea".

Watch

  • Shot-04 (the shipped round-14 state): statusError forces isClean false, so empty_state never renders and the body below the notice is blank; the notice's second sentence "Commit history may be out of date." then points at history that isn't shown. Blind reader: "I can't tell whether blank means 'no history' or 'history hidden because of the error' — no idea." Rare state (status failure + empty log) × momentary confusion × every occurrence. Fix: when statusError and no commits render, show a muted "Commit history unavailable" placeholder in GitPanel.tsx.

Suggestions

  • GitPanel.tsx non-503 branch now headlines the raw errMessage body with the full two-sentence status_failed — "Commit history may be out of date." atop, say, a network error. Use only the first sentence as the title (split the key).

[UX-REVIEWED] 51d5fd0

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 51d5fd07c774e3fc9686dac1b13358f500909c87 — 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

Verify the ChatPage footer badge on the new 503: the spec now asserts it "degrades silently", but no test in this diff exercises that consumer.

Not justified as shipped

  • Item 10 — rides along: _remove_tree / test_remove_tree_clears_readonly_file in test_project_git_status_log.py is Windows fixture-cleanup hardening the description never mentions; harm-free rider, inventory only.

What this change ships

Inventory (10 items) — 9 justified

Intent: FIX (issue #10775) — stop the Git panel presenting a Git failure as "not a repository" or as stale/clean data.

  1. Status endpoint returns 503 git_status_unavailable on operational Git failure instead of 200 no-repo/empty data — justified
  2. Only Git's own not a git repository verdict (sandboxed, LC_ALL=C, pinned by a real-git test) means "no repository" — justified
  3. Corrupt symbolic HEAD (bad.lock) reads as outage, not bogus clean status — justified
  4. Panel shows terminal "Not a Git repository" with folder-name help instead of perpetual loading/false "clean" — justified
  5. Failed refresh shows muted "Branch unavailable" and hides stale branch/sync/clean/changed rows; commit list stays with out-of-date copy — justified
  6. Files rail Changed mode shows one error notice instead of a permanent skeleton — justified
  7. Notices carry the structured "Ask the agent" report via existing errorReport mechanism — justified
  8. New strings in every shipped catalog and the pseudolocale — justified
  9. Directory vanishing mid-request (incl. Windows spawn errors) still reads as absence — justified
  10. Test-only readonly-tree removal helper plus its self-test — rides along

Consumer counts run: ['git-status' query key = 4 consumers, matching the spec's declared contract; _run_git_bounded( = 13 call sites, capture="stderr" used by 1 with 12 on the default, so the parameter carries two live values; parseErrorCode = ~25 existing consumers, the new apiErrorCode reuses it in the codebase's idiomatic local-wrapper shape. The declared unfixed sibling /api/project/git/log is deferred to issue #10892; /api/project/git's degrade-to-no-branch is a recorded spec decision, not a sibling.

[FIRST-PRINCIPLES-REVIEWED] 51d5fd0

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 5.6 flagged blocking issues on 51d5fd07c774e3fc9686dac1b13358f500909c87; Opus 4.8 adjudication downgraded every one of them to advisory. Adjudication downgraded all 1 blocking finding(s) to advisory: the remedy each one requires is disproportionate to the harm it prevents. Read them as advice, not as merge conditions.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/pages/chat/FileBrowserRail.tsx:519 -- Content mode suppresses the Git status failure
{statusError && !changedMode && (
Changed selected -> switch to Content -> status fails -> the unmounted tree and rail both hide the error.
Anchor: errors-use-error-notice
Fix: Suppress the rail notice only when the Changed tree is mounted, e.g. !changedMode || contentMode.
[BLOCK-MERGE-DOWNGRADED] 51d5fd0
[GPT-REVIEWED] 51d5fd0

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

I've verified the code. The finding is real at the code level: with changedMode persisted true (line 325) and searchMode==='content' (line 400), ContentResults renders instead of PierreWorkspaceTree (lines 525/538) so the changed tree is unmounted, and line 519's statusError && !changedMode is false — so no one renders the git-status notice.

But the cited anchor errors-use-error-notice (AUTOSDE line 597, blocking: true) governs how an error renders (through ErrorNotice, not a hand-written div). This code renders through ErrorNotice correctly; the finding is about a conditional-visibility gap, which that rule explicitly does not cover. So it is not a binding blocking-rule violation.

Harm weighing:

  • Conditions: changedMode true (line 325), contentMode true unmounting the Pierre tree (lines 400/525/538), statusError true (line 350), line 519 gate false → notice hidden.
  • Recovery: switching searchMode back to 'name' (line 496) remounts PierreWorkspaceTree in 'changed' mode (line 538-539), which owns and renders the notice per the comment at 515-518; the refresh button (line 472) also refetches. Self-correcting.
  • Rung: LOW. A purely informational "git status failed" notice is suppressed only while the user is in Content search mode — where no Changed count or changed tree is even displayed, so the missing message isn't information the user is currently deprived of in any actionable way. Fully recoverable, self-correcting on a mode switch, non-security, no data loss. Blocking a merge on this is disproportionate.

[ADJUDICATION] 51d5fd0 total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/pages/chat/FileBrowserRail.tsx:519 reason=disproportionate-remedy
[GPT-ADJUDICATED] 51d5fd0

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

@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from a37a10c to 667a89b Compare September 14, 2026 17:09
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 14, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from 667a89b to 6425f74 Compare September 14, 2026 18:56
@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 Sep 14, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch 2 times, most recently from 80ba052 to a2e0a79 Compare September 14, 2026 21:49
@pepmach

pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • FIXED — span=8fc725f9f9b3

Deleted _project_git_marker_state and its marker, path, gitdir, and ref-validation helpers.
Sandboxed git rev-parse --git-dir owns discovery; git symbolic-ref -q HEAD lets Git validate symbolic HEAD names.

@pepmach

pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • FIXED — span=9d1df4c86c9a

The autouse sandbox fixture comment states the new response boundary.
Operational sandbox failures are 503; repo: false requires Git's own not-a-repository verdict.

@pepmach

pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • FIXED — span=d89d2b034568

Every not_a_repository_help catalog value describes the selected folder as not being a Git repository.
The copy no longer calls it a Git working tree.

@pepmach

pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • FIXED — span=55a7a0088a87

The help text names the Project directory picker and tells the user to select the repository subfolder there.
Every shipped locale and the generated pseudolocale carry the same instruction.

@pepmach

pepmach commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author
  • FIXED — span=cb35b6ad7cd9

isClean now requires !statusError.
A regression starts with cached clean data, fails the refresh, and proves the ErrorNotice appears without the clean badge or healthy empty state.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 14, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from a2e0a79 to dd6566d Compare September 14, 2026 22:57
@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 Sep 14, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from dd6566d to d7d4840 Compare September 14, 2026 23:35
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 14, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from 1f5687e to 7ac713f Compare September 17, 2026 20:15
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Sep 17, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from 7ac713f to 92c2b8d Compare September 17, 2026 21:44
@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 Sep 17, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from 92c2b8d to 016d2ba Compare September 17, 2026 22:07
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@pepmach
pepmach force-pushed the fix/git-panel-no-repo-state branch from 016d2ba to 1fac5ed Compare September 18, 2026 17:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@pepmach

pepmach commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

When /git/log also collapses (corrupt HEAD), the second sentence points at history that is not on screen; the fix is to append it only when the list has entries, reusing the one-sentence string the Pierre tree already ships.
Out of this round: the head is GPT/Opus clean and the change is copy conditioning, not the status contract. #11858 carries the task, owner and due date; #10892 owns the log route side.

@pepmach

pepmach commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author
  • REBUTTED — the placeholder is the preview pane's pre-existing empty state, outside this PR — span=4ed9af6ba64b

"Select a file from the tree to open it in a new tab" renders whenever no file is open, exactly as it did beside the permanent skeleton this PR replaces; this PR changes the status contract and the tree's error notice, not the preview pane.
Scoping that placeholder to the tree's state is a preview-pane change with its own copy and tests; folding it into a 14-round status PR is disproportional.

@pepmach

pepmach commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author
  • REBUTTED — the round-14 header capture directly below shows HEAD; the round-6 shot documents a different flow — span=6ccbc002e4b2

Shot-03 records the injected-503 refresh on a healthy repository (stale rows hidden, commit list kept), which the round-14 corrupt-HEAD capture does not exercise; the round-14 Git panel capture under it shows the shipped "Branch unavailable" header.
Re-uploading a caption-only change re-rolls every CI and review lane for no behavior change; the caption is relabeled with the next real push.

@pepmach

pepmach commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author
  • REBUTTED — no load signal, and a discovery cache would add a staleness window to the state this PR fixes — span=d2ce9c4042d5

Each probe is the existing bounded subprocess (timeout, reap, byte cap) on the pre-existing 5-second cadence; the PR adds no new poller.
Caching the repository verdict would delay exactly the transitions this PR makes honest (a repository appearing, or its HEAD breaking); revisit only if the poll shows up in a load measurement.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 2026
@pepmach

pepmach commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

CI note: Backend Tests (3.12, 2) and Backend Tests (Windows) (2) fail on test/test_ci_fleet_routing_expression_parity.py::test_every_ci_yml_resolver_consumer_reads_the_resolver_not_a_literal -- the resolver-consumer allowlist has been red on main since #11699 landed (the allowlist did not move with the new backend-test consumer); the heal is #11876. This PR does not touch that test; the pair clears with the heal.

@bolichen97 bolichen97 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.

Approved after verification: PR Readiness success on this head, no active change requests or unresolved threads, mergeable against current main.

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.

Git panel hangs on 'loading...' and shows a false 'clean' badge when the project directory is not a git repo

2 participants