feat(kanban): pick a task's model and thinking depth from the board

The desktop board had no model control at all: a task ran whatever the profile
you assigned it to happened to be configured with, and the only way to point
one task elsewhere was `hermes kanban set-model` or the browser dashboard's
flat provider:model select.

Adds a Model row to New Task and to the task drawer, rendering the composer's
own picker via the SDK — same search, same provider groups, same submenu — so
the board and the chat bar cannot drift. Unset reads "Profile default" and
changes nothing; a pin reads "provider: model · High" with an inline clear.

Presets are read-only here: picking a model seeds the depth from what you last
used for it, but a per-task choice never rewrites what the composer opens at.
Fast mode is omitted rather than shown-and-ignored — it's a live-session
request parameter with no worker-spawn equivalent.

The New Task dialog opts out of DialogContent's clip: the dialog publishes
itself as the portal container for popovers opened inside it, so its
overflow-y-auto cropped the menu at the dialog's edge. The general fix is in
flight as #75600; this override is scoped to one dialog to avoid conflicting
with it and disappears when that lands.
This commit is contained in:
Brooklyn Nicholson
2026-08-01 16:10:25 -05:00
parent b35c34d58c
commit 602fc5f9f5
6 changed files with 377 additions and 1 deletions
+23 -1
View File
@@ -78,6 +78,12 @@ import {
} from './api'
import { BoardSwitcher } from './board-switcher'
import { TaskDrawer } from './drawer'
import {
EMPTY_OVERRIDE,
ModelOverrideField,
overrideCreateFields,
type TaskModelOverride
} from './model-override'
import { OrchestrationPanel } from './orchestration'
import { columnMeta, type KanbanBoard, type KanbanTask, type TaskEstimate } from './types'
import {
@@ -570,6 +576,7 @@ function NewTaskDialog({
// a path here overrides just this task. Only meaningful for dir/worktree.
const [workspacePath, setWorkspacePath] = useState('')
const [parent, setParent] = useState('')
const [modelOverride, setModelOverride] = useState<TaskModelOverride>(EMPTY_OVERRIDE)
const [goalMode, setGoalMode] = useState(false)
const [busy, setBusy] = useState(false)
const [error, setError] = useState<null | string>(null)
@@ -602,6 +609,7 @@ function NewTaskDialog({
setWorkspaceKind(boardDefaultKind)
setWorkspacePath('')
setParent('')
setModelOverride(EMPTY_OVERRIDE)
setGoalMode(false)
setError(null)
setBusy(false)
@@ -637,6 +645,7 @@ function NewTaskDialog({
title: trimmed,
triage: isTriage,
workspace_kind: workspaceKind,
...overrideCreateFields(modelOverride),
// Empty → backend inherits the board's default project dir.
workspace_path: workspaceKind !== 'scratch' && workspacePath.trim() ? workspacePath.trim() : undefined
})
@@ -661,7 +670,15 @@ function NewTaskDialog({
return (
<Dialog onOpenChange={open => !open && onClose()} open={Boolean(target)}>
<DialogContent className="w-[min(42rem,94vw)] max-w-none">
{/* `overflow-visible`: DialogContent publishes ITSELF as the portal
container for popovers opened inside it (dialog-portal-context), and
its default `overflow-y-auto` then crops them at the dialog's edge —
the model menu below is born inside that scroll box. This dialog
already owns a scroller on its body div, so the shell's clip is
redundant here and dropping it is safe. The general fix to
DialogContent is in flight as #75600; when that lands this override
becomes a no-op and can go. */}
<DialogContent className="w-[min(42rem,94vw)] max-w-none overflow-visible">
<DialogHeader>
<DialogTitle>{target ? k.newTaskIn(columnLabel(k, target)) : k.newTask}</DialogTitle>
</DialogHeader>
@@ -742,6 +759,11 @@ function NewTaskDialog({
<Input onChange={event => setSkills(event.target.value)} placeholder={k.skillsPlaceholder} value={skills} />
</Field>
<Field label={k.model}>
<ModelOverrideField onChange={setModelOverride} value={modelOverride} />
<span className="text-[0.625rem] text-(--ui-text-quaternary)">{k.modelHint}</span>
</Field>
{parents.length > 0 && (
<Field label={k.parent}>
<Select onValueChange={v => setParent(v === NO_PARENT ? '' : v)} value={parent || NO_PARENT}>
@@ -45,6 +45,7 @@ import {
taskKey,
uploadAttachment
} from './api'
import { ModelOverrideField, overridePatch } from './model-override'
import {
type Diagnostic,
type DiagnosticAction,
@@ -770,6 +771,16 @@ export function TaskDrawer({
{task.workspace_path}
</MetaRow>
)}
<MetaRow label={k.model}>
<ModelOverrideField
onChange={next => void mutate(() => patchTask(task.id, overridePatch(next)))()}
value={{
effort: task.reasoning_effort ?? '',
model: task.model_override ?? '',
provider: task.provider_override ?? ''
}}
/>
</MetaRow>
{task.created_by && <MetaRow label={k.metaCreatedBy}>{task.created_by}</MetaRow>}
{ago(task.created_at) && <MetaRow label={k.metaCreated}>{ago(task.created_at)}</MetaRow>}
{running && task.worker_pid ? <MetaRow label={k.metaWorkerPid}>{task.worker_pid}</MetaRow> : null}
+20
View File
@@ -65,6 +65,10 @@ type KanbanMessages = {
workspace: string
boardDefaultSuffix: string
workspaceOverride: string
model: string
modelInherit: string
modelClear: string
modelHint: string
workspaceInherit: string
workspaceInheritDir: (dir: string) => string
workspaceInheritGeneric: string
@@ -250,6 +254,10 @@ const en: KanbanMessages = {
workspace: 'Workspace',
boardDefaultSuffix: ' · board default',
workspaceOverride: 'Workspace path (optional override)',
model: 'Model',
modelInherit: 'Profile default',
modelClear: 'Clear model override',
modelHint: 'Runs this task on a specific model and thinking depth. Unset uses the assigned profile’s own.',
workspaceInherit: 'Inherits the board’s project directory',
workspaceInheritDir: dir => `Leave empty to inherit ${dir}`,
workspaceInheritGeneric: 'Leave empty to inherit the board’s project directory.',
@@ -438,6 +446,10 @@ const ja: KanbanMessages = {
workspace: 'ワークスペース',
boardDefaultSuffix: '・ボード既定',
workspaceOverride: 'ワークスペースパス(任意の上書き)',
model: 'モデル',
modelInherit: 'プロファイル既定',
modelClear: 'モデル指定を解除',
modelHint: 'このタスクを特定のモデルと思考深度で実行します。未設定なら担当プロファイルの設定を使用します。',
workspaceInherit: 'ボードのプロジェクトディレクトリを継承',
workspaceInheritDir: dir => `空欄にすると ${dir} を継承します`,
workspaceInheritGeneric: '空欄にするとボードのプロジェクトディレクトリを継承します。',
@@ -624,6 +636,10 @@ const zh: KanbanMessages = {
workspace: '工作区',
boardDefaultSuffix: '・面板默认',
workspaceOverride: '工作区路径(可选覆盖)',
model: '模型',
modelInherit: '配置文件默认',
modelClear: '清除模型覆盖',
modelHint: '让该任务使用指定的模型与思考深度。未设置时使用所指派配置文件自身的设置。',
workspaceInherit: '继承面板的项目目录',
workspaceInheritDir: dir => `留空则继承 ${dir}`,
workspaceInheritGeneric: '留空则继承面板的项目目录。',
@@ -808,6 +824,10 @@ const zhHant: KanbanMessages = {
workspace: '工作區',
boardDefaultSuffix: '・面板預設',
workspaceOverride: '工作區路徑(選填覆寫)',
model: '模型',
modelInherit: '設定檔預設',
modelClear: '清除模型覆寫',
modelHint: '讓此任務使用指定的模型與思考深度。未設定時使用所指派設定檔本身的設定。',
workspaceInherit: '繼承面板的專案目錄',
workspaceInheritDir: dir => `留空則繼承 ${dir}`,
workspaceInheritGeneric: '留空則繼承面板的專案目錄。',
@@ -0,0 +1,148 @@
import { DropdownMenu, DropdownMenuContent, ModelCatalogMenu, type ModelMenuController } from '@hermes/plugin-sdk'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import {
EMPTY_OVERRIDE,
isInherited,
overrideCreateFields,
overrideLabel,
overridePatch,
type TaskModelOverride
} from './model-override'
// Radix calls these on open; jsdom doesn't implement them.
beforeAll(() => {
Element.prototype.scrollIntoView = vi.fn()
Element.prototype.hasPointerCapture = vi.fn(() => false)
Element.prototype.releasePointerCapture = vi.fn()
})
const getGlobalModelOptions = vi.fn()
vi.mock('@/hermes', () => ({
getGlobalModelOptions: (...args: unknown[]) => getGlobalModelOptions(...args),
setApiRequestProfile: vi.fn()
}))
beforeEach(() => {
getGlobalModelOptions.mockResolvedValue({
providers: [{ models: ['gemini-3.1-pro', 'gemini-2.5-flash'], name: 'Google', slug: 'google' }]
})
})
afterEach(() => {
cleanup()
vi.clearAllMocks()
})
describe('override label', () => {
it('reads as inherited until something is pinned', () => {
expect(isInherited(EMPTY_OVERRIDE)).toBe(true)
expect(overrideLabel(EMPTY_OVERRIDE, 'Profile default')).toBe('Profile default')
})
it('shows provider: model · Effort', () => {
expect(overrideLabel({ effort: 'high', model: 'gemini-3.1-pro', provider: 'google' }, 'x')).toBe(
'google: gemini-3.1-pro · High'
)
})
it('a depth-only pin is still an override', () => {
const depthOnly: TaskModelOverride = { effort: 'ultra', model: '', provider: '' }
expect(isInherited(depthOnly)).toBe(false)
expect(overrideLabel(depthOnly, 'Profile default')).toBe('Profile default · Ultra')
})
})
// The override drives the SHARED composer menu through a controller. This is
// the seam that keeps the two surfaces identical, so exercise the real
// component rather than a stand-in.
describe('the shared catalog menu, driven by an override controller', () => {
function renderMenu(value: TaskModelOverride = EMPTY_OVERRIDE) {
const onChange = vi.fn()
const controller: ModelMenuController = {
applyPreset: (preset, row) => onChange({ effort: preset.effort ?? '', model: row.model, provider: row.provider }),
current: { effort: value.effort, fast: false, model: value.model, provider: value.provider },
presetFor: () => ({}),
select: (model, provider) => onChange({ ...value, model, provider }),
setOptions: (patch, row) => {
if (patch.effort !== undefined) {
onChange({ effort: patch.effort, model: row.model, provider: row.provider })
}
}
}
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
render(
<QueryClientProvider client={client}>
<DropdownMenu open>
<DropdownMenuContent>
<ModelCatalogMenu controller={controller} />
</DropdownMenuContent>
</DropdownMenu>
</QueryClientProvider>
)
return onChange
}
it('lists the catalog and reports a picked model', async () => {
const onChange = renderMenu()
// Rows render the display name; the controller receives the raw id.
fireEvent.click(await screen.findByText(/Gemini 3\.1 Pro/i))
const picked = onChange.mock.calls.at(-1)![0]
expect(picked.model).toBe('gemini-3.1-pro')
expect(picked.provider).toBe('google')
})
it('never renders MoA presets — a preset is not a worker model', async () => {
getGlobalModelOptions.mockResolvedValue({
providers: [
{ models: ['gemini-3.1-pro'], name: 'Google', slug: 'google' },
{ models: ['BeastMode'], name: 'Mixture of Agents', slug: 'moa' }
]
})
renderMenu()
await screen.findByText(/Gemini 3\.1 Pro/i)
expect(screen.queryByText(/BeastMode/)).toBeNull()
})
})
// A PATCH body can't say "set to NULL" with a missing key, so clears are
// explicit flags; a create should instead OMIT what the user never touched so
// the backend's own defaults still apply.
describe('REST field mapping', () => {
it('create omits untouched fields', () => {
expect(overrideCreateFields(EMPTY_OVERRIDE)).toEqual({})
expect(overrideCreateFields({ effort: 'high', model: 'm', provider: 'p' })).toEqual({
model_override: 'm',
provider_override: 'p',
reasoning_effort: 'high'
})
})
it('patch clears explicitly', () => {
expect(overridePatch(EMPTY_OVERRIDE)).toEqual({ clear_model_override: true, clear_reasoning_effort: true })
})
it('patch can pin depth alone, leaving the model to the profile', () => {
expect(overridePatch({ effort: 'ultra', model: '', provider: '' })).toEqual({
clear_model_override: true,
reasoning_effort: 'ultra'
})
})
it('a provider is never sent without its model', () => {
expect(overrideCreateFields({ effort: '', model: '', provider: 'google' })).toEqual({})
})
})
@@ -0,0 +1,170 @@
/**
* Per-task model override — the board's half of the composer's model picker.
*
* The MENU is not ours: `ModelCatalogMenu` from the SDK is the same component
* the chat composer renders, so search, provider grouping, `-fast` families,
* and the thinking/effort submenu behave identically here. What differs is
* what a selection MEANS — the controller below holds a detached value instead
* of writing to a live session, which is exactly the seam the SDK exposes.
*
* An unset value means "inherit the assigned profile's own model + effort",
* which is what every kanban task did before this existed.
*/
import {
Button,
cn,
Codicon,
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
ModelCatalogMenu,
ModelMenuCloseContext,
type ModelMenuController,
reasoningEffortLabel
} from '@hermes/plugin-sdk'
import { useState } from 'react'
import { useKanban } from './ui'
/** A task's model override. Empty strings mean "inherit the profile". */
export interface TaskModelOverride {
/** '' = profile default, 'none' = thinking off, else a reasoning level. */
effort: string
model: string
provider: string
}
export const EMPTY_OVERRIDE: TaskModelOverride = { effort: '', model: '', provider: '' }
/** True when nothing is pinned and the worker profile decides everything. */
export const isInherited = (value: TaskModelOverride): boolean =>
!value.model.trim() && !value.provider.trim() && !value.effort.trim()
/** The trigger's label: `provider: model · High`, or the inherit copy. */
export function overrideLabel(value: TaskModelOverride, inheritCopy: string): string {
if (isInherited(value)) {
return inheritCopy
}
const model = value.model.trim()
const base = model ? (value.provider.trim() ? `${value.provider}: ${model}` : model) : inheritCopy
const effort = value.effort.trim() ? reasoningEffortLabel(value.effort) : ''
return effort ? `${base} · ${effort}` : base
}
/**
* The picker itself. Controlled: the caller owns the value, so the New Task
* dialog can hold it as form state and the drawer can PATCH on change.
*/
export function ModelOverrideField({
onChange,
value
}: {
onChange: (next: TaskModelOverride) => void
value: TaskModelOverride
}) {
const k = useKanban()
const [open, setOpen] = useState(false)
const controller: ModelMenuController = {
// Picking a model seeds the depth from what the user last used for it, so
// the board behaves like the composer. We only READ presets — a per-task
// choice must never rewrite what the composer opens at.
applyPreset: (preset, row) =>
onChange({
effort: preset.effort ?? '',
model: row.model,
provider: row.provider
}),
current: { effort: value.effort, fast: false, model: value.model, provider: value.provider },
// Read-only against Hermes' global presets is deliberate: see applyPreset.
presetFor: () => ({}),
select: (model, provider) => {
onChange({ ...value, model, provider })
},
// Fast mode is a live-session request parameter, not something the worker
// spawn can carry (there is no --fast flag), so the menu is told this
// catalog has no fast support and only effort edits arrive here.
setOptions: (patch, row) => {
if (patch.effort === undefined) {
return
}
onChange({ effort: patch.effort, model: row.model, provider: row.provider })
}
}
return (
<DropdownMenu onOpenChange={setOpen} open={open}>
<DropdownMenuTrigger asChild>
<Button
className={cn(
'h-8 w-full justify-between gap-2 px-2.5 text-[0.75rem] font-normal',
isInherited(value) && 'text-(--ui-text-tertiary)'
)}
type="button"
variant="outline"
>
<span className="min-w-0 truncate">{overrideLabel(value, k.modelInherit)}</span>
<span className="flex shrink-0 items-center gap-1">
{!isInherited(value) && (
<span
aria-label={k.modelClear}
className="grid size-4 place-items-center rounded text-(--ui-text-tertiary) hover:text-foreground"
onClick={event => {
// Clear without opening the menu.
event.preventDefault()
event.stopPropagation()
onChange(EMPTY_OVERRIDE)
}}
role="button"
>
<Codicon name="close" size="0.7rem" />
</span>
)}
<Codicon className="opacity-50" name="chevron-down" size="0.7rem" />
</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="w-72 p-0">
<ModelMenuCloseContext.Provider value={() => setOpen(false)}>
<ModelCatalogMenu controller={controller} />
</ModelMenuCloseContext.Provider>
</DropdownMenuContent>
</DropdownMenu>
)
}
/** Translate an override into the REST fields the kanban API expects.
* Used by both create (POST) and edit (PATCH); the explicit clear flags exist
* because `null` in a PATCH body means "field not sent", not "set to NULL". */
export function overridePatch(value: TaskModelOverride): Record<string, unknown> {
const model = value.model.trim()
const effort = value.effort.trim()
return {
...(model
? { model_override: model, provider_override: value.provider.trim() || undefined }
: { clear_model_override: true }),
...(effort ? { reasoning_effort: effort } : { clear_reasoning_effort: true })
}
}
/** The create-time shape: omit rather than clear, so the backend's own
* defaults apply to fields the user never touched. */
export function overrideCreateFields(value: TaskModelOverride): Record<string, unknown> {
const model = value.model.trim()
const effort = value.effort.trim()
return {
...(model ? { model_override: model } : {}),
...(model && value.provider.trim() ? { provider_override: value.provider.trim() } : {}),
...(effort ? { reasoning_effort: effort } : {})
}
}
+5
View File
@@ -97,6 +97,11 @@ export interface KanbanAttachment {
export interface KanbanTaskFull extends KanbanTask {
result?: null | string
created_by?: null | string
/** Per-task worker overrides. Null/absent = the assigned profile's own
* model, provider, and reasoning effort decide. */
model_override?: null | string
provider_override?: null | string
reasoning_effort?: null | string
completed_at?: null | number
last_failure_error?: null | string
workspace_kind?: null | string