Skip to content

feat(frontend): open New Evaluation and Add to test set from the /m playground - #8110

Merged
mmabrouk merged 5 commits into
release/v0.128.8from
feat/m-playground-handoff-links
Nov 5, 2026
Merged

mmabrouk merged 5 commits into
release/v0.128.8from
feat/m-playground-handoff-links

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Release after v0.128.7. Merge #8075 first.

Context

#8075 left two playground links as seams, because their target code was not in its base: "New Evaluation" from the playground header, and "Add to test set" for the playground runs. Both targets are on main now: the /m new evaluation wizard (M7) and the /m add-to-test-set sheet (M10). This PR wires the two links. The playground is still a hidden developer view.

Changes

New Evaluation. The playground header has a "New Evaluation" button, as in /w. It opens the auto evaluation wizard with the app fixed and the revisions on screen already picked, in the order of the page. The Test set section opens first. A local draft is left out, because the server does not know its id. The button is disabled when only drafts are on screen, and hidden while the evaluations view is off (the started run opens in that view). The wizard waits until each picked revision and the variant names have loaded, so no chip opens with a placeholder label.

Add to test set. The run pane's test set menu has "Add to test set", as in /w. /w takes every successful run, finds the root span of its trace, and opens its trace drawer with those spans. /m does the same and opens the traces page sheet. The root span holds the run's inputs and outputs, so the sheet maps them like any trace. The item is disabled until a run succeeds, and hidden without edit_testsets. Two points differ from /w:

  • A run with repeats adds every repeat, not only the first one.
  • If the trace of one run cannot be read, no sheet opens and an error shows. /w opens the sheet with the runs it could read.

Both sheets load on demand. The run traces are read in the playground route itself: reading them inside the on-demand chunk made Turbopack split the app shell differently, which cost 1.2 KB on every page.

Size

First-load gzip against the #8075 head, same build machine: the app shell and the playground route grow 0.1 KB, every other page 0.0 to 0.2 KB. speed:check passes.

Tests

  • New playgroundNewEvaluation.render.test.tsx: the real playground selection, workflow stores and wizard, with HTTP mocked and the wizard's pickers as stubs (their popovers need pointer events). The wizard opens with exactly the shown revision ids, in order; a local draft is left out; the button is hidden while the view is off.
  • New playgroundAddToTestset.render.test.tsx: a real playground run, the real trace stores and the real sheet, with HTTP mocked and the sheet's search selects as native selects. The commit carries exactly the run's row; a run with two repeats adds two rows; without trace access no sheet opens; the item is disabled before a run and hidden without permission.
  • /m types pass, lint has 0 errors. Full /m suite: 2,230 to 2,234 of 2,240 pass over three runs. The 6 to 10 failures are all in playgroundRevisionActions (delete and discard) and one in playgroundCompare. The same tests fail on the feat(frontend): Playground share links, last selection and links in from other /m pages #8075 head without this change (checked locally: 10 of 37 in those two files fail with and without it).

Review

One Codex correctness round. It rated the first version Medium, with three findings, all fixed: a failed trace dropped a run without a word, repeats were left out, and a compare revision still loading could give a wrong chip label. Codex also noted that /w takes the span id from the run response first and the trace root only as a fallback. /m always takes the root span. I left this as is: the root span of a prompt app run holds its inputs and outputs, as the live check shows.

Live check

A fresh OSS dev stack with the four views on. From the playground: "New Evaluation", pick a test set and Exact Match, Start. The created run's application step references exactly the playground revision, and the run finishes. Then run one test case and use "Add to test set" on an existing test set. The new test set revision holds the row with the input and the output. The provider QA keys had no credit, so the runs used the stack's mock model.

What to QA

Turn on playground, evaluations and testsets.

  • Open an app's playground, compare two revisions, "New Evaluation". Both revisions show as picks. Start a run and open it from the toast.
  • Run two test cases, then Test set menu, "Add to test set". The preview shows both rows. Commit to a test set and open it.
  • Set repeats to 2 and run one test case. "Add to test set" previews two rows.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Summary

Summary by CodeRabbit

  • New Features
    • Added options to send successful playground runs, including repeated runs, to a test set.
    • Added a “New Evaluation” action to the playground for saved revisions when evaluations are available.
  • Bug Fixes
    • The add-to-queue picker no longer appears when there are no items to add.
  • Tests
    • Added coverage for adding runs to test sets, evaluation setup, and empty queue behavior.

The playground adds a New Evaluation action that initializes the evaluation wizard with saved revisions. It also adds a permission-gated action to add successful run traces to test sets. The Add to queue renderer now returns nothing when its item list is empty.

