Skip to content

feat(ui): admin prompt library and prompt selection in the preset/partition editors - #836

Merged
andyne13 merged 27 commits into
developfrom
feat/pm-ui
Jul 30, 2026
Merged

feat(ui): admin prompt library and prompt selection in the preset/partition editors#836
andyne13 merged 27 commits into
developfrom
feat/pm-ui

Conversation

@andyne13

@andyne13 andyne13 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Admin UI for the prompt library added in #835. Stacked on that PR — review
and merge it first
; this branch targets feat/pm-backend, so the diff here
is UI-only.

Part of #772.

What it adds

Prompt Library page (/admin/prompts, new sidebar entry) — prompts grouped
by concern (Answer / Indexation / Retrieval) as cards, with a drawer editor
offering an edit tab and a preview tab that renders the template against sample
values. Insert-variable buttons only offer the placeholders the type actually
accepts, so the editor can't produce a template the API would reject.

Each card carries a used-by badge and a default badge, and exposes the same
card-action affordances as Presets and Models rather than a new pattern.

Selection lives in the editors that own the setting, not in a separate
assignment screen:

  • Preset editor — indexation presets pick contextualization / image-captioning /
    topic-tagging prompts; retrieval presets pick query-contextualizer, plus HyDE
    or multi-query, shown only when the retriever type actually uses them.
  • Partition editor — an Answer section picks the final answer prompt.

Every picker offers "Use default", which clears the name and falls back to the
type's global default.

Also in here

A few consistency fixes this page surfaced: the Jobs, Presets and Models tabs
now match the Library's tab sizing, the Jobs status tabs are title-cased, the
Default badge renders identically in Prompts and Models, and the partition
config rows no longer overflow their grid cells.

Verification

tsc -b clean, 176 vitest tests green, production build clean. eslint reports
one pre-existing warning in models.tsx, untouched here.

Driven end-to-end against a live deployment: creating a prompt, selecting it in
a preset and in a partition, and confirming the selection reached the model.

Summary by CodeRabbit

  • New Features

    • Added an admin-only Prompt Library (create/edit, preview with placeholder validation, set default, delete) and a new /prompts admin route.
    • Added “Prompts” to the sidebar, visible only with prompt-management permission.
  • Improvements

    • Expanded prompt API and updated prompt/partition/preset wiring to support prompt-type–driven selection with “use default”.
    • Enhanced General Settings to edit generation_prompt_names; refined several admin UI details (tabs, badges, layout/spacing).
  • Tests

    • Added pagination coverage for prompt listing and updated prompt/template utility and related admin UI tests.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an admin Prompt Library with CRUD API support, template validation and previewing, prompt selection for presets and partitions, admin navigation and routing, plus related UI styling and test updates.

Changes

Prompt management and configuration

Layer / File(s) Summary
Prompt contracts and template metadata
ui/src/lib/api/prompts.ts, ui/src/lib/api/prompts.test.ts, ui/src/lib/prompt-meta.ts, ui/src/lib/prompt-meta.test.ts
Adds typed prompt CRUD operations, pagination, API tests, prompt taxonomy, placeholder validation, preview rendering, and picker value helpers.
Admin prompt library and navigation
ui/src/pages/admin/prompts.tsx, ui/src/router.tsx, ui/src/lib/permissions.ts, ui/src/components/layout/sidebar.tsx
Adds the admin Prompt Library page, guarded route, permissions, and sidebar navigation.
Preset and partition prompt selection
ui/src/lib/api/partitions.ts, ui/src/pages/admin/partitions/detail.tsx, ui/src/pages/admin/presets.tsx, ui/src/pages/admin/presets.test.tsx
Adds prompt selection controls to presets and partition generation settings, and sends partition prompt overrides in PATCH requests.
Related admin UI updates
ui/src/components/ui/tabs.tsx, ui/src/pages/admin/jobs/list.tsx, ui/src/pages/admin/jobs/list.test.tsx, ui/src/pages/admin/models.tsx
Updates tab sizing, job status labels and tests, model default badge styling, and partition form layout classes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant Router
  participant PromptsPage
  participant PromptAPI
  Admin->>Router: open /prompts
  Router->>PromptsPage: render admin page
  PromptsPage->>PromptAPI: listAllPrompts()
  PromptAPI-->>PromptsPage: PromptResponse[]
  Admin->>PromptsPage: create or update prompt
  PromptsPage->>PromptAPI: createPrompt() or updatePrompt()
  PromptAPI-->>PromptsPage: mutation result
