Skip to content

[eb-v2 review] Git import: bind the trust prompt to the repo it was granted for — sign-off requested - #1654

Open
chiang-daniel wants to merge 1 commit into
review/eb-v2/basefrom
review/eb-v2/trust
Open

[eb-v2 review] Git import: bind the trust prompt to the repo it was granted for — sign-off requested#1654
chiang-daniel wants to merge 1 commit into
review/eb-v2/basefrom
review/eb-v2/trust

Conversation

@chiang-daniel

@chiang-daniel chiang-daniel commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review-only PR — do not merge. These changes are already landed on dchiang/eb-v2-merge (the eval-builder integration branch); this PR is a focused review surface for one area of that work. Every fix carries an inline comment explaining what was broken and why the fix takes this shape. Comments marked Personal review requested are the spots that want human judgment — the rest is context your tooling can skim. Reply on the inline comments (or add new line comments); accepted feedback will be implemented on eb-v2-merge and the commit sha posted back here. When review wraps, this PR is closed, not merged — its base and head are throwaway review refs.

Surface: the Git-import project wizard and the Code Tool test panel. One commit, e9c4b294c (landed as ccf082f54) — bind git-import trust to the repo URL it was granted for (any URL change clears the stale clone/branch/project state that the trust-skip relies on), refuse a local-trust import with no selected path, and stop the code-tool test panel from silently swallowing input-validation errors. Roughly half the diff is the wizard-stub harness and tests. The trust-model trade-offs are called out in two Personal review requested comments below — those are the ones I'd like your explicit sign-off on.

🤖 Generated with Claude Code

CI note: the "Check API Schema Bindings" failure here is an artifact of this review PR's pinned snapshot — the canonical schema verification lives on dchiang/eb-v2-merge. No action needed from reviewers.

…, and surface code-tool input validation errors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR adds validation feedback to the code-tool test panel. It also updates Git import state handling so repository changes clear stale selections, same-repository trust persists, and local imports require a selected path.

Changes

Code-tool input validation

Layer / File(s) Summary
Input validation and dialog feedback
app/web_ui/src/lib/components/code_tools/code_tool_test_panel.svelte, app/web_ui/src/lib/components/code_tools/code_tool_test_panel.test.ts
The edit dialog now displays validation errors, remains open after invalid input, clears errors on retry, and shows the generated input preview after successful submission.

Git import state management