Changes: Playground actions

Layer / File(s) Summary
Start evaluations from the playground
web/mobile/src/features/playground/PlaygroundNewEvaluation.tsx, web/mobile/src/features/playground/PlaygroundNewEvaluationSheet.tsx, web/mobile/src/features/playground/PlaygroundWorkspace.tsx, web/mobile/tests/unit/playgroundNewEvaluation.render.test.tsx
The workspace header adds a New Evaluation action when the evaluations developer view is enabled. The sheet waits for workflow data and initializes the wizard with selected saved revisions. Tests cover revision selection, draft exclusion, and button visibility.
Add playground runs to test sets
web/mobile/src/features/playground/playgroundRunTraces.ts, web/mobile/src/features/playground/PlaygroundTestsetMenu.tsx, web/mobile/src/features/playground/PlaygroundAddToTestset.tsx, web/mobile/tests/unit/playgroundAddToTestset.render.test.tsx
The menu collects trace IDs from successful runs when the project has edit permission. The sheet waits for trace summaries and root span IDs before opening. Tests cover commits, repeated runs, and permission states.
Hide the queue picker for empty item lists
web/mobile/src/features/playground/usePlaygroundAddToQueue.tsx, web/mobile/tests/unit/playgroundAddToQueue.test.tsx
The queue renderer returns nothing when the item ID list is empty. A unit test covers this case.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PlaygroundWorkspace
  participant PlaygroundNewEvaluation
  participant PlaygroundNewEvaluationSheet
  participant NewEvaluationSheet
  PlaygroundWorkspace->>PlaygroundNewEvaluation: Render with saved revision IDs
  PlaygroundNewEvaluation->>PlaygroundNewEvaluationSheet: Open with selected revision IDs
  PlaygroundNewEvaluationSheet->>NewEvaluationSheet: Pass initial picks after workflow data loads
Loading
sequenceDiagram
  participant PlaygroundTestsetMenu
  participant runTraceIds
  participant PlaygroundAddToTestset
  participant AddToTestsetSheet
  PlaygroundTestsetMenu->>runTraceIds: Collect successful run trace IDs
  PlaygroundTestsetMenu->>PlaygroundAddToTestset: Open with selected trace IDs
  PlaygroundAddToTestset->>AddToTestsetSheet: Pass root span IDs after summaries load
Loading

Possibly related PRs

Merge Risk: Moderate · up to 54756

Runs without trace IDs can be omitted from a test set or leave the action disabled. Resolve trace handling before merging; loading feedback and incorrect labels remain bounded concerns.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely identifies both primary changes: opening New Evaluation and Add to test set from the playground.
Description check Passed The description directly explains the playground wiring, behavior, permissions, loading, tests, and QA steps for both features.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 10 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@mmabrouk
mmabrouk changed the base branch from feat/m-view-playground-links to main November 4, 2026 21:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Nitpick comments: 4
web/mobile/src/features/playground/PlaygroundAddToTestset.tsx: 2

9-14: Trivial · Maintainability & Code Quality · Low value

Shorten the multi-line block comment to one line.

The repository rule limits each comment to one short line. This block spans six lines of prose about why the component behaves as it does. The line break in the middle of a sentence also hurts readability.

♻️ Proposed fix
-/**
- * "Add to test set" from the playground, as in /w: every finished run goes to the sheet as the
- * root span of its trace, which holds the run's inputs and outputs. The sheet opens when every
- * run's span is known. If one is missing,
- * nothing opens: a sheet with some of the runs would add fewer rows than the page shows.
- */
+/** Opens the sheet only when every run's root span is known; a partial sheet would add fewer rows. */

As per coding guidelines: "At most ONE short line per comment. No multi-line blocks narrating why in prose."

Source: Coding guidelines


42-42: Trivial · Functional Correctness · Quick win

Show loading feedback while the trace summaries are pending.

While any summary is pending, spanIds is null and the component renders nothing. The user picks "Add to test set" and sees no change until every trace loads. A slow trace read looks like a dead menu item, and the user may click again.

Render a loading state in this period. A toast or a skeleton sheet both work. Keep the existing error path for the failed case.

As per coding guidelines: "Every screen and every data-bearing component defines loading, empty, error ... states as first-class sibling components".

Source: Coding guidelines

web/mobile/tests/unit/playgroundAddToTestset.render.test.tsx: 1

2-7: Trivial · Maintainability & Code Quality · Low value

Shorten the file header comment.

