Skip to content

feat(dashboard/hands): enlarge TOML view, edit agent system prompt and tools with reset-to-default (#6150 #6151 #6152)#6166

Merged
houko merged 3 commits into
mainfrom
feat/hands-editing-ui
Jun 17, 2026
Merged

feat(dashboard/hands): enlarge TOML view, edit agent system prompt and tools with reset-to-default (#6150 #6151 #6152)#6166
houko merged 3 commits into
mainfrom
feat/hands-editing-ui

Conversation

@houko

@houko houko commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Three Hands-page UX improvements, one PR.

#6150 — Enlarge the HAND.toml view

The manifest viewer (TomlViewer) was capped at a 3xl modal with a 65vh code pane, which is cramped for a dense manifest.
It now opens at 7xl with a 78vh scrollable body — near-fullscreen while still letting the centred modal manage its own 90vh cap.
Responsive and dark-mode behaviour is unchanged (same Modal shell, same theme tokens).

#6151 — Edit a hand agent's system prompt (with restore-default)

A new "Agent" tab on the hand detail panel lets you edit each role's system prompt in a textarea and save it.
A one-click "Restore default" (一键恢复默认) control resets the draft to the value shipped in the hand's HAND.toml.

#6152 — Edit a hand agent's tools (with restore-default)

The same tab edits the agent's tool allowlist (capabilities.tools): add a tool by name, remove an existing chip, then save.
"Restore default" resets the list to the HAND.toml baseline.

How it works

The editor seeds from the live agent config and writes through endpoints that already exist:

  • System prompt: read via GET /api/agents/{id} (system_prompt), saved via PATCH /api/agents/{id} (usePatchAgent).
  • Tools: read via GET /api/agents/{id}/tools (capabilities_tools), saved via PUT /api/agents/{id}/tools (useUpdateAgentTools).
  • Restore-default target: the parsed HAND.toml values, newly exposed per-agent on GET /api/hands/{id}.

Editing is gated on the hand being active, because a live agent_id only exists for an active instance — the inactive state shows a "activate first" hint, mirroring the existing settings editor.
The manifest baseline on GET /api/hands/{id} is an honest reset target: the per-agent edit endpoints write the live AgentRegistry / agent.toml, never HAND.toml, so the default is never destroyed.

Backend change

One read-only addition: get_hand (crates/librefang-api/src/routes/skills/hands.rs) now emits system_prompt and capabilities_tools for each entry in the agents array, straight from the parsed manifest.
No new write endpoint was needed — the existing per-agent config endpoints already cover system prompt and tools.

Data-layer compliance

  • All API access goes through hooks in src/lib/queries/ and src/lib/mutations/ (useAgentDetail, useAgentTools, usePatchAgent, useUpdateAgentTools); no inline fetch/api.* in the page.
  • Query keys use the existing agentKeys factories; no inline key arrays.
  • Mutation invalidation lives in the shared hooks (they already invalidate agentKeys.detail / agentKeys.tools).
  • i18n keys added to all three locale files (en.json, zh.json, uk.json); no hardcoded user-visible strings.
  • Tailwind + dark mode via theme tokens, lucide-react icons, motion/react tab transitions (reused from the existing tab system), TypeScript strict (no any).

Verification

Dashboard (crates/librefang-api/dashboard):

  • pnpm install --frozen-lockfile — clean.
  • pnpm typecheck — green.
  • pnpm lint — 0 errors (only pre-existing baseline warnings; none from HandsPage.tsx source I added).
  • pnpm test --run — 80 files, 794 tests passed.
  • pnpm build — succeeds.

Rust (via the sanctioned Dockerfile.rust-dev image, per-worktree target volume — no host target/ contention):

  • cargo check --workspace --lib — clean.
  • cargo clippy -p librefang-api --all-targets -- -D warnings — clean.
  • cargo test -p librefang-api --test hands_routes_integration — 29 passed, including the new get_hand_agents_expose_system_prompt_and_tools.
  • cargo fmt -- --check on the changed Rust files — clean.

Maintainer notes

  • The "Agent" tab edits a hand role's live agent via the standalone agent-config endpoints (PATCH /api/agents/{id}, PUT /api/agents/{id}/tools), which persist to the agent's agent.toml + DB. This is the same surface the Agents page already uses on hand-role agents. It does not rewrite HAND.toml; the manifest stays the source of "default", which is exactly what makes restore-default honest. I deliberately did not add a HAND.toml-rewriting endpoint (it would need format-preserving manifest surgery and a manifest-override merge layer in librefang-hands/librefang-kernel) — out of scope and unnecessary for the requested behaviour.
  • There is a richer, hand-native override path (PATCH/DELETE /api/agents/{id}/hand-runtime-configHandAgentRuntimeOverride, persisted to hand_state.json, reset-on-DELETE) that currently covers model/provider/tokens/temperature/web-search but not system prompt or tools. Extending it to carry those two fields would let restore-default route through a single DELETE and keep the override in hand_state.json instead of agent.toml. That is a cross-crate change (librefang-hands struct + merge, librefang-kernel apply, the route); happy to do it as a follow-up if you'd prefer that surface over the standalone agent-config endpoints used here.

Closes #6150
Closes #6151
Closes #6152

@github-actions github-actions Bot added size/L 250-999 lines changed has-conflicts PR has merge conflicts that need resolution labels Jun 17, 2026
@houko
houko force-pushed the feat/hands-editing-ui branch from 6fd0660 to d396b8d Compare June 17, 2026 12:27
@houko
houko enabled auto-merge (squash) June 17, 2026 12:27
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review and removed has-conflicts PR has merge conflicts that need resolution labels Jun 17, 2026
@houko
houko marked this pull request as draft June 17, 2026 12:32
auto-merge was automatically disabled June 17, 2026 12:32

Pull request was converted to draft

@houko
houko marked this pull request as ready for review June 17, 2026 12:37
@houko
houko enabled auto-merge (squash) June 17, 2026 12:40
@github-actions github-actions Bot added has-conflicts PR has merge conflicts that need resolution and removed ready-for-review PR is ready for maintainer review labels Jun 17, 2026
Evan and others added 2 commits June 17, 2026 23:22
…d tools with reset-to-default (#6150 #6151 #6152)

Enlarge the HAND.toml viewer from a 3xl/65vh pane to a near-fullscreen 7xl/78vh scrollable shell so dense manifests are readable (#6150).

Add a per-agent "Agent" tab on the hand detail panel that edits each role's system prompt (#6151) and tool allowlist (#6152), each with a one-click "restore default" control.

The editor seeds from the live agent config (system prompt via GET /api/agents/{id}, tools via GET /api/agents/{id}/tools) and saves through the existing PATCH /api/agents/{id} and PUT /api/agents/{id}/tools endpoints; the manifest baseline carried on GET /api/hands/{id} is the reset target. Editing is gated on the hand being active, since a live agent_id only exists for an active instance — mirroring the existing settings editor.

Expose the parsed HAND.toml system_prompt and capabilities.tools per agent on GET /api/hands/{id} so the dashboard has an honest reset-to-default baseline that the per-agent edit endpoints never overwrite (they target the live AgentRegistry / agent.toml, not HAND.toml).

i18n keys added to en/zh/uk. No new backend write endpoint was needed; the existing per-agent config endpoints already cover system prompt and tools.
@houko
houko force-pushed the feat/hands-editing-ui branch from d396b8d to e04c129 Compare June 17, 2026 14:22
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review and removed has-conflicts PR has merge conflicts that need resolution labels Jun 17, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying librefang with  Cloudflare Pages  Cloudflare Pages

Latest commit: e04c129
Status: ✅  Deploy successful!
Preview URL: https://6a54b9b0.librefang-7oe.pages.dev
Branch Preview URL: https://feat-hands-editing-ui.librefang-7oe.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying librefang-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e04c129
Status: ✅  Deploy successful!
Preview URL: https://5170695e.librefang-docs.pages.dev
Branch Preview URL: https://feat-hands-editing-ui.librefang-docs.pages.dev

View logs

@github-actions github-actions Bot added has-conflicts PR has merge conflicts that need resolution and removed ready-for-review PR is ready for maintainer review labels Jun 17, 2026
@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review and removed has-conflicts PR has merge conflicts that need resolution labels Jun 17, 2026
@houko
houko merged commit 65aa341 into main Jun 17, 2026
33 checks passed
@houko
houko deleted the feat/hands-editing-ui branch June 17, 2026 15:01
houko added a commit that referenced this pull request Jun 19, 2026
…er (#6201)

* feat(dashboard): edit + bind system prompt from the agent detail drawer

The Agents page showed the system prompt read-only, and the Prompts modal's
activate only flipped the store is_active flag without changing the live
prompt the agent sends to the LLM. The Hands page already had a full inline
editor (#6151 / #6166), so the two pages were inconsistent.

Convert SystemPromptSection into an inline editor mirroring the Hands page:
edit and save via PATCH /api/agents/{id}, or open the prompt library and bind
a saved version via useBindPromptVersionToAgent, which hot-swaps the live
system_prompt and flips is_active together. The section now always renders so
an agent with no prompt yet can have one added.

Dashboard-only; the backend update_system_prompt path is unchanged. i18n added
to en/zh/uk; the editor is covered by a new AgentsPage.test.tsx (save PATCHes
system_prompt; bind dispatches the version).

Closes #6187

* style(dashboard): collapse multi-line comment blocks to one-liners per CLAUDE.md

---------

Co-authored-by: Evan <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review PR is ready for maintainer review size/L 250-999 lines changed

Projects

None yet

2 participants