Skip to content

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

Merged
houko merged 7 commits into
mainfrom
feat/6187-agents-prompt-editor
Jun 19, 2026
Merged

feat(dashboard): edit + bind system prompt from the agent detail drawer#6201
houko merged 7 commits into
mainfrom
feat/6187-agents-prompt-editor

Conversation

@houko

@houko houko commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #6187. The Agents (智能体) detail drawer showed the system prompt read-only, and the "Prompts" modal's activate only flipped the store's is_active flag — it did not change the live prompt the agent sends to the LLM (documented gap in useBindPromptVersionToAgent). The Hands page already shipped a full inline editor (#6151 / #6166), so the two pages were inconsistent. The issue screenshot asks for exactly this on the Agents page: view/modify the prompt or bind one from the prompt library (提示词库).

Changes (dashboard-only)

  • src/pages/AgentsPage.tsxSystemPromptSection becomes an inline editor mirroring the Hands page:
    • Edit + Save via the existing usePatchAgentPATCH /api/agents/{id} (system_prompt); Save is disabled until dirty.
    • "Bind from library" opens the agent's saved versions (usePromptVersions, fetched lazily on open) with loading / empty / error states; binding a version calls useBindPromptVersionToAgent, which hot-swaps the live system_prompt and flips is_active together — fixing the activate-only-flag gap.
    • The section now always renders (was gated on a non-empty prompt) so an agent with no prompt yet can have one added.
  • src/locales/{en,zh,uk}.json — new agents.* keys (no hardcoded strings).
  • src/pages/AgentsPage.test.tsxnew focused test for the exported SystemPromptSection: Save is disabled until edited; editing + Save PATCHes system_prompt; binding a library version dispatches the version. (AgentsPage had no test harness; testing the component directly follows the data-layer rule without standing up the whole ~20-hook page.)

No backend change — update_system_prompt (lifecycle.rs) already supports both paths.

Verification

pnpm typecheck                                   # clean
pnpm exec vitest run src/pages/AgentsPage.test.tsx   # 3 passed
pnpm exec eslint src/pages/AgentsPage.tsx src/pages/AgentsPage.test.tsx   # 0 errors
                                                 # (3 pre-existing exhaustive-deps warnings at L646/662/864, not in the changed code)
pnpm build                                       # ✓

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
@github-actions github-actions Bot added size/L 250-999 lines changed area/docs Documentation and guides labels Jun 18, 2026
@github-actions github-actions Bot added the has-conflicts PR has merge conflicts that need resolution label Jun 18, 2026
# Conflicts:
#	.secrets.baseline
@houko
houko enabled auto-merge (squash) June 19, 2026 04:50
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 19, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review no-rust-required This task does not require Rust knowledge has-conflicts PR has merge conflicts that need resolution and removed has-conflicts PR has merge conflicts that need resolution ready-for-review PR is ready for maintainer review labels Jun 19, 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 19, 2026
@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 19, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

@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 19, 2026
@houko
houko merged commit 07fb8de into main Jun 19, 2026
38 checks passed
@houko
houko deleted the feat/6187-agents-prompt-editor branch June 19, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation and guides no-rust-required This task does not require Rust knowledge ready-for-review PR is ready for maintainer review size/L 250-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hands 和 智能体, 增加绑定提示词库 的功能

2 participants