The repository rule limits each comment to one short line. This header is a six-line block. Reduce it to one line, for example: "Add to test set from the playground, over real run and trace stores; only HTTP is mocked."

As per coding guidelines: "At most ONE short line per comment."

Source: Coding guidelines

web/mobile/src/features/playground/usePlaygroundSelection.ts: 1

118-120: Trivial · Maintainability & Code Quality · Quick win

Shorten multi-line in-code comments to one line.

The frontend conventions set a hard limit of one short line per comment. The new code in this file breaks that limit. Examples are the comment blocks at Lines 118-120, 141-142, 189-190 and 205-206. The new doc blocks in playgroundSnapshot.ts and tracePlayground.ts break it in the same way.

Keep a longer comment only where it explains a surprising constraint, such as a race or an ordering requirement. The restore token comment at Lines 141-142 and the "write mid-read" comment in syncSnapshotDrafts are the likely candidates. Reduce the other comments to one line each.

As per coding guidelines: "At most ONE short line per comment. No multi-line blocks narrating why, no restating what the code shows."

Source: Coding guidelines

Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d1c6dd2 and 6ee4a6e.

Files selected for processing: 45
  • web/mobile/src/features/app/GlobalDrawers.tsx
  • web/mobile/src/features/evaluators/EvaluatorsDrawer.tsx
  • web/mobile/src/features/evaluators/EvaluatorsScreen.tsx
  • web/mobile/src/features/observability/bindTraceDrawerSeams.ts
  • web/mobile/src/features/observability/tracePlayground.ts
  • web/mobile/src/features/playground/PlaygroundAddToTestset.tsx
  • web/mobile/src/features/playground/PlaygroundFocusDrawerHost.tsx
  • web/mobile/src/features/playground/PlaygroundNewEvaluation.tsx
  • web/mobile/src/features/playground/PlaygroundNewEvaluationSheet.tsx
  • web/mobile/src/features/playground/PlaygroundTestsetMenu.tsx
  • web/mobile/src/features/playground/PlaygroundWorkspace.tsx
  • web/mobile/src/features/playground/playgroundLastSelection.ts
  • web/mobile/src/features/playground/playgroundRunTraces.ts
  • web/mobile/src/features/playground/playgroundSnapshot.ts
  • web/mobile/src/features/playground/playgroundUrl.ts
  • web/mobile/src/features/playground/usePlaygroundAddToQueue.tsx
  • web/mobile/src/features/playground/usePlaygroundSelection.ts
  • web/mobile/src/features/prompts/PromptsList.tsx
  • web/mobile/src/features/prompts/PromptsScreen.tsx
  • web/mobile/src/features/prompts/promptRowActions.ts
  • web/mobile/src/features/revisions/OpenInPlaygroundButton.tsx
  • web/mobile/src/features/variants/DeploymentsTab.tsx
  • web/mobile/src/features/variants/VariantRowCells.tsx
  • web/mobile/src/features/variants/VariantRowMenu.tsx
  • web/mobile/src/features/variants/VariantsScreen.tsx
  • web/mobile/src/features/variants/VariantsTab.tsx
  • web/mobile/src/features/variants/VariantsTable.tsx
  • web/mobile/tests/unit/playgroundAddToQueue.test.tsx
  • web/mobile/tests/unit/playgroundAddToTestset.render.test.tsx
  • web/mobile/tests/unit/playgroundLinks.test.ts
  • web/mobile/tests/unit/playgroundNewEvaluation.render.test.tsx
  • web/mobile/tests/unit/playgroundRevisionActions.render.test.tsx
  • web/mobile/tests/unit/playgroundSelection.test.tsx
  • web/mobile/tests/unit/playgroundSnapshot.test.tsx
  • web/mobile/tests/unit/promptsScreen.render.test.tsx
  • web/mobile/tests/unit/traceDrawerQuery.test.ts
  • web/mobile/tests/unit/variantsScreen.render.test.tsx
  • web/packages/agenta-observability-ui/src/traceDrawer/TraceTypeHeader.tsx
  • web/packages/agenta-playground-ui/src/panels/focus/FocusDrawer.tsx
  • web/packages/agenta-playground/src/index.ts
  • web/packages/agenta-playground/src/state/controllers/playgroundController.ts
  • web/packages/agenta-playground/tests/unit/restoreLoadableConnection.test.ts
  • web/storybook/stories/developer-views/PromptsScreen.stories.tsx
  • web/storybook/stories/developer-views/VariantsScreen.stories.tsx
  • web/storybook/stories/playground/FocusDrawer.stories.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Item Value
