Skip to content

fix(frontend): Pi permissions controls hidden when agent config omits harness.kind - #5675

Open
waterWang wants to merge 1 commit into
Agenta-AI:mainfrom
waterWang:fix/pi-permissions-hidden-when-harness-kind-absent
Open

fix(frontend): Pi permissions controls hidden when agent config omits harness.kind#5675
waterWang wants to merge 1 commit into
Agenta-AI:mainfrom
waterWang:fix/pi-permissions-hidden-when-harness-kind-absent

Conversation

@waterWang

Copy link
Copy Markdown

Symptom

When an agent config omits harness.kind, the runner treats the harness as pi_core — all seven Pi built-ins are active and the harness.permissions allow/ask/deny rules are enforced at runtime. The web UI does not apply the same default, so for such a config the Pi permissions controls are hidden while the run enforces Pi permission gating. The author cannot see or edit the rules that apply to their runs.

Before

Before — PiPermissionsControl is hidden when harness.kind is absent

Root Cause

In useModelHarness.tsx, harnessValue stayed null when harness.kind was absent (line 174), so isPiHarness was false and hasPiPermissions hid PiPermissionsControl.

Fix

Extracted a small exported helper resolveHarnessKind that defaults to "pi_core" when harness.kind is absent (matching the runner's default). The default is read-path only — it never writes kind back into the saved config.

Coverage

  • null / undefined harness → "pi_core"
  • {harness: {}}"pi_core"
  • {harness: {kind: "claude"}}"claude" (not overridden)
  • All other explicit harness kinds preserved

Validation

All 310 tests pass (20 test files, including 9 new tests for resolveHarnessKind):

 ✓ tests/unit/resolveHarnessKind.test.ts (9 tests) 12ms
 Test Files  20 passed (20)
      Tests  310 passed (310)

No lint errors.

AI Model

This change was produced by DeepSeek V4 Flash (Hermes Agent) with web research and unit test verification. The implementation follows the step-by-step instructions left by @mmabrouk in the issue.

Closes #5661

… harness.kind

The runner treats an absent harness.kind as pi_core, but the UI read path
left harnessValue as null, so isPiHarness and hasPiPermissions were false
and PiPermissionsControl never rendered.

Extracted resolveHarnessKind helper that defaults to 'pi_core' when kind
is absent, aligning the UI with the runner. The default is read-path only;
it never writes kind back into the saved config.

Closes Agenta-AI#5661
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 3, 2026
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

@waterWang is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dosubot dosubot Bot added bug Something isn't working Frontend labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi @waterWang, thanks for opening a pull request. 🙏

This PR was automatically closed because it does not yet meet our contribution requirements:

  • The Summary section is missing or empty. Describe what changed and why using the PR template.

We ask for this so every change is documented and demonstrably tested before review.

How to get it reopened
Update the PR description (and add a demo recording if your change touches functional code). The bot reopens the PR automatically once the requirements are met. No need to open a new one.

See the Contributing guide and Creating your first PR. If you think this was closed in error, leave a comment and a maintainer will take a look.

@github-actions github-actions Bot added the incomplete-pr PR is missing required template sections or a demo recording label Aug 3, 2026
@github-actions github-actions Bot closed this Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2985aa5e-a52b-4a24-a3c8-a75260939ef7

📥 Commits

Reviewing files that changed from the base of the PR and between 99ab003 and 5b9c38c.

📒 Files selected for processing (2)
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx
  • web/packages/agenta-entity-ui/tests/unit/resolveHarnessKind.test.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved model harness handling by applying a consistent default when the harness type is missing or invalid.
    • Preserved recognized harness types, including Claude, OpenAI, Pi Agenta, and Bedrock.
  • Tests

    • Added coverage to verify default and recognized harness type behavior.

Walkthrough

The change adds resolveHarnessKind, defaults absent or invalid harness kinds to pi_core, and uses the resolved value for Pi-specific UI behavior. Unit tests cover nullish, empty, and explicit harness kinds.

Changes

Harness kind handling

Layer / File(s) Summary
Harness kind resolver and coverage
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx, web/packages/agenta-entity-ui/tests/unit/resolveHarnessKind.test.ts
Adds the exported resolveHarnessKind helper and tests default and explicit harness kinds.
Harness capability integration
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx
Uses the resolved harness kind for effective harness and Pi-specific behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@mmabrouk mmabrouk reopened this Aug 3, 2026
@mmabrouk

mmabrouk commented Aug 3, 2026

Copy link
Copy Markdown
Member

Thanks for picking this up, and thanks for the tests. The approach is right: the runner treats a missing harness.kind as pi_core, so defaulting on the read path is exactly the fix, and keeping the default out of the write path is the important part. I checked that side of it and the config is never written back, which is what we wanted.

Three things before we can merge this.

1. Prettier fails on the new test file. The only difference is a missing newline at the end of web/packages/agenta-entity-ui/tests/unit/resolveHarnessKind.test.ts. Our CI job "11 - check code styling" will go red on it once the workflows run. You can fix it with:

cd web && pnpm format-fix

2. The CLA is not signed yet. We cannot merge without it, independent of the code. The CLA bot comment on this PR has the link.

3. Two more places still read the raw value. resolveHarnessKind is applied to harnessValue, but the harness dropdown and the collapsed section summary still read harness.kind directly, so a config without a kind shows Pi in the rail but shows an empty harness dropdown in the focused view. That is the manual check from step 2 of the issue: "the harness dropdown should now show Pi selected instead of empty". Please use the helper in both spots:

// in the HarnessSelectControl inside the "Harness" RailField
value={resolveHarnessKind(harness)}

// in modelSummary
enumLabel(harnessProps.kind, resolveHarnessKind(harness))

One optional nit, not a blocker: two of the test cases are the same assertion, resolveHarnessKind({}), once as "harness.kind is absent" and once as "harness.kind is an empty object". You can drop one.

Everything else looks good. The package test suite passes on your branch, TypeScript and ESLint are both clean, and the change is scoped to the two files it should touch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Frontend incomplete-pr PR is missing required template sections or a demo recording size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(bug) Pi permissions controls are hidden when the agent config omits harness.kind

3 participants