Skip to content

Preserve model landing handoffs in Playground - #673

Open
think-back wants to merge 3 commits into
mainfrom
fix/model-playground-handoff-20260808
Open

Preserve model landing handoffs in Playground#673
think-back wants to merge 3 commits into
mainfrom
fix/model-playground-handoff-20260808

Conversation

@think-back

Copy link
Copy Markdown
Collaborator

Summary

  • Route model landing page CTAs directly to Console /playground with the landing model id and example prompt in search params.
  • Initialize Playground with the requested model before async model lists resolve, including filtered image models such as gpt-image-2.
  • Keep the handoff prompt as editable input, remove replayable URL/draft state only after explicit submit, and avoid automatic generation.

Test Plan

  • bun test src/features/playground/index.test.tsx src/features/playground/lib/playground-handoff.test.ts src/routes/_authenticated/playground/-index.test.ts from web/default (12 pass)
  • bun test src/components/model-landing-page.test.tsx from website (3 pass)
  • bun run typecheck from web/default
  • bun run typecheck from website
  • bun x eslint src/features/playground/hooks/use-playground-state.ts src/features/playground/index.tsx src/features/playground/lib/index.ts src/routes/_authenticated/playground/index.tsx src/features/playground/index.test.tsx src/features/playground/lib/playground-handoff.ts src/features/playground/lib/playground-handoff.test.ts from web/default
  • bun x eslint src/components/model-landing-page.tsx src/components/model-landing-page.test.tsx from website
  • bun run build:check from web/default
  • bun run build from website
  • git diff --check

Known baseline failures

  • web/default: full bun test reports 1254 pass / 11 fail; failures remain in SMTP settings, subscription purchase/payment request-id tests, subscription fallback normalization, and refundable billing display tests outside this change.
  • website: full bun test reports 202 pass / 6 fail; failures remain in Japanese contact copy, docs link settings, and perf metrics default group proxy tests outside this change.

Not tested

  • Browser-level clickthrough against deployed staging Website and Console.

Constraint: Model landing actions must open Console Playground with a draft prompt instead of triggering generation immediately.

Rejected: Reusing the previous generate search flag | It caused auto-submit behavior and did not keep the prompt editable.

Confidence: high

Scope-risk: moderate

Tested: bun test src/features/playground/index.test.tsx src/routes/_authenticated/playground/-index.test.ts

Not-tested: Browser-level staging clickthrough against deployed Console.
Constraint: Landing page CTA must carry model and prompt into /playground without nested sign-up redirect state.

Rejected: Keeping /sign-up?redirect=/playground | It prevents a direct Playground handoff and keeps replayable state nested.

Confidence: high

Scope-risk: narrow

Tested: bun test src/components/model-landing-page.test.tsx

Not-tested: Browser-level staging clickthrough against deployed Website and Console.
Constraint: The handoff must preserve the landing model id and prompt as editable Playground input without auto-submission.

Rejected: Covering only URL validation | It would miss the filtered-model and first-render Playground state regressions.

Confidence: high

Scope-risk: narrow

Tested: bun test src/features/playground/index.test.tsx src/features/playground/lib/playground-handoff.test.ts src/routes/_authenticated/playground/-index.test.ts; bun test src/components/model-landing-page.test.tsx

Not-tested: Full e2e browser automation against staging.
@KingCesc

KingCesc commented Aug 8, 2026

Copy link
Copy Markdown

🤖 OpenCodeReview · 评审 commit 9690b2d4 · 共 2 条

web/default/src/features/playground/lib/playground-handoff.ts

  • L57-59: [阻塞] 这里把外部传入的 model 直接补进可选模型列表,会绕过 input.models(当前用户实际可用模型集合)的约束;后续 UI 会把该模型视为有效并可提交,可能导致构造 URL 调用未开放/不可用模型,带来越权、计费或请求失败风险。建议仅在模型存在于后端返回的可用模型白名单时应用 handoff;如需要展示未知模型,应只作为提示,不要加入可提交的选项列表。
const isKnownModel = model
    ? models.some((option) => option.value === model)
    : false

web/default/src/features/playground/index.tsx

  • L222-229: [阻塞] 这里会把外部传入的 model 直接补进可选模型列表并作为可提交配置使用;结合路由层仅做 trim(),用户可以构造任意模型 ID 进入 Playground。若后续请求链路依赖前端模型列表做可用性/权限约束,可能导致未开放模型被调用、计费/额度异常或核心请求失败。建议只允许当前用户可用模型集合或明确的后端白名单中的模型进入 handoff;未知模型最多展示为提示,不应直接加入可选项并用于提交。
const isKnownAvailableModel = models.some((option) => option.value === model)
  if (model && !isKnownAvailableModel) {
    return {
      models,
      ...(prompt ? { prompt } : {}),
    }
  }

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.

2 participants