Status stopped
Commit 5475634d2e4e75d54fcd9ef2b72452882c2757d7
Manual expiry (UTC) Not granted
CI deadline (UTC) Not granted
Workflow https://github.com/Agenta-AI/agenta/actions/runs/42067327925

Provisioning failed; no manual review time granted. Environment absence verified; retained storage requires separate provider accounting.

Post /preview as a new comment to request a one-hour preview. Repeating it while active does not extend the hour.
Preview data is disposable. Expiry is enforced by the next successful cleanup sweep, not an exact timer.
Environment deletion stops its compute. Provider-retained storage and permanent services may still be billed.

@mmabrouk
mmabrouk changed the base branch from main to release/v0.128.8 November 5, 2026 16:11
…layground

A row added in the focus drawer has no saved id, so the drawer showed a
disabled Add to queue control. It now shows none.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Major · Do not drop runs without a trace ID before the completeness check. · playgroundRunTraces.ts:15-27

web/mobile/src/features/playground/playgroundRunTraces.ts:15-27
Major · Data Integrity & Integration · Quick win

Do not drop runs without a trace ID before the completeness check.

runTraceIds removes runs whose traceId is missing. PlaygroundAddToTestset then compares the remaining span count with the remaining ID count, so it cannot detect the gap. A successful run or repeat can have no trace ID when the invoke response lacks trace_id and tree_id. The sheet can then open with only the other runs. The component's documented contract says it must show an error instead.

Keep the missing entries in the list. The component then sees a span count below the run count and shows the error.

Suggested fix

--- a/web/mobile/src/features/playground/playgroundRunTraces.ts
+++ b/web/mobile/src/features/playground/playgroundRunTraces.ts
@@
-export const runTraceIds = (get: Getter, loadableId: string): string[] => {
+export const runTraceIds = (get: Getter, loadableId: string): (string | null)[] => {
@@
-                ? result.repetitions.map((repeat) => repeat.traceId)
-                : [result.traceId],
+                ? result.repetitions.map((repeat) => repeat.traceId ?? null)
+                : [result.traceId ?? null],
@@
-              .map((execution) => execution.traceId)
+              .map((execution) => execution.traceId ?? null)
@@
-    return [...new Set([...runs, ...turns])].filter((id): id is string => Boolean(id))
+    return [...new Set([...runs, ...turns])]
--- a/web/mobile/src/features/playground/PlaygroundAddToTestset.tsx
+++ b/web/mobile/src/features/playground/PlaygroundAddToTestset.tsx
@@
-    traceIds: string[]
+    traceIds: (string | null)[]
@@
-                const summaries = traceIds.map((id) => get(traceDataSummaryAtomFamily(id)))
+                const summaries = traceIds.map((id) =>
+                    id ? get(traceDataSummaryAtomFamily(id)) : null,
+                )
                 if (summaries.some((summary) => summary?.isPending)) return null
-                const ids = summaries.flatMap((summary) => summary.rootSpan?.span_id ?? [])
+                const ids = summaries.flatMap((summary) => summary?.rootSpan?.span_id ?? [])
Minor · Enable "Add to test set" when a run succeeds, without… · PlaygroundTestsetMenu.tsx:100-113

web/mobile/src/features/playground/PlaygroundTestsetMenu.tsx:100-113
Minor · Functional Correctness · Quick win

Enable "Add to test set" when a run succeeds, without requiring a trace ID.

PlaygroundTestsetMenu passes onAddToTestset whenever the user has edit_testsets. The item is disabled by model.hasSuccessfulResults. That predicate requires a truthy traceId, so a successful run with a null trace ID leaves the item disabled. The empty-list error path in PlaygroundAddToTestset is never reached. The PR intends the item to enable on success.

The predicate has no other consumer in the inspected code. The change affects only this menu item.

Suggested fix

-                    if (results.some((result) => result?.status === "success" && result.traceId)) {
+                    if (results.some((result) => result?.status === "success")) {
                         return true
                     }
@@
-                        (execution) => execution?.status === "complete" && !!execution.traceId,
+                        (execution) => execution?.status === "complete",
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6ee4a6e and 5475634.

Files selected for processing: 2

  • web/mobile/src/features/playground/usePlaygroundAddToQueue.tsx
  • web/mobile/tests/unit/playgroundAddToQueue.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@mmabrouk
mmabrouk merged commit d63692d into release/v0.128.8 Nov 5, 2026
61 of 62 checks passed
@mmabrouk mmabrouk mentioned this pull request Nov 5, 2026
7 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant