Skip to content

fix(frontend): pi permissions controls hidden when harness kind missing - #5706

Open
oforiwaasam wants to merge 4 commits into
Agenta-AI:mainfrom
oforiwaasam:fix/pi-permissions-hidden-controls
Open

fix(frontend): pi permissions controls hidden when harness kind missing#5706
oforiwaasam wants to merge 4 commits into
Agenta-AI:mainfrom
oforiwaasam:fix/pi-permissions-hidden-controls

Conversation

@oforiwaasam

@oforiwaasam oforiwaasam commented Aug 3, 2026

Copy link
Copy Markdown

Summary

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.

Where the gap is: in web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx, harnessValue stays null when harness.kind is absent (line 174), so isPiHarness is false (line 175) and hasPiPermissions (line 379) hides PiPermissionsControl.

This is a visibility gap only; the runtime permission gate (including allow_reads) still applies. The UI should treat an absent harness.kind as pi_core, matching the runner, with coverage for the {harness: {}} case.

Demo

image image image

Testing

Verified locally

pnpm --filter @agenta/entity-ui test passes.

Test Files  20 passed (20)
      Tests  303 passed (303)
   Start at  12:43:37
   Duration  6.00s (transform 14.79s, setup 0ms, import 38.21s, tests 82ms, environment 1ms)

Added or updated tests

Tests verify the following:

  • Missing or undefined harness values default to pi_core.
  • Explicit harness values like pi_agenta and claude are preserved as-is.

QA follow-up

pnpm lint-fix passes with no issues.

Tasks:    11 successful, 11 total
Cached:    0 cached, 11 total
  Time:    41.251s 

AI Model Usage

This change was assisted by GitHub Copilot (MAI-Code-1-Flash) on VS code following the step-by-step instructions in the issue description.

Issue

Closes #5661

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working Frontend labels Aug 3, 2026
@CLAassistant

CLAassistant commented Aug 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ Thanks @oforiwaasam! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon.

@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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b880287a-1b40-43a0-81cf-15b0b9b3a03e

📥 Commits

Reviewing files that changed from the base of the PR and between a1e4760 and e96ef32.

📒 Files selected for processing (1)
  • web/packages/agenta-entity-ui/tests/unit/useModelHarness.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/packages/agenta-entity-ui/tests/unit/useModelHarness.test.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved model harness handling by applying a consistent default when the harness type is missing or invalid.
    • Fallback behavior now uses pi_core instead of leaving the harness type unset.
  • Tests

    • Added coverage for default and explicitly specified harness types.

Walkthrough

The UI now defaults missing or invalid harness kinds to pi_core. Model handling, summaries, and fallback harness selection use the shared resolver. Unit tests cover default and explicit harness kinds.

Changes

Harness kind defaulting

Layer / File(s) Summary
Resolver contract and coverage
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx, web/packages/agenta-entity-ui/tests/unit/useModelHarness.test.ts
Adds resolveHarnessKindValue, which preserves string values and defaults other values to pi_core. Tests cover omitted, undefined, and explicit kinds.
Harness value integration
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx
Uses the resolver for model handling, model summaries, and fallback harness selection.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the frontend fix for hidden Pi permission controls when the harness kind is missing.
Description check ✅ Passed The description explains the missing harness kind behavior, the UI fix, test coverage, and validation results.
Linked Issues check ✅ Passed The changes satisfy issue #5661 by defaulting missing or non-string harness kinds to pi_core and adding fallback coverage.
Out of Scope Changes check ✅ Passed The changes are limited to harness kind resolution and focused unit tests required by issue #5661.
✨ 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.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/packages/agenta-entity-ui/tests/unit/useModelHarness.test.ts (1)

1-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the module comment.

The six-line comment only describes the test file. The repository guideline allows at most one short in-code comment unless it documents a surprising constraint. Replace it with one short line or remove it.

Proposed fix
-/**
- * Unit tests for the resolveHarnessKindValue function used by the model harness UI.
- *
- * These tests lock in the fallback behavior for omitted or undefined harness values and confirm
- * that explicit harness selections such as `pi_agenta` and `claude` are preserved unchanged.
- * Runs under `@agenta/entity-ui`'s own vitest runner.
- */
+// Tests harness-kind fallback and explicit values.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1070ef17-4d4f-44b8-86bc-92da46a58035

📥 Commits

Reviewing files that changed from the base of the PR and between 69e2165 and a1e4760.

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

Comment on lines +88 to +91
export function resolveHarnessKindValue(harness: {kind?: string} | null | undefined): string {
// default to the pi_core harness when none is set
const kind = harness?.kind
return typeof kind === "string" ? kind : "pi_core"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

tsconfig="$(fd -t f -i '^tsconfig.*\.json$' web/packages/agenta-entity-ui | head -n 1)"
test -n "$tsconfig"

pnpm --dir web exec tsc --noEmit --pretty false -p "${tsconfig#web/}"

Repository: Agenta-AI/agenta

Length of output: 4853


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx"
if [ ! -f "$file" ]; then
  echo "missing: $file"
  fd -i 'useModelHarness\.tsx$' web/packages/agenta-entity-ui || true
  exit 1
fi

echo "=== file location ==="
echo "$file"

echo "=== lines around resolver and call sites ==="
sed -n '70,105p;165,185p;365,385p;820,835p' "$file" | cat -n

echo "=== exact resolver line ==="
grep -n "export function resolveHarnessKindValue" "$file"

echo "=== asObject import/usages in file ==="
rg -n "asObject|resolveHarnessKindValue|type .*Record<string|Record<string" "$file"

echo "=== package tsconfig relevant content ==="
sed -n '1,80p' web/packages/agenta-entity-ui/tsconfig.json

Repository: Agenta-AI/agenta

Length of output: 7439


Align the resolver type with the actual configuration type.

harness comes from asObject("harness"), which returns Record<string, unknown>, while resolveHarnessKindValue is declared as {kind?: string} | null | undefined. This type mismatch makes the calls at Lines 180 and 377 fail type checking. Model the input as {kind?: unknown} | null | undefined, with no change to the runtime behavior.

Proposed fix
-export function resolveHarnessKindValue(harness: {kind?: string} | null | undefined): string {
+export function resolveHarnessKindValue(
+    harness: {kind?: unknown} | null | undefined,
+): string {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function resolveHarnessKindValue(harness: {kind?: string} | null | undefined): string {
// default to the pi_core harness when none is set
const kind = harness?.kind
return typeof kind === "string" ? kind : "pi_core"
export function resolveHarnessKindValue(
harness: {kind?: unknown} | null | undefined,
): string {
// default to the pi_core harness when none is set
const kind = harness?.kind
return typeof kind === "string" ? kind : "pi_core"

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 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

2 participants