summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/testing/model-selection.ts
diff options
context:
space:
mode:
authorShoubhit Dash <[email protected]>2026-04-16 17:30:14 +0530
committerShoubhit Dash <[email protected]>2026-04-16 17:30:14 +0530
commit2e18a603f0ea24154908e748493fd4bfaa74fc00 (patch)
treeb723e00af2821b213573b16fa199b64babd5f1f5 /packages/app/src/testing/model-selection.ts
parent9819eb04614fd607cacb07d754052f1531a82331 (diff)
parent7341718f9234b0cf3a8758c87e91d2006b71bff6 (diff)
downloadopencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.tar.gz
opencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.zip
merge dev
Diffstat (limited to 'packages/app/src/testing/model-selection.ts')
-rw-r--r--packages/app/src/testing/model-selection.ts109
1 files changed, 0 insertions, 109 deletions
diff --git a/packages/app/src/testing/model-selection.ts b/packages/app/src/testing/model-selection.ts
deleted file mode 100644
index d2770fe28..000000000
--- a/packages/app/src/testing/model-selection.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-type ModelKey = {
- providerID: string
- modelID: string
-}
-
-type ModelItem = ModelKey & {
- name: string
-}
-
-type AgentItem = {
- name: string
-}
-
-type State = {
- agent?: string
- model?: ModelKey | null
- variant?: string | null
-}
-
-export type ModelProbeState = {
- dir?: string
- sessionID?: string
- last?: {
- type: "agent" | "model" | "variant"
- agent?: string
- model?: ModelKey | null
- variant?: string | null
- }
- agent?: string
- model?: (ModelKey & { name?: string }) | undefined
- variant?: string | null
- selected?: string | null
- configured?: string
- pick?: State
- base?: State
- current?: string
- variants?: string[]
- models?: ModelItem[]
- agents?: AgentItem[]
-}
-
-export type ModelWindow = Window & {
- __opencode_e2e?: {
- model?: {
- enabled?: boolean
- current?: ModelProbeState
- controls?: {
- setAgent?: (name: string | undefined) => void
- setModel?: (value: ModelKey | undefined) => void
- setVariant?: (value: string | undefined) => void
- }
- }
- }
-}
-
-const clone = (state?: State) => {
- if (!state) return undefined
- return {
- ...state,
- model: state.model ? { ...state.model } : state.model,
- }
-}
-
-let active: symbol | undefined
-
-export const modelEnabled = () => {
- if (typeof window === "undefined") return false
- return (window as ModelWindow).__opencode_e2e?.model?.enabled === true
-}
-
-const root = () => {
- if (!modelEnabled()) return
- return (window as ModelWindow).__opencode_e2e?.model
-}
-
-export const modelProbe = {
- bind(id: symbol, input: NonNullable<NonNullable<ModelWindow["__opencode_e2e"]>["model"]>["controls"]) {
- const state = root()
- if (!state) return
- active = id
- state.controls = input
- },
- set(id: symbol, input: ModelProbeState) {
- const state = root()
- if (!state || active !== id) return
- state.current = {
- ...input,
- model: input.model ? { ...input.model } : undefined,
- last: input.last
- ? {
- ...input.last,
- model: input.last.model ? { ...input.last.model } : input.last.model,
- }
- : undefined,
- pick: clone(input.pick),
- base: clone(input.base),
- variants: input.variants?.slice(),
- models: input.models?.map((item) => ({ ...item })),
- agents: input.agents?.map((item) => ({ ...item })),
- }
- },
- clear(id: symbol) {
- const state = root()
- if (!state || active !== id) return
- active = undefined
- state.current = undefined
- state.controls = undefined
- },
-}