Loading

Possibly related issues

  • linagora/openrag#772 — Covers the prompt library, global defaults, admin UI, and per-partition prompt overrides implemented by this change.

Possibly related PRs

  • linagora/openrag#835 — Adds the backend /prompts endpoints and generation_prompt_names support consumed by this UI and API client.

Suggested labels: admin-ui

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main UI work: adding the admin prompt library and prompt selection in preset/partition editors.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pm-ui

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.

@coderabbitai coderabbitai Bot added the admin-ui Admin UI label Jul 29, 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 (5)
ui/src/pages/admin/presets.tsx (3)

605-643: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

New PromptSelect reuses the same "__default__" sentinel as FeatureToggle, and a prompt literally named __default__ would be unselectable.

Both this component and FeatureToggle (line 582) hardcode "__default__" as the "use default" sentinel value for the Select. Since prompt name is free text with no visible reserved-word restriction (see prompts.tsx's create/edit form), a prompt named exactly __default__ would always render as "Use default" and never be individually selectable in any of the three pickers (here, FeatureToggle, and the partition detail generation-prompt picker). Consider centralizing the sentinel as a shared exported constant (e.g. in prompt-meta.ts) and either validating against it in the prompt name field, or picking a sentinel value guaranteed not to collide with a real prompt name.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/pages/admin/presets.tsx` around lines 605 - 643, Prevent prompt names
from colliding with the "__default__" Select sentinel used by PromptSelect,
FeatureToggle, and the partition detail generation-prompt picker. Centralize the
sentinel in a shared exported prompt-meta constant, then validate or reject that
value in the prompt create/edit name field so prompts named "__default__" cannot
be saved while preserving the existing default-selection behavior.

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

Duplicate promptsByType filter helper (3rd occurrence).

Same one-liner as IndexationPresetForm (line 288, pre-existing) and now also added in ui/src/pages/admin/partitions/detail.tsx. See consolidated comment for a shared-helper suggestion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/pages/admin/presets.tsx` at line 664, Remove the duplicate local
promptsByType helper from the presets page and reuse the shared helper
established for prompt-type filtering, ensuring existing callers retain the same
filtering behavior. Check the corresponding IndexationPresetForm and partitions
detail implementations to consolidate rather than adding another identical
filter.

581-596: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Hardcoded "__default__" sentinel duplicated across prompt pickers.

Will be covered by the consolidated comment alongside the new PromptSelect component and the partition detail picker.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/pages/admin/presets.tsx` around lines 581 - 596, The prompt picker
hardcodes the "__default__" sentinel, which should be shared across
prompt-selection controls. Update the Select value handling, onValueChange
mapping, and default SelectItem in the prompt picker to reuse the centralized
sentinel from the new PromptSelect implementation, preserving the existing
empty-string behavior.
ui/src/lib/prompt-meta.ts (1)

66-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider typing prompt-type params/keys as PromptType instead of string.

PROMPT_TYPE_VARIABLES is Record<string, TemplateVariable[]>, and validatePlaceholders/renderPreview take promptType: string. Since all 7 PromptType members are already covered, switching to Record<PromptType, TemplateVariable[]> and typed params would catch a missing variables entry at compile time if a new prompt type is ever added, instead of silently falling back to []. This also propagates loosely as string into PromptTemplateEditor's prop in prompts.tsx.

♻️ Proposed tightening
-export const PROMPT_TYPE_VARIABLES: Record<string, TemplateVariable[]> = {
+export const PROMPT_TYPE_VARIABLES: Record<PromptType, TemplateVariable[]> = {
   ...
 };

-export function validatePlaceholders(content: string, promptType: string) {
+export function validatePlaceholders(content: string, promptType: PromptType) {
   ...
 }

-export function renderPreview(content: string, promptType: string): PreviewSegment[] {
+export function renderPreview(content: string, promptType: PromptType): PreviewSegment[] {
   ...
 }

Also applies to: 115-141

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/lib/prompt-meta.ts` around lines 66 - 105, Introduce the existing
PromptType type for prompt-type keys and parameters: change
PROMPT_TYPE_VARIABLES to Record<PromptType, TemplateVariable[]> and type
validatePlaceholders’ promptType accordingly, preserving all seven existing
entries. Propagate PromptType through the related renderPreview and
PromptTemplateEditor prompt-type props instead of accepting string, and remove
the permissive fallback that can hide missing prompt-type definitions.
ui/src/pages/admin/partitions/detail.tsx (1)

119-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate promptsByType filter helper.

This one-line (type) => prompts.filter(p => p.prompt_type === type) is now defined three times across the codebase (here, and twice in ui/src/pages/admin/presets.tsx). See the consolidated comment for a shared-helper suggestion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/pages/admin/partitions/detail.tsx` around lines 119 - 125, Remove the
local promptsByType helper from the partition detail component and reuse the
shared prompt-type filtering helper introduced for this duplicate logic. Update
its call sites to use the shared helper with promptsData, preserving the
existing PromptResponse[] filtering behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/src/pages/admin/prompts.tsx`:
- Around line 72-88: Update the onSuccess handlers for setDefaultMut and
deleteMut to invalidate both ["prompts-library"] and ["prompts-for-presets"],
matching createMut and updateMut. Preserve the existing success toasts and error
handling.

---

Nitpick comments:
In `@ui/src/lib/prompt-meta.ts`:
- Around line 66-105: Introduce the existing PromptType type for prompt-type
keys and parameters: change PROMPT_TYPE_VARIABLES to Record<PromptType,
TemplateVariable[]> and type validatePlaceholders’ promptType accordingly,
preserving all seven existing entries. Propagate PromptType through the related
renderPreview and PromptTemplateEditor prompt-type props instead of accepting
string, and remove the permissive fallback that can hide missing prompt-type
definitions.

In `@ui/src/pages/admin/partitions/detail.tsx`:
- Around line 119-125: Remove the local promptsByType helper from the partition
detail component and reuse the shared prompt-type filtering helper introduced
for this duplicate logic. Update its call sites to use the shared helper with
promptsData, preserving the existing PromptResponse[] filtering behavior.

In `@ui/src/pages/admin/presets.tsx`:
- Around line 605-643: Prevent prompt names from colliding with the
"__default__" Select sentinel used by PromptSelect, FeatureToggle, and the
partition detail generation-prompt picker. Centralize the sentinel in a shared
exported prompt-meta constant, then validate or reject that value in the prompt
create/edit name field so prompts named "__default__" cannot be saved while
preserving the existing default-selection behavior.
- Line 664: Remove the duplicate local promptsByType helper from the presets
page and reuse the shared helper established for prompt-type filtering, ensuring
existing callers retain the same filtering behavior. Check the corresponding
IndexationPresetForm and partitions detail implementations to consolidate rather
than adding another identical filter.
- Around line 581-596: The prompt picker hardcodes the "__default__" sentinel,
which should be shared across prompt-selection controls. Update the Select value
handling, onValueChange mapping, and default SelectItem in the prompt picker to
reuse the centralized sentinel from the new PromptSelect implementation,
preserving the existing empty-string behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d2960a1a-9da0-4ac7-bdb0-e641b1988d59

📥 Commits

Reviewing files that changed from the base of the PR and between 75dc014 and 2e39c20.

📒 Files selected for processing (15)
  • ui/src/components/layout/sidebar.tsx
  • ui/src/components/ui/tabs.tsx
  • ui/src/lib/api/partitions.ts
  • ui/src/lib/api/prompts.test.ts
  • ui/src/lib/api/prompts.ts
  • ui/src/lib/permissions.ts
  • ui/src/lib/prompt-meta.ts
  • ui/src/pages/admin/jobs/list.test.tsx
  • ui/src/pages/admin/jobs/list.tsx
  • ui/src/pages/admin/models.tsx
  • ui/src/pages/admin/partitions/detail.tsx
  • ui/src/pages/admin/presets.test.tsx
  • ui/src/pages/admin/presets.tsx
  • ui/src/pages/admin/prompts.tsx
  • ui/src/router.tsx

Comment thread ui/src/pages/admin/prompts.tsx
andyne13 added 16 commits July 29, 2026 17:37
Group it under Retrieval (not Generation), add its dropdown to the retrieval
preset editor, and drop it from the partition generation-prompts section.
…er prompt

Drop spoken_style_answer from the library and partition editor; the Answer
concern now holds a single 'Final answer prompt' selected per partition.
…nswer-prompt

Move the partition's answer-prompt select onto the same row as Indexation
Preset / Retrieval Preset / Chat LLM (4-column row) instead of a separate block
below Chat History Depth; rename the library concern group Answer -> Final Answer.
The shared SelectTrigger is w-fit, so the Chat LLM value overflowed its cell
and overlapped the neighbour once the row held four selects. Constrain the
config-row triggers to w-full, wrap the row responsively (2 cols, 4 on lg), and
widen the form so the four selects have room.
…th input

Use the same 2/4-col grid for the read-only info row (dimension/embedder/docs)
as the config row so their columns line up; cap the chat-history-depth number
input width instead of stretching it full-width like the description.
Default prompts now show a disabled delete button with a tooltip explaining it
can't be removed until another prompt is promoted to default, instead of hiding
delete entirely (which looked like the feature was missing).
Show All / Active / Completed / Failed / Cancelled instead of the shouty
uppercase labels; the underlying tab values stay uppercase for the filter logic.
Use the same outline buttons with icon+label (Set Default / Edit / Delete) in a
flex-wrap row, instead of the odd ghost/icon-only delete — so prompt cards look
uniform with the rest of the admin console.
Tabs across Jobs/Presets/Models/partitions now use text-xs font-semibold on a
shorter list, matching the library concern filters for a uniform look. Update
the jobs test for the title-cased tab labels.

@hedhoud hedhoud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The latest update is a clean rebase, so the functional patch is unchanged. The inline comments cover two behavior blockers and three user-facing correctness issues that should be addressed before approval. The existing unresolved cache-invalidation comment also remains valid.

Comment thread ui/src/pages/admin/prompts.tsx
Comment thread ui/src/pages/admin/partitions/detail.tsx Outdated
Comment thread ui/src/lib/prompt-meta.ts
Comment thread ui/src/pages/admin/prompts.tsx Outdated
Comment thread ui/src/pages/admin/presets.tsx Outdated
andyne13 added 2 commits July 29, 2026 17:52
- Match the API's template grammar instead of a /{(\\w+)}/ regex: doubled
  braces are literal, a lone brace is an error, and conversions/format specs/
  attribute access reduce to the root field. Malformed or unknown-variable
  templates are now blocked before the request rather than coming back 422.
  Verbatim prompt types are not format-validated at all, matching the backend.
- Surface a load error on the library page. A failed request rendered as an
  empty successful library, telling an admin there were no prompts during an
  outage; cached data now stays visible across a failed refetch.
- Invalidate the presets' prompt query when a prompt is promoted or deleted,
  so the preset pickers stop showing a stale default badge or a deleted prompt.
- Warn before a rename that drops selections. References are by name, so
  renaming a prompt in use silently falls its partitions back to the default.
- Only send generation_prompt_names when this editor changed it. The backend
  validates every name, so resubmitting an untouched-but-stale reference would
  422 the whole PATCH and block unrelated edits — unrecoverable for a non-admin
  owner, whose picker is disabled.
- Namespace prompt picker option values so a prompt named __default__ is still
  selectable; the fallback sentinel can no longer collide with a real name.

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

🧹 Nitpick comments (1)
ui/src/lib/prompt-meta.ts (1)

185-203: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift

Make preview use the same formatter grammar.

The regex only handles exact {name} placeholders: valid escaped braces remain doubled, and valid formatted fields are not substituted. Tokenize with the same grammar used for validation so the preview matches runtime rendering.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/lib/prompt-meta.ts` around lines 185 - 203, Update the preview
formatter around the regex-based tokenization loop to reuse the same placeholder
grammar and parsing logic as validation, including escaped braces and formatted
fields. Ensure recognized variables are substituted from varMap while preserving
literal text and unresolved placeholders according to runtime rendering
behavior, rather than relying on the exact `{name}` regex.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui/src/lib/prompt-meta.ts`:
- Around line 185-203: Update the preview formatter around the regex-based
tokenization loop to reuse the same placeholder grammar and parsing logic as
validation, including escaped braces and formatted fields. Ensure recognized
variables are substituted from varMap while preserving literal text and
unresolved placeholders according to runtime rendering behavior, rather than
relying on the exact `{name}` regex.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 804aeb6c-5e8f-4741-96f8-c181a1a10854

📥 Commits

Reviewing files that changed from the base of the PR and between 2e39c20 and b497c36.

📒 Files selected for processing (16)
  • ui/src/components/layout/sidebar.tsx
  • ui/src/components/ui/tabs.tsx
  • ui/src/lib/api/partitions.ts
  • ui/src/lib/api/prompts.test.ts
  • ui/src/lib/api/prompts.ts
  • ui/src/lib/permissions.ts
  • ui/src/lib/prompt-meta.test.ts
  • ui/src/lib/prompt-meta.ts
  • ui/src/pages/admin/jobs/list.test.tsx
  • ui/src/pages/admin/jobs/list.tsx
  • ui/src/pages/admin/models.tsx
  • ui/src/pages/admin/partitions/detail.tsx
  • ui/src/pages/admin/presets.test.tsx
  • ui/src/pages/admin/presets.tsx
  • ui/src/pages/admin/prompts.tsx
  • ui/src/router.tsx
🚧 Files skipped from review as they are similar to previous changes (12)
  • ui/src/pages/admin/jobs/list.tsx
  • ui/src/pages/admin/models.tsx
  • ui/src/pages/admin/jobs/list.test.tsx
  • ui/src/lib/permissions.ts
  • ui/src/pages/admin/presets.test.tsx
  • ui/src/components/ui/tabs.tsx
  • ui/src/pages/admin/partitions/detail.tsx
  • ui/src/lib/api/prompts.ts
  • ui/src/lib/api/prompts.test.ts
  • ui/src/pages/admin/prompts.tsx
  • ui/src/lib/api/partitions.ts
  • ui/src/pages/admin/presets.tsx

@andyne13 andyne13 added this to the v2.0.2 milestone Jul 29, 2026
@andyne13 andyne13 added the enhancement New feature or request label Jul 29, 2026
The preview still used the old /{(\\w+)}/ regex while validation had moved to
a Formatter-compatible scan, so the two disagreed: escaped braces stayed
doubled in the preview and a field carrying a format spec or conversion was
shown raw instead of substituted.

Extract the tokenizer both now share, so what an author sees in the preview
is what the pipeline renders. Verbatim prompt types preview unchanged, since
they are never .format-ed.
@andyne13

Copy link
Copy Markdown
Contributor Author

@hedhoud thanks for the review — all five points are addressed, could you take another look when you have a moment?

  • Template validation now mirrors the backend's str.format grammar instead of a {(\w+)} regex: {{/}} are literal, a lone brace is an error, and conversions / format specs / attribute access reduce to the root field. Malformed or unknown-variable templates are blocked before the request rather than coming back as a 422. Verbatim prompt types aren't format-validated at all, matching _PROMPT_FORMAT_FIELDS.
  • Rename of a prompt in use now warns explicitly (inline on the field and again on submit), naming how many partitions lose their selection and that they fall back to the default.
  • generation_prompt_names is only sent when this editor actually changed it, so an untouched-but-stale reference can no longer 422 an unrelated description or chat-depth edit — which a non-admin owner couldn't have recovered from.
  • Failed prompt-list request shows an error with a retry instead of rendering as an empty library, and cached data stays visible across a failed refetch.
  • __default__ is no longer a reserved value: picker options are namespaced, so a prompt with that name stays selectable.

Also from CodeRabbit's follow-up: the preview shared the old regex, so it disagreed with the new validation on escaped braces and formatted fields — both now share one tokenizer.

Covered by new unit tests in ui/src/lib/prompt-meta.test.ts (204 green overall, tsc and build clean).

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/src/lib/prompt-meta.test.ts`:
- Around line 107-110: Strengthen the test for format and conversion handling in
the “substitutes a field carrying a format spec or conversion” case by asserting
the exact renderPreview/flat output rather than using toContain. Verify the
intended semantics for {:>12} padding and !r quoting, or explicitly assert that
these modifiers are deliberately stripped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5934fa08-a2a8-434a-8c4d-36f67f39bad3

📥 Commits

Reviewing files that changed from the base of the PR and between b497c36 and 935cadb.

📒 Files selected for processing (2)
  • ui/src/lib/prompt-meta.test.ts
  • ui/src/lib/prompt-meta.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/src/lib/prompt-meta.ts

Comment thread ui/src/lib/prompt-meta.test.ts Outdated
The assertions used toContain, so they passed whether or not a field's
conversion (!r) and format spec (:>12) were honoured — the test named the
behaviour without pinning it.

Assert the exact output and document the choice: modifiers are recognised but
deliberately not emulated, because the substituted value is the illustrative
sample rather than the runtime one, so reimplementing Python's format
mini-language in TypeScript would be a second grammar to keep in sync for no
gain.

@hedhoud hedhoud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The latest update addresses the earlier rename, stale-reference, error-state, sentinel, and cache findings. Three correctness issues still need attention before approval: runtime-unsafe template expressions, silent pinning of the current default in indexation presets, and the one-page prompt-library limit.

Comment thread ui/src/lib/prompt-meta.ts
Comment thread ui/src/pages/admin/presets.tsx
Comment thread ui/src/pages/admin/prompts.tsx Outdated
@hedhoud hedhoud self-assigned this Jul 30, 2026
andyne13 added 2 commits July 30, 2026 09:57
- Mirror the API's stricter placeholder rule: a conversion, format spec or
  attribute/index access is rejected instead of being reduced to its root name,
  which previously let the editor accept templates the pipeline cannot render.
- Stop auto-selecting the only prompt in a FeatureToggle. After seeding a type
  usually has exactly one prompt — its global default — so opening and saving
  an indexation preset pinned that name and silently detached the preset from
  any future default. An empty value is a real 'use default' choice; models
  have no such fallback and keep the behaviour.
- Follow pagination when listing the library. A single capped request hid
  prompts past the cap and reported a partial count as the total, leaving them
  unmanageable on the page and unselectable in every picker.
@andyne13

Copy link
Copy Markdown
Contributor Author

@hedhoud all three are addressed — replies inline on each thread.

The placeholder one turned out to be a backend bug as well: the same root-reduction was in _validate_template, so {context!x} and {context.missing} were reachable through the API and would have crashed at render time. Managed templates are now restricted to plain placeholders on the backend (#835, 8c207a9e) with the editor mirroring that verdict here. Thanks for spotting it — that one would have been ugly as a global default.

Ready for another look when you have a moment.

hedhoud
hedhoud previously approved these changes Jul 30, 2026

@hedhoud hedhoud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rechecked the latest update. The three blocking issues are addressed, and the focused tests and UI build pass locally. This is ready from my side.

andyne13 added 3 commits July 30, 2026 12:08
The API now returns spoken_style_answer, which this page deliberately does not
surface — it is driven by a chat metadata flag, not by anything configurable
here — but the header counted every prompt the API returned, so it advertised
eight prompts above seven cards.

Count the managed types only. Adding the type to PROMPT_GROUPS later is all
that's needed to surface it.
Base automatically changed from feat/pm-backend to develop July 30, 2026 13:19
@andyne13
andyne13 dismissed hedhoud’s stale review July 30, 2026 13:19

The base branch was changed.

@andyne13
andyne13 merged commit 376d7c3 into develop Jul 30, 2026
6 checks passed
@andyne13
andyne13 deleted the feat/pm-ui branch July 30, 2026 13:38
@andyne13 andyne13 mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

admin-ui Admin UI enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants