Enable 2-4 column comparisons with per-variant version/model selection, persisted layout/results, and evaluation actions aligned to output.
6.8 KiB
Test Area Version/Model Selection (basic-user first)
1. Background
In the current /basic/user workspace, the right-side test area implicitly tests:
- "original" =
session.prompt(v0) - "optimized" =
session.optimizedPrompt(whatever is currently in the optimized editor) - model =
session.selectedTestModelKey(single shared model)
This creates hard coupling between test inputs and the editor textareas. Users want to compare arbitrary versions (v0..vn) and also compare the same version under different models.
2. Scope
Phase 1 (this doc): implement only for /basic/user.
Out of scope for phase 1:
/basic/system,/pro/*,/image/*rollout- draft/unsaved text selection
- one-click "latest two versions" shortcut (can be added later)
3. Requirements
Functional:
- Each test result panel has independent selectors:
- prompt version: v0..vn plus
latest - model key
- prompt version: v0..vn plus
- Default selection is v0 vs latest(vn).
- Compare mode runs both tests in parallel.
- Version chain is session-scoped and isolated per sub-mode.
Non-functional:
- Backward compatible with existing persisted sessions.
- Missing/invalid version selection must gracefully fall back.
- No new "draft" state.
4. Current Implementation Touchpoints
- Basic-user workspace:
packages/ui/src/components/basic-mode/BasicUserWorkspace.vue - Basic test logic:
packages/ui/src/composables/workspaces/useBasicWorkspaceLogic.ts#handleTest - Session store:
packages/ui/src/stores/session/useBasicUserSession.ts - Test UI components:
packages/ui/src/components/TestAreaPanel.vuepackages/ui/src/components/TestResultSection.vuepackages/ui/src/components/TestControlBar.vue
- History chain types:
packages/core/src/services/history/types.ts
5. Data Model
5.1 Persisted selector value
Use a JSON-serializable union value:
// 0 represents v0.
// number >= 1 represents v1..vn.
// 'latest' follows the max version in the chain.
export type TestPanelVersionValue = 0 | number | 'latest'
5.2 Per-panel config
export interface TestPanelConfig {
version: TestPanelVersionValue
modelKey: string
}
export interface BasicUserTestPanelsConfig {
original: TestPanelConfig
optimized: TestPanelConfig
}
5.3 Session store changes (basic-user)
Add to BasicUserSessionState:
testPanels?: BasicUserTestPanelsConfig
Add update helpers (exact names can vary):
updateTestPanelVersion(panel: 'original'|'optimized', v: TestPanelVersionValue)updateTestPanelModel(panel: 'original'|'optimized', modelKey: string)
Persist these inside the existing preference key session/v1/basic-user.
5.4 Migration / Defaults
When restoring session state:
- If
testPanelsis missing (legacy session):original.version = 0optimized.version = 'latest'original.modelKey = parsed.selectedTestModelKey || fallbackModelKeyoptimized.modelKey = parsed.selectedTestModelKey || fallbackModelKey
If any selected model key is not in enabled models, apply the existing fallback strategy (first enabled model).
6. Version Resolver
At test time (not at render time), resolve selection into actual prompt text.
Inputs:
v0Prompt: string(fromsession.prompt)chainVersions: PromptRecord[](fromlogic.currentVersions)selected: TestPanelVersionValue
Algorithm:
- If
selected === 0: returnv0Prompt. - Let
latestRecord = max(chainVersions, by record.version). - If
selected === 'latest':- return
latestRecord.optimizedPromptif present - else return
v0Prompt
- return
- If
selectedis a number >= 1:- find record with
record.version === selected - if found return its
optimizedPrompt - else fall back to latest (step 3)
- find record with
Note: history chain versions start at 1, so v0 is always external.
7. UI Design (basic-user)
7.1 Control placement
To avoid ambiguity, place selectors in each result card header:
- Original result header: version select + model select
- Optimized result header: version select + model select
The main TestControlBar retains:
- compare mode toggle
- start test button
7.2 Component changes
TestResultSection.vue:
- Add optional header slots:
original-header-extraoptimized-header-extrasingle-header-extra(optional)
Render them next to the title (and before/after evaluation entry).
TestAreaPanel.vue:
- Pass through these slots from
TestAreaPaneltoTestResultSection.
BasicUserWorkspace.vue:
- Build version options list:
- always include
v0 - include
latestif chain exists (still allowed if empty; it falls back) - include
v1..vnderived fromlogic.currentVersions
- always include
- Bind
v-modelof each select to session storetestPanelsstate. - Remove the single model select slot usage for basic-user; instead provide per-panel model selects via the new header slots.
7.3 Titles
Keep existing i18n titles but append selection info for clarity, e.g.
原始提示词结果 (v0)优化后提示词结果 (latest=v6)
This can be implemented by computing originalResultTitle and optimizedResultTitle from the selected values.
8. Test Execution (basic-user)
Update the test handler for /basic/user so that it no longer depends on editor textareas.
Compare mode ON:
- Resolve both prompt texts (left/right) using the resolver.
- Execute both tests in parallel:
- left uses
testPanels.original.modelKey - right uses
testPanels.optimized.modelKey
- left uses
- Stream results into the existing
testResultsshape:originalResult/originalReasoningoptimizedResult/optimizedReasoning
Compare mode OFF:
- Only run the "optimized" panel test.
9. Evaluation Alignment
Current evaluation logic assumes:
- originalPrompt/optimizedPrompt are the prompts being evaluated
- originalResult/optimizedResult are the corresponding outputs
After this change, the evaluation handler in BasicUserWorkspace.vue must be bound to:
originalPrompt = resolvedPrompt(original panel)optimizedPrompt = resolvedPrompt(optimized panel)
So that "compare evaluation" reflects the actual selected versions.
10. Edge Cases
- No history chain yet (only v0):
latestresolves to v0.
- Selected fixed version does not exist anymore:
- fall back to latest.
- Model key invalid/unavailable:
- fall back to first enabled model.
- User selects the same version and same model on both sides:
- allowed; results should be identical unless provider variance.
11. Implementation Plan (basic-user)
- Extend
useBasicUserSessionwithtestPanelspersisted state and migration defaults. - Add header slots to
TestResultSectionand pass-through inTestAreaPanel. - Implement selectors in
BasicUserWorkspaceand bind to session store. - Update test execution to resolve prompts by selection and run in parallel.
- Bind evaluation handler prompts to resolved prompts.
- Update unit/integration/e2e tests for basic-user as needed.