Layer / File(s) Summary
Repository state and local import guards
app/web_ui/src/lib/components/import/import_project.svelte, app/web_ui/src/lib/stores/git_import_wizard_store.ts
Git URL changes now clear downstream repository state. Same-repository trust state remains available. Local imports without a selected path return to file selection.
Import flow test coverage
app/web_ui/src/lib/components/import/import_project.test.ts, app/web_ui/src/lib/components/import/__tests__/*
Tests add wizard-step stubs and verify trust retention, repository switching, and empty-path protection.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: scosman

Poem

A rabbit checks each field with care,
Keeps broken dialogs open there.
Git paths hop, old states depart,
Trust stays tied to the right cart.
Empty paths turn back at the gate.
“All validated!” squeaks the hare.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes and review intent but omits the required template sections for related issues, CLA confirmation, and checklists. Add the required template headings, provide related issue links or state none, confirm the CLA, and complete the test checklists.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary Git-import trust-binding change and requests review sign-off.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch review/eb-v2/trust

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

// A required field is missing or an object param is invalid JSON. Keep
// the dialog open and surface the error so the typed inputs aren't
// discarded and Run Test can't post stale values.
input_error = createKilnError(e)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The edit-inputs dialog built its param values in a try with an empty catch: when build_params threw (a missing required field, or an object param that isn't valid JSON) the error was swallowed, the dialog closed as if it succeeded, and the just-typed inputs were dropped — Run Test then posted the previous, stale values. Now a build failure keeps the dialog open, returns false, and renders the error inline, so bad input is fixed instead of silently discarded.

// which the store-only validate_step_requirements can't see. A remount or
// deep-link to #local-trust starts with no path, so send the user back to
// pick a file rather than letting Trust Project import an empty path.
if (step === "local_trust_confirm" && !import_project_path) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The local-trust step's only real input — the selected file path — lives in component state, which the store-only step validator can't see. A remount or a deep-link straight to #local-trust arrives with no path, and the old code let the user reach "Trust Project" and POST an empty path into a server error. This sends them back to the file picker instead. It's paired with the guard in on_local_trust_confirmed so an empty path can't be imported by either route.

// Seed the url step from the deep-link param. Route through adopt_git_url
// so a param pointing at a different repo than the persisted session
// clears its stale downstream state (and its trust skip).
adopt_git_url(url_param)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deep links carry a ?url= param. Previously this wrote git_url directly and left any persisted session state untouched, which is the same trust-skip hole as the Back-nav path: land on the wizard with a stale clone_path for repo A, deep-link to repo B, and B inherits A's passed trust. Seeding through adopt_git_url means a deep link to a different repo clears that state like any other URL change.

// it can never be mistaken for the current repo — in particular so the
// clone_path-based trust skip below only fires for the same repo the trust
// gate was passed for.
function adopt_git_url(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The trust gate was granted per-repo, but nothing tied it to the repo it was granted for. clone_path, selected_branch and the selected project all described whichever repo was entered earlier; changing the URL and coming back (e.g. via browser Back) left that state in place, so a different repo could sail past the trust prompt on the strength of the previous repo's clone. This routes every URL entry through one choke point that drops the downstream state whenever the URL actually changes, so the clone_path-based trust-skip below can only ever fire for the repo currently being imported.

extra_fields: Partial<typeof $git_import_wizard_store> = {},
) {
const url_changed = url !== $git_import_wizard_store.git_url
update_store({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Personal review requested: This makes the trust prompt fail-safe-annoying — re-entering the same repo URL still skips the prompt, but any different URL re-prompts, including a differently-spelled but equivalent one (trailing slash, .git suffix, http vs https, ssh vs https for the same repo). Is re-prompting on equivalent spellings the right trade for your trust model, or do you want URL normalization before the comparison?

...extra_fields,
...(url_changed
? {
clone_path: "",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Personal review requested: A URL change clears clone_path, branch and project selection, but deliberately keeps the stored credentials/auth — the credentials step re-verifies them against the new repo before any clone. So a token entered for repo A survives a switch to repo B and is re-checked rather than re-entered. Confirm that carrying credentials across a URL change matches your trust intent (the alternative is clearing them too and forcing re-entry).

// If clone_path is set, the user already passed the trust gate and the
// branch step redirected back here for credentials — skip trust and
// return directly to branch.
// A clone_path here means this repo already reached the branch step, which

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the trust-skip itself: a set clone_path is taken as proof the repo already passed trust and the branch step merely bounced back for credentials. That inference is only sound once clone_path is guaranteed to belong to the current repo, which the adopt_git_url change now enforces. The comment is rewritten to state that dependency so the skip isn't later "simplified" back into a hole.

@chiang-daniel
chiang-daniel requested a review from scosman August 5, 2026 23:41
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

📊 Coverage Report

Overall Coverage: 93%

Diff: origin/review/eb-v2/base...HEAD

No lines with coverage information in this diff.


@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
app/web_ui/src/lib/components/import/import_project.test.ts (1)

513-524: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover URL-query initialization.

Line 515 should not assert that onMount is unavailable because this setup uses @testing-library/svelte on jsdom with Svelte 4. Add a test that seeds ?url= before rendering and checks that a different repository clears clone_path, selected_branch, and project selection state through adopt_git_url.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/web_ui/src/lib/components/import/import_project.test.ts` around lines 513
- 524, Update the ImportProject tests around renderAtUrlStep to cover URL-query
initialization under jsdom/Svelte 4 rather than assuming onMount is unavailable.
Seed the browser URL with a ?url= value before rendering, then verify that
adopting a different repository through adopt_git_url clears clone_path,
selected_branch, and the project selection state.
app/web_ui/src/lib/components/code_tools/code_tool_test_panel.test.ts (1)

90-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test error recovery in the same component instance.

The success test mounts a new panel, so it cannot detect a missing input_error = null reset. Extend the invalid-input flow: provide the required value, invoke Done again, and assert that the action returns true and the warning disappears.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/web_ui/src/lib/components/code_tools/code_tool_test_panel.test.ts` around
lines 90 - 103, Extend the invalid-input test for CodeToolTestPanel so it reuses
the same rendered component after correcting the required field, invokes the
Done action again, and verifies it returns true with the “Required property not
set” warning removed. Do not rely on the separate “saves and closes when all
required fields are provided” test; the same-instance flow must validate
input_error reset behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/web_ui/src/lib/components/code_tools/code_tool_test_panel.test.ts`:
- Around line 90-103: Extend the invalid-input test for CodeToolTestPanel so it
reuses the same rendered component after correcting the required field, invokes
the Done action again, and verifies it returns true with the “Required property
not set” warning removed. Do not rely on the separate “saves and closes when all
required fields are provided” test; the same-instance flow must validate
input_error reset behavior.

In `@app/web_ui/src/lib/components/import/import_project.test.ts`:
- Around line 513-524: Update the ImportProject tests around renderAtUrlStep to
cover URL-query initialization under jsdom/Svelte 4 rather than assuming onMount
is unavailable. Seed the browser URL with a ?url= value before rendering, then
verify that adopting a different repository through adopt_git_url clears
clone_path, selected_branch, and the project selection state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b67068c6-7b56-4b79-bd6f-51b56b308e28

📥 Commits

Reviewing files that changed from the base of the PR and between b27d50e and e9c4b29.

📒 Files selected for processing (8)
  • app/web_ui/src/lib/components/code_tools/code_tool_test_panel.svelte
  • app/web_ui/src/lib/components/code_tools/code_tool_test_panel.test.ts
  • app/web_ui/src/lib/components/import/__tests__/step_branch_stub.svelte
  • app/web_ui/src/lib/components/import/__tests__/step_credentials_stub.svelte
  • app/web_ui/src/lib/components/import/__tests__/step_url_stub.svelte
  • app/web_ui/src/lib/components/import/import_project.svelte
  • app/web_ui/src/lib/components/import/import_project.test.ts
  • app/web_ui/src/lib/stores/git_import_wizard_store.ts

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.

1 participant