fix(frontend): pi permissions controls hidden when harness kind missing - #5706
fix(frontend): pi permissions controls hidden when harness kind missing#5706oforiwaasam wants to merge 4 commits into
Conversation
|
@oforiwaasam is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @oforiwaasam! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe UI now defaults missing or invalid harness kinds to ChangesHarness kind defaulting
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winShorten 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
📒 Files selected for processing (2)
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsxweb/packages/agenta-entity-ui/tests/unit/useModelHarness.test.ts
| 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" |
There was a problem hiding this comment.
🎯 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.jsonRepository: 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.
| 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" |
Summary
When an agent config omits
harness.kind, the runner treats the harness aspi_core: all seven Pi built-ins are active and theharness.permissionsallow/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,harnessValuestaysnullwhenharness.kindis absent (line 174), soisPiHarnessis false (line 175) andhasPiPermissions(line 379) hidesPiPermissionsControl.This is a visibility gap only; the runtime permission gate (including
allow_reads) still applies. The UI should treat an absentharness.kindaspi_core, matching the runner, with coverage for the{harness: {}}case.Demo
Testing
Verified locally
pnpm --filter @agenta/entity-ui testpasses.Added or updated tests
Tests verify the following:
pi_core.pi_agentaandclaudeare preserved as-is.QA follow-up
pnpm lint-fixpasses with no issues.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