feat(app): make redesigned question dock opt-in (#59723)

This commit is contained in:
usrnk1
2026-10-29 10:59:45 +01:00
committed by GitHub
Unverified
parent 1341387981
commit 7d0f79d2ca
22 changed files with 4495 additions and 2932 deletions
File diff suppressed because it is too large Load Diff
+2
View File
@@ -786,6 +786,8 @@ export const dict = {
"settings.experimental.row.newIcons.description": "Preview the updated icon set",
"settings.experimental.row.foldUserMessages.title": "Fold long messages",
"settings.experimental.row.foldUserMessages.description": "Fold your messages past 12 lines behind a Read more button",
"settings.experimental.row.newQuestionUI.title": "New question UI",
"settings.experimental.row.newQuestionUI.description": "Preview the keyboard-first question dock",
"settings.plugins.reload": "Reload",
"settings.plugins.status.loading": "Loading",
"settings.plugins.status.failed": "Failed",
@@ -3,6 +3,7 @@ import { SessionElicitationDock } from "@/session/requests/session-elicitation-d
import { SessionPermissionDock } from "@/session/requests/session-permission-dock"
import { SessionQuestionDock } from "@/session/requests/session-question-dock"
import { questionMotion } from "@/session/requests/question-motion"
import { useSettings } from "@/settings/model"
import { SessionWebSearchDock } from "@/session/requests/session-websearch-dock"
import type { SessionComposerRegionController } from "./session-composer-region-controller"
import { ComposerMorph, Grow } from "./spring-height"
@@ -30,6 +31,7 @@ export function SessionComposerRegion(props: {
subagent: JSX.Element
}) {
const controller = props.controller
const settings = useSettings()
const face = createMemo(() => {
const websearch = controller.state.websearch.request()
@@ -56,7 +58,10 @@ export function SessionComposerRegion(props: {
>
<div class="relative z-[70] flex flex-col">
{props.above}
<ComposerMorph face={face()} instant={(face) => !!face.question && !questionMotion()}>
<ComposerMorph
face={face()}
instant={(face) => !!face.question && (!settings.general.newQuestionUI() || !questionMotion())}
>
{(current) => (
<div class="flex flex-col">
<Grow when={current().websearch} fade card class={controller.child() ? "mb-2" : undefined}>
@@ -64,7 +69,7 @@ export function SessionComposerRegion(props: {
</Grow>
<Grow
when={current().question}
instant={!questionMotion()}
instant={!settings.general.newQuestionUI() || !questionMotion()}
fade
card
class={controller.child() ? "mb-2" : undefined}
@@ -1,5 +1,6 @@
import { activeQuestionRequest, questionPendingDocument } from "@opencode/session-ui/storybook"
import { SessionPreview } from "./story-model"
import { SettingsExperimental } from "@/settings/experimental/experimental"
export default {
title: "OpenCode/Session/Question switch",
@@ -12,13 +13,25 @@ export default {
docs: {
description: {
component:
"A pending question dock with five questions of different heights. Step through them with ← and →, or the Replay buttons under Knobs → Timeline → Question. Its motion is off until Question dock motion is turned on there.",
"Compare the original question cards with the New question UI experiment. With the experiment enabled, step through questions with ← and →. Its motion is off until Question dock motion is turned on under Knobs → Timeline → Question.",
},
},
},
}
// Several questions of different lengths and kinds in a row, to step through with ← and →.
export const Experiments = {
render: () => (
<SessionPreview
title="Choose a Session layout"
description="opencode · question UI experiments"
document={questionPendingDocument}
request={{ type: "question", value: activeQuestionRequest }}
side={<SettingsExperimental />}
/>
),
}
// Several questions of different lengths and kinds in a row.
export const QuestionSeries = {
render: () => (
<SessionPreview
@@ -0,0 +1,4 @@
export const questionCache = new Map<
string,
{ tab: number; answers: string[][]; custom: string[]; customOn: boolean[] }
>()
@@ -0,0 +1,809 @@
import { For, Show, createEffect, createMemo, onCleanup, onMount, type Component } from "solid-js"
import { createStore } from "solid-js/store"
import { useMutation } from "@tanstack/solid-query"
import { Button } from "@opencode/ui/button"
import { IconButton } from "@opencode/ui/icon-button"
import { Tooltip } from "@opencode/ui/tooltip"
import { DockPrompt } from "@opencode/session-ui/dock-prompt"
import { Icon } from "@opencode/ui/icon"
import { Keybind } from "@opencode/ui/keybind"
import { TextInput } from "@opencode/ui/text-input"
import { useSpring } from "@opencode/ui/motion-spring"
import { observeReducedMotion, prefersReducedMotion } from "@opencode/ui/motion"
import { showToast } from "@/shell/notifications/toast"
import type { FormAnswer, FormInfo, FormMultiselectField, FormStringField } from "@opencode/client/promise"
import { useLanguage } from "@/runtime/i18n/language"
import { makeEventListener } from "@solid-primitives/event-listener"
import { createResizeObserver } from "@solid-primitives/resize-observer"
import { useServerSDK } from "@/runtime/server/client"
import { ScopedKey } from "@/runtime/server/scope"
import { useCommand } from "@/shell/commands/command"
import { questionCache } from "./question-state"
const IS_MAC = /(Mac|iPod|iPhone|iPad)/.test(navigator.platform)
type QuestionField = FormStringField | FormMultiselectField
function questionField(field: FormInfo["fields"][number]): field is QuestionField {
return field.type === "string" || field.type === "multiselect"
}
function Mark(props: { multi: boolean; picked: boolean }) {
return (
<span data-slot="question-option-check" aria-hidden="true">
<span data-slot="question-option-box" data-type={props.multi ? "checkbox" : "radio"} data-picked={props.picked}>
<Show when={props.multi} fallback={<span data-slot="question-option-radio-dot" />}>
<Icon name="check" size="normal" />
</Show>
</span>
</span>
)
}
function Option(props: {
multi: boolean
picked: boolean
label: string
description?: string
number: number
disabled: boolean
ref?: (el: HTMLButtonElement) => void
onFocus?: VoidFunction
onClick: VoidFunction
}) {
return (
<button
type="button"
ref={props.ref}
data-slot="question-option"
data-picked={props.picked}
role={props.multi ? "checkbox" : "radio"}
aria-checked={props.picked}
aria-keyshortcuts={props.number <= 9 ? String(props.number) : undefined}
disabled={props.disabled}
onFocus={props.onFocus}
onClick={props.onClick}
>
<Mark multi={props.multi} picked={props.picked} />
<span data-slot="question-option-main">
<span data-slot="option-label">
<bdi>{props.label}</bdi>
</span>
<Show when={props.description}>
<span data-slot="option-description">
<bdi>{props.description}</bdi>
</span>
</Show>
</span>
<Show when={props.number <= 9}>
<Keybind
keys={[String(props.number)]}
variant={props.picked ? "outline" : "neutral"}
data-slot="question-option-shortcut"
aria-hidden="true"
/>
</Show>
</button>
)
}
export const SessionQuestionDockClassic: Component<{ request: FormInfo; onSubmit: () => void }> = (props) => {
const serverSDK = useServerSDK()
const language = useLanguage()
const command = useCommand()
const cacheKey = ScopedKey.from(serverSDK.scope, props.request.id)
const questions = createMemo(() =>
props.request.fields.filter(questionField).map((field) => ({
field,
header: field.title ?? "",
question: field.description ?? field.title ?? "",
options: field.type === "string" ? (field.options ?? []) : field.options,
multiple: field.type === "multiselect",
})),
)
const total = createMemo(() => questions().length)
const cached = questionCache.get(cacheKey)
const [store, setStore] = createStore({
tab: cached?.tab ?? 0,
answers: cached?.answers ?? [],
custom: cached?.custom ?? [],
customOn: cached?.customOn ?? [],
editing: false,
keyboard: false,
reducedMotion: prefersReducedMotion(),
focus: 0,
minimized: false,
optionsHeight: 180,
})
onCleanup(observeReducedMotion(() => setStore("reducedMotion", prefersReducedMotion())))
let root: HTMLDivElement | undefined
let optionsRef: HTMLDivElement | undefined
let customRef: HTMLButtonElement | undefined
let customInput: HTMLInputElement | undefined
let optsRef: HTMLButtonElement[] = []
let replied = false
let focusFrame: number | undefined
const question = createMemo(() => questions()[store.tab])
const options = createMemo(() => question()?.options ?? [])
const input = createMemo(() => store.custom[store.tab] ?? "")
const on = createMemo(() => store.customOn[store.tab] === true)
const multi = createMemo(() => question()?.multiple === true)
const count = createMemo(() => options().length + 1)
const summary = createMemo(() => {
if (total() === 1) return language.t("session.question.title")
const n = Math.min(store.tab + 1, total())
return language.t("session.question.progress", { current: n, total: total() })
})
const customLabel = () => language.t("ui.question.custom.answerPlaceholder")
const last = createMemo(() => store.tab >= total() - 1)
const collapse = useSpring(
() => (store.minimized ? 1 : 0),
{ visualDuration: 0.3, bounce: 0 },
() => (store.reducedMotion || store.keyboard ? store.minimized : undefined),
)
const hidden = createMemo(() => Math.max(0, Math.min(1, collapse())))
const optionsOff = createMemo(() => hidden() > 0.98)
const customUpdate = (value: string, selected: boolean = on()) => {
const prev = input().trim()
const next = value.trim()
setStore("custom", store.tab, value)
if (!selected) return
if (multi()) {
setStore("answers", store.tab, (current = []) => {
const removed = prev ? current.filter((item) => item.trim() !== prev) : current
if (!next) return removed
if (removed.some((item) => item.trim() === next)) return removed
return [...removed, next]
})
return
}
setStore("answers", store.tab, next ? [next] : [])
}
const measure = () => {
if (!root) return
const scroller = document.querySelector('[data-slot="session-timeline-scroll"] > .scroll-view__viewport')
const head = scroller instanceof HTMLElement ? scroller.firstElementChild : undefined
const top =
head instanceof HTMLElement && head.classList.contains("sticky")
? head.getBoundingClientRect().bottom
: scroller instanceof HTMLElement
? scroller.getBoundingClientRect().top
: 0
const dock = root.closest('[data-component="session-composer-dock"]')
// In the app this row can have zero height and overflow upward; the containing panel bounds the question.
const column = bounds(dock?.parentElement)
const bottom = Math.min(window.innerHeight, column?.bottom ?? window.innerHeight)
const around =
dock instanceof HTMLElement
? Math.max(0, dock.getBoundingClientRect().height - root.getBoundingClientRect().height)
: 0
const gap = 8
const max = Math.max(240, Math.floor(bottom - Math.max(0, top, column?.top ?? 0) - around - gap))
root.style.setProperty("--question-prompt-max-height", `${max}px`)
}
const clamp = (i: number) => Math.max(0, Math.min(count() - 1, i))
const pickFocus = (tab: number = store.tab) => {
const list = questions()[tab]?.options ?? []
if (store.customOn[tab] === true) return list.length
return Math.max(
0,
list.findIndex((item) => store.answers[tab]?.includes(item.value) ?? false),
)
}
const focus = (i: number) => {
const next = clamp(i)
setStore("focus", next)
if (store.editing) return
if (focusFrame !== undefined) cancelAnimationFrame(focusFrame)
focusFrame = requestAnimationFrame(() => {
focusFrame = undefined
const el = next === options().length ? customRef : optsRef[next]
el?.focus()
})
}
onMount(() => {
let raf: number | undefined
const update = () => {
if (raf !== undefined) cancelAnimationFrame(raf)
raf = requestAnimationFrame(() => {
raf = undefined
measure()
})
}
update()
makeEventListener(window, "resize", update)
const dock = root?.closest('[data-component="session-composer-dock"]')
const scroller = document.querySelector('[data-slot="session-timeline-scroll"] > .scroll-view__viewport')
createResizeObserver([dock, scroller], update)
onCleanup(() => {
if (raf !== undefined) cancelAnimationFrame(raf)
})
focus(pickFocus())
})
createEffect(() => {
const el = optionsRef
if (!el) return
const update = () => setStore("optionsHeight", (height) => Math.max(height, el.scrollHeight))
update()
createResizeObserver(el, update)
})
onCleanup(() => {
if (focusFrame !== undefined) cancelAnimationFrame(focusFrame)
if (replied) return
questionCache.set(cacheKey, {
tab: store.tab,
answers: store.answers.map((a) => (a ? [...a] : [])),
custom: store.custom.map((s) => s ?? ""),
customOn: store.customOn.map((b) => b ?? false),
})
})
const fail = (err: Error) => showToast({ title: language.t("common.requestFailed"), description: err.message })
const replyMutation = useMutation(() => ({
mutationFn: (answer: FormAnswer) =>
serverSDK.api.session.form.reply({ sessionID: props.request.sessionID, formID: props.request.id, answer }),
onMutate: () => {
props.onSubmit()
},
onSuccess: () => {
replied = true
questionCache.delete(cacheKey)
},
onError: fail,
}))
const rejectMutation = useMutation(() => ({
mutationFn: () =>
serverSDK.api.session.form.cancel({ sessionID: props.request.sessionID, formID: props.request.id }),
onMutate: () => {
props.onSubmit()
},
onSuccess: () => {
replied = true
questionCache.delete(cacheKey)
},
onError: fail,
}))
const sending = createMemo(() => replyMutation.isPending || rejectMutation.isPending)
const submitShortcut = () => (IS_MAC ? "⌘⏎" : `${language.t("common.key.ctrl")}+⏎`)
const backShortcut = () => (IS_MAC ? "⌘[" : `${language.t("common.key.alt")}+←`)
const reply = (answer: FormAnswer) => {
if (sending()) return
replyMutation.mutate(answer)
}
const reject = () => {
if (sending()) return
rejectMutation.mutate()
}
const submit = () =>
reply(
Object.fromEntries(
questions().flatMap((question, index) => {
const answers = store.answers[index] ?? []
if (answers.length === 0) return []
return [[question.field.key, question.multiple ? answers : answers[0]]]
}),
),
)
const answered = (i: number) => {
if ((store.answers[i]?.length ?? 0) > 0) return true
return store.customOn[i] === true && (store.custom[i] ?? "").trim().length > 0
}
const picked = (answer: string) => store.answers[store.tab]?.includes(answer) ?? false
const pick = (answer: string) => {
setStore("answers", store.tab, [answer])
setStore("customOn", store.tab, false)
setStore("editing", false)
}
const toggle = (answer: string) => {
setStore("answers", store.tab, (current = []) => {
if (current.includes(answer)) return current.filter((item) => item !== answer)
return [...current, answer]
})
}
const customToggle = () => {
if (sending()) return
setStore("focus", options().length)
if (!multi()) {
setStore("customOn", store.tab, true)
setStore("editing", true)
customUpdate(input(), true)
customInput?.focus()
return
}
const next = !on()
setStore("customOn", store.tab, next)
if (next) {
setStore("editing", true)
customUpdate(input(), true)
customInput?.focus()
return
}
const value = input().trim()
if (value) setStore("answers", store.tab, (current = []) => current.filter((item) => item.trim() !== value))
setStore("editing", false)
focus(options().length)
}
const move = (step: number) => {
if (store.editing || sending()) return
focus(store.focus + step)
}
const nav = (event: KeyboardEvent) => {
if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return
if (event.key === "Escape") {
event.preventDefault()
reject()
return
}
const previous = IS_MAC
? event.metaKey && !event.ctrlKey && !event.altKey && event.key === "["
: event.altKey && !event.ctrlKey && !event.metaKey && event.key === "ArrowLeft"
if (previous) {
if (event.repeat) return
event.preventDefault()
back()
return
}
const mod = (event.metaKey || event.ctrlKey) && !event.altKey
if (mod && event.key === "Enter") {
if (event.repeat) return
event.preventDefault()
next()
return
}
const target =
event.target instanceof HTMLElement ? event.target.closest('[data-slot="question-options"]') : undefined
if (store.editing) return
if (event.altKey || event.ctrlKey || event.metaKey) return
if (/^[1-9]$/.test(event.key)) {
if (event.repeat || store.minimized || sending()) return
const index = Number(event.key) - 1
if (index >= count()) return
event.preventDefault()
if (index === options().length) {
customToggle()
return
}
selectOption(index)
focus(index)
return
}
if (!(target instanceof HTMLElement)) return
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
event.preventDefault()
move(1)
return
}
if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
event.preventDefault()
move(-1)
return
}
if (event.key === "Home") {
event.preventDefault()
focus(0)
return
}
if (event.key !== "End") return
event.preventDefault()
focus(count() - 1)
}
const selectOption = (optIndex: number) => {
if (sending()) return
const opt = options()[optIndex]
if (!opt) return
if (multi()) {
setStore("editing", false)
toggle(opt.value)
return
}
pick(opt.value)
}
const commitCustom = () => {
setStore("editing", false)
customUpdate(input())
focus(options().length)
}
const next = () => {
if (sending()) return
if (store.editing) commitCustom()
if (store.tab >= total() - 1) {
submit()
return
}
jump(store.tab + 1)
}
const back = () => {
if (sending() || store.tab <= 0) return
jump(store.tab - 1)
}
const jump = (tab: number) => {
if (sending() || tab === store.tab) return
setStore("tab", tab)
setStore("editing", false)
if (optionsRef) setStore("optionsHeight", optionsRef.scrollHeight)
if (!store.minimized) focus(pickFocus(tab))
}
command.register("session.question.back", () => [
{
id: "session.question.back",
title: language.t("ui.common.back"),
keybind: IS_MAC ? "mod+[" : "alt+arrowleft",
hidden: true,
// Stay registered while sending so the shortcut does not fall through to history navigation.
disabled: store.tab <= 0,
when: () => store.tab > 0,
onSelect: back,
},
])
const minimize = () => {
if (sending()) return
setStore("editing", false)
setStore("minimized", true)
}
const restore = () => {
if (sending()) return
setStore("minimized", false)
focus(pickFocus())
}
return (
<div
data-component="session-question-dock"
data-keyboard={store.keyboard}
onPointerDown={() => setStore("keyboard", false)}
onKeyDown={() => setStore("keyboard", true)}
>
<DockPrompt
kind="question"
ref={(el) => (root = el)}
onKeyDown={nav}
header={
<>
<div data-slot="question-header-top">
<div data-slot="question-header-title">
<bdi>{summary()}</bdi>
</div>
<div data-slot="question-header-actions">
<Show when={total() > 1}>
<div data-slot="question-progress">
<For each={questions()}>
{(_, i) => (
<button
type="button"
data-slot="question-progress-segment"
data-active={i() === store.tab}
data-answered={answered(i())}
disabled={sending()}
onClick={() => jump(i())}
aria-label={language.t("ui.tool.questions.numbered", { number: i() + 1 })}
aria-current={i() === store.tab ? "step" : undefined}
>
<span data-slot="question-progress-bar" aria-hidden="true" />
</button>
)}
</For>
</div>
</Show>
<IconButton
icon={<Icon name="outline-chevron-down" size="normal" />}
variant="ghost"
size="large"
disabled={sending()}
style={{ transform: `rotate(${hidden() * 180}deg)` }}
onClick={store.minimized ? restore : minimize}
aria-label={language.t(store.minimized ? "session.question.restore" : "session.question.minimize")}
/>
</div>
</div>
<div data-slot="question-details">
<div
data-slot="question-text"
style={{
display: store.minimized ? "-webkit-box" : undefined,
"-webkit-line-clamp": store.minimized ? "3" : undefined,
"-webkit-box-orient": store.minimized ? "vertical" : undefined,
overflow: store.minimized ? "hidden" : undefined,
}}
>
<bdi>{question()?.question}</bdi>
</div>
<Show when={!store.minimized}>
<div data-slot="question-hint">
{language.t(multi() ? "ui.question.classic.multiHint" : "ui.question.singleHint")}
</div>
</Show>
</div>
</>
}
footer={
<>
<Button variant="ghost" size="large" disabled={sending()} onClick={reject} aria-keyshortcuts="Escape">
{language.t("ui.common.dismiss")}
</Button>
<div data-slot="question-footer-actions">
<Show when={store.tab > 0}>
<Tooltip
placement="top"
value={
<>
{language.t("ui.common.back")}
<span style={{ opacity: 0.6 }}>{backShortcut()}</span>
</>
}
>
<Button
variant="neutral"
size="large"
disabled={sending()}
onClick={back}
aria-keyshortcuts={IS_MAC ? "Meta+[" : "Alt+ArrowLeft"}
>
{language.t("ui.common.back")}
</Button>
</Tooltip>
</Show>
<Tooltip
placement="top"
value={
<>
{language.t(last() ? "ui.common.submit" : "ui.common.next")}
<span style={{ opacity: 0.6 }}>{submitShortcut()}</span>
</>
}
>
<Button
variant={last() ? "contrast" : "neutral"}
size="large"
disabled={sending()}
onClick={next}
aria-label={language.t(last() ? "ui.common.submit" : "ui.common.next")}
aria-keyshortcuts="Meta+Enter Control+Enter"
>
<span data-slot="question-advance-labels" aria-hidden="true">
<span data-slot="question-advance-label" data-active={!last()}>
{language.t("ui.common.next")}
</span>
<span data-slot="question-advance-label" data-active={last()}>
{language.t("ui.common.submit")}
</span>
</span>
</Button>
</Tooltip>
</div>
</>
}
>
<div
ref={(el) => (optionsRef = el)}
data-slot="question-options"
data-scrollable
role={multi() ? "group" : "radiogroup"}
aria-label={question()?.question}
inert={store.minimized}
aria-hidden={store.minimized || optionsOff() ? "true" : undefined}
classList={{ "pointer-events-none": hidden() > 0.1 }}
style={{
"max-height": `${Math.max(0, store.optionsHeight * (1 - hidden()))}px`,
opacity: `${Math.max(0, Math.min(1, 1 - hidden()))}`,
visibility: optionsOff() ? "hidden" : "visible",
}}
>
<For each={options()}>
{(opt, i) => (
<Option
multi={multi()}
picked={picked(opt.value)}
label={opt.label}
description={opt.description}
number={i() + 1}
disabled={sending()}
ref={(el) => (optsRef[i()] = el)}
onFocus={() => setStore("focus", i())}
onClick={() => selectOption(i())}
/>
)}
</For>
<div
data-slot="question-option"
data-custom="true"
data-picked={on()}
data-editing={store.editing}
data-disabled={sending()}
onClick={(event) => {
if (event.target !== event.currentTarget || sending()) return
setStore("focus", options().length)
setStore("customOn", store.tab, true)
setStore("editing", true)
customUpdate(input(), true)
customInput?.focus()
}}
>
<button
type="button"
ref={customRef}
data-slot="question-custom-toggle"
role={multi() ? "checkbox" : "radio"}
aria-checked={on()}
aria-label={customLabel()}
aria-keyshortcuts={count() <= 9 ? String(count()) : undefined}
disabled={sending()}
onFocus={() => setStore("focus", options().length)}
onClick={customToggle}
>
<Mark multi={multi()} picked={on()} />
</button>
<TextInput
ref={(el) => (customInput = el)}
class="question-custom-field"
dir="auto"
aria-label={customLabel()}
placeholder={customLabel()}
value={input()}
disabled={sending()}
onFocus={() => {
if (focusFrame !== undefined) cancelAnimationFrame(focusFrame)
focusFrame = undefined
setStore("focus", options().length)
setStore("editing", true)
}}
onClick={() => {
setStore("customOn", store.tab, true)
customUpdate(input(), true)
}}
onBlur={() => setStore("editing", false)}
onKeyDown={(e) => {
if (e.isComposing || e.keyCode === 229) return
if (e.key === "Escape") {
e.preventDefault()
setStore("editing", false)
focus(options().length)
return
}
if ((e.metaKey || e.ctrlKey) && !e.altKey) return
if (e.key !== "Enter") return
e.preventDefault()
commitCustom()
}}
onInput={(e) => {
setStore("customOn", store.tab, true)
customUpdate(e.currentTarget.value, true)
}}
/>
<Show when={count() <= 9}>
<Keybind
keys={[String(count())]}
variant={on() ? "outline" : "neutral"}
data-slot="question-option-shortcut"
aria-hidden="true"
/>
</Show>
</div>
</div>
</DockPrompt>
</div>
)
}
function bounds(el: Element | null | undefined): DOMRect | undefined {
if (!el) return undefined
const rect = el.getBoundingClientRect()
return rect.height >= 1 ? rect : bounds(el.parentElement)
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -50,6 +50,20 @@ export const SettingsExperimental: Component = () => {
/>
</div>
</SettingsRow>
<SettingsRow
title={language.t("settings.experimental.row.newQuestionUI.title")}
description={language.t("settings.experimental.row.newQuestionUI.description")}
>
<div data-action="settings-new-question-ui">
<Switch
checked={settings.general.newQuestionUI()}
onChange={(checked) => settings.general.setNewQuestionUI(checked)}
hideLabel
>
{language.t("settings.experimental.row.newQuestionUI.title")}
</Switch>
</div>
</SettingsRow>
</SettingsList>
</div>
</div>
+3
View File
@@ -97,6 +97,7 @@ describe("settings schema", () => {
timelineWidth: "comfortable",
newIcons: false,
foldUserMessages: false,
newQuestionUI: false,
mobileTitlebarPosition: "top",
followUpBehavior: "steer",
},
@@ -134,6 +135,7 @@ describe("settings schema", () => {
followUpBehavior: "invalid",
backgroundActivity: "invalid",
timelineWidth: "invalid",
newQuestionUI: "invalid",
},
appearance: { fontSize: "large", mono: "Custom Mono", tabLayout: "vertical", showProjectName: true },
permissions: { autoApprove: true, autoApproveProjects: { on: true, off: false, bad: "yes" } },
@@ -150,6 +152,7 @@ describe("settings schema", () => {
followUpBehavior: "steer",
backgroundActivity: "left",
timelineWidth: "comfortable",
newQuestionUI: false,
})
expect(settings.appearance).toEqual({
fontSize: 14,
+7
View File
@@ -131,6 +131,8 @@ const generalSchema = Persistence.struct({
newIcons: Schema.Boolean,
// The "Fold long messages" experiment, off until it ships.
foldUserMessages: Schema.Boolean,
// The redesigned keyboard-first question dock, off until it ships.
newQuestionUI: Schema.Boolean,
mobileTitlebarPosition: Schema.Literals(["top", "bottom"]),
// Owned by the review plugin, which copies it out once; kept so settings rewrites cannot drop it first.
mobileDiffWrap: Persistence.optional(Schema.Boolean),
@@ -300,6 +302,7 @@ export const defaultSettings: Settings = {
timelineWidth: "comfortable",
newIcons: false,
foldUserMessages: false,
newQuestionUI: false,
mobileTitlebarPosition: "top",
followUpBehavior: "steer",
},
@@ -412,6 +415,10 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
setFoldUserMessages(value: boolean) {
setStore("general", "foldUserMessages", value)
},
newQuestionUI: withFallback(() => store.general?.newQuestionUI, defaultSettings.general.newQuestionUI),
setNewQuestionUI(value: boolean) {
setStore("general", "newQuestionUI", value)
},
mobileTitlebarPosition: withFallback(
() => store.general?.mobileTitlebarPosition,
defaultSettings.general.mobileTitlebarPosition,
@@ -111,6 +111,13 @@ export const clientSettings: Entry<SettingsRootTab>[] = [
description: "settings.experimental.row.foldUserMessages.description",
keywords: "fold collapse long messages prompts read more",
},
{
tab: "experimental",
label: "settings.experimental.row.newQuestionUI.title",
target: "settings-new-question-ui",
description: "settings.experimental.row.newQuestionUI.description",
keywords: "question answers keyboard dock redesign",
},
{
tab: "appearance",
label: "settings.general.row.colorScheme.title",
@@ -75,6 +75,10 @@ describe("settings search index", () => {
.map((item) => item.page),
).toEqual(["Desktop notifications", "Sound effects"])
expect(rankSettings("follow-up behavior", items)[0].page).toBe("Preferences / General")
expect(rankSettings("new question UI", items)[0].view).toMatchObject({
tab: "experimental",
target: "settings-new-question-ui",
})
expect(rankSettings("capsule", items)[0].view).toMatchObject({
tab: "general",
target: "settings-background-activity",
@@ -2,6 +2,7 @@ import type { JSX } from "solid-js"
export function DockPrompt(props: {
kind: "question" | "permission"
variant?: "experimental"
header: JSX.Element
children: JSX.Element
footer: JSX.Element
@@ -11,7 +12,13 @@ export function DockPrompt(props: {
const slot = (name: string) => `${props.kind}-${name}`
return (
<div data-component="dock-prompt" data-kind={props.kind} ref={props.ref} onKeyDown={props.onKeyDown}>
<div
data-component="dock-prompt"
data-kind={props.kind}
data-variant={props.variant}
ref={props.ref}
onKeyDown={props.onKeyDown}
>
<div data-slot={slot("body")}>
<div data-slot={slot("header")}>{props.header}</div>
<div data-slot={slot("content")}>{props.children}</div>
@@ -1380,7 +1380,8 @@
scroll-margin-top: var(--sticky-accordion-top, 0px);
}
[data-component="dock-prompt"] {
[data-component="dock-prompt"][data-kind="permission"],
[data-component="dock-prompt"][data-variant="experimental"] {
position: relative;
display: flex;
flex-direction: column;
@@ -0,0 +1,568 @@
[data-component="dock-prompt"][data-kind="question"][data-variant="experimental"] {
--v2-question-answer-bg-selected: light-dark(#f5f8ff, #7698fd26);
/* A bounce-0 spring sampled for CSS: with the dock's motion on, every pick and progress change eases on it, so two
answers trading places always cross in the same frames. */
--question-spring: linear(
0,
0.04,
0.131,
0.243,
0.358,
0.466,
0.562,
0.645,
0.715,
0.774,
0.821,
0.859,
0.89,
0.914,
0.934,
0.949,
0.96,
0.97,
0.977,
0.982,
1
);
--question-pick: 120ms;
--question-settle: 300ms;
max-block-size: var(--question-prompt-max-height, 100dvh);
font-family: var(--v2-font-family-sans);
[data-slot="question-body"] {
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
min-block-size: 0;
padding: 8px;
}
[data-slot="question-header"] {
display: flex;
flex-direction: column;
gap: 4px;
flex-shrink: 0;
min-inline-size: 0;
padding-inline: 10px;
}
[data-slot="question-header-top"] {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
min-block-size: 28px;
min-inline-size: 0;
}
[data-slot="question-header-title"] {
min-inline-size: 0;
font-size: 13px;
font-weight: 440;
line-height: var(--line-height-base);
color: var(--v2-text-text-muted);
overflow-wrap: anywhere;
}
[data-slot="question-header-actions"] {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
[data-component="icon-button-v2"] {
flex-shrink: 0;
color: var(--v2-icon-icon-muted);
}
[data-slot="icon-svg"] {
flex-shrink: 0;
}
}
/* Holds the question text at its sprung height, and the outgoing copy of it while questions switch. It reaches into
the header's side padding, so text sliding past a side fades out in that gutter instead of over the text at rest. */
[data-slot="question-details-frame"] {
--question-gutter: 10px;
position: relative;
min-inline-size: 0;
margin-inline: calc(-1 * var(--question-gutter));
padding-inline: var(--question-gutter);
overflow: clip;
mask-composite: intersect;
}
/* A question switching away shrinks toward its top, and the next one grows from there. */
[data-slot="question-details"] {
display: flex;
flex-direction: column;
gap: 4px;
min-inline-size: 0;
transform-origin: 50% 0;
}
[data-slot="question-text"] {
font-size: 13px;
font-weight: 530;
line-height: var(--line-height-base);
color: var(--v2-text-text-base);
overflow-wrap: anywhere;
-webkit-user-select: text;
user-select: text;
}
[data-slot="question-hint"] {
font-size: 11px;
font-weight: 440;
line-height: var(--line-height-tight);
color: var(--v2-text-text-faint);
overflow-wrap: anywhere;
}
/* Each segment is a 20px button holding a 14px dash, 2px apart, so dashes repeat every 22px from 3px in. */
[data-slot="question-progress"] {
position: relative;
display: flex;
align-items: center;
gap: 2px;
flex-shrink: 0;
}
/* The current question's bar slides along a strip that shows only through the dashes, never in the gaps. */
[data-slot="question-progress-track"] {
position: absolute;
z-index: 1;
inset-inline: 0;
inset-block-start: calc(50% - 1px);
block-size: 2px;
pointer-events: none;
-webkit-mask-image: repeating-linear-gradient(to right, transparent 0 3px, #000 3px 17px, transparent 17px 22px);
mask-image: repeating-linear-gradient(to right, transparent 0 3px, #000 3px 17px, transparent 17px 22px);
}
[data-slot="question-progress"]:has(:disabled) [data-slot="question-progress-track"] {
opacity: 0.5;
}
[data-slot="question-progress-current"] {
position: absolute;
inset-block: 0;
inset-inline-start: 3px;
inline-size: 14px;
background-color: var(--v2-icon-icon-base);
will-change: transform;
}
[data-slot="question-progress-segment"] {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
inline-size: 20px;
block-size: 20px;
padding: 0;
border: 0;
border-radius: 4px;
background: transparent;
cursor: pointer;
touch-action: manipulation;
&[data-answered="true"] [data-slot="question-progress-bar"]::before {
transform: scaleX(1);
}
&:focus-visible {
outline: 2px solid var(--v2-border-border-focus);
outline-offset: 1px;
}
&:disabled {
cursor: not-allowed;
opacity: 0.5;
}
}
[data-slot="question-progress-bar"] {
position: relative;
inline-size: 14px;
block-size: 2px;
flex-shrink: 0;
overflow: hidden;
background-color: var(--v2-background-bg-layer-04);
/* Answering fills the segment from its start. */
&::before {
content: "";
position: absolute;
inset: 0;
background-color: var(--v2-background-bg-accent);
transform: scaleX(0);
transform-origin: left;
}
&:dir(rtl)::before {
transform-origin: right;
}
}
[data-slot="question-content"] {
display: flex;
flex-direction: column;
flex: 1;
min-block-size: 0;
min-inline-size: 0;
}
/* Reaches into the body's side padding like the question text's frame, for the same gutter. */
[data-slot="question-options"] {
--question-gutter: 8px;
flex: 1 1 auto;
min-block-size: 0;
min-inline-size: 0;
margin: 0 calc(-1 * var(--question-gutter));
padding: 0;
overflow-y: auto;
scrollbar-width: none;
mask-composite: intersect;
&::-webkit-scrollbar {
display: none;
}
}
/* Holds the answers and the outgoing copy of them while questions switch. It clips them at its sides, so answers
sliding past never make the box scroll sideways. */
[data-slot="question-options-track"] {
position: relative;
padding-inline: var(--question-gutter);
overflow-x: clip;
}
[data-slot="question-options-list"] {
display: flex;
flex-direction: column;
gap: 2px;
position: relative;
isolation: isolate;
transform-origin: 50% 0;
}
/* One highlight for the whole list, painted under the keyboard-focused answer by its clip.
Only the navigation keys show it; the pick itself shows only on the key. */
[data-slot="question-highlight"] {
position: absolute;
inset: 0;
z-index: -1;
background:
linear-gradient(var(--v2-question-answer-bg-selected), var(--v2-question-answer-bg-selected)),
var(--v2-background-bg-layer-01);
clip-path: inset(0 0 100% round 6px);
pointer-events: none;
&[data-shown="false"] {
visibility: hidden;
}
}
[data-slot="question-option"] {
display: flex;
align-items: flex-start;
gap: 8px;
flex-shrink: 0;
box-sizing: border-box;
inline-size: 100%;
position: relative;
padding: 10px;
border: 0;
border-radius: 6px;
outline: none;
background: transparent;
color: var(--v2-text-text-base);
text-align: start;
cursor: pointer;
touch-action: manipulation;
&:disabled,
&[data-disabled="true"] {
cursor: not-allowed;
opacity: 0.5;
}
}
[data-slot="question-option-check"] {
display: inline-flex;
align-items: center;
justify-content: center;
inline-size: 18px;
block-size: 20px;
flex: 0 0 18px;
}
/* An answer's key is its mark. One answer: a round key with a soft fill. Many: a hollow square key, like a checkbox.
Picking fills either solid, with the number in the inverse colour. */
[data-slot="question-option-key"] {
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
inline-size: 18px;
block-size: 18px;
position: relative;
isolation: isolate;
border-radius: 50%;
background-color: var(--v2-background-bg-layer-03);
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base);
color: var(--v2-text-text-muted);
font-size: 11px;
font-weight: 530;
line-height: 1;
font-variant-numeric: tabular-nums;
&::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background-color: var(--v2-background-bg-accent);
opacity: 0;
}
&[data-type="checkbox"] {
border-radius: 4px;
background-color: transparent;
box-shadow: inset 0 0 0 1px var(--v2-border-border-strong);
}
&[data-picked="true"] {
color: var(--v2-text-text-contrast);
box-shadow: inset 0 0 0 1px transparent;
&::before {
opacity: 1;
}
}
}
[data-slot="question-option-main"] {
display: flex;
flex-direction: column;
gap: 4px;
min-inline-size: 0;
flex: 1;
}
[data-slot="option-label"] {
font-family: var(--v2-font-family-sans);
font-size: 13px;
font-weight: 530;
line-height: var(--line-height-base);
color: var(--v2-text-text-base);
overflow-wrap: anywhere;
}
[data-slot="option-description"] {
min-inline-size: 0;
font-family: var(--v2-font-family-sans);
font-size: 13px;
font-weight: 440;
line-height: var(--line-height-base);
color: var(--v2-text-text-muted);
overflow-wrap: anywhere;
white-space: normal;
}
[data-slot="question-option"][data-custom="true"] {
align-items: center;
block-size: 40px;
min-block-size: 40px;
max-block-size: 40px;
padding-block: 0;
padding-inline: 10px;
&:not([data-editing="true"]) [data-slot="text-input-v2-input"] {
font-weight: 530;
}
&[data-editing="true"] .question-custom-field[data-component="text-input-v2"] {
background:
linear-gradient(180deg, var(--v2-alpha-light-2), var(--v2-alpha-light-0)), var(--v2-background-bg-base);
box-shadow: inset 0 0 0 1px var(--v2-border-border-focus);
[data-slot="text-input-v2-input"] {
padding-inline: 8px;
&::placeholder {
color: var(--v2-text-text-faint);
}
}
}
}
[data-slot="question-custom-toggle"] {
display: inline-flex;
align-items: center;
justify-content: center;
inline-size: 18px;
block-size: 20px;
flex: 0 0 18px;
margin: 0;
padding: 0;
border: 0;
border-radius: 4px;
background: transparent;
cursor: pointer;
touch-action: manipulation;
&:focus-visible {
outline: none;
}
&:disabled {
cursor: not-allowed;
}
}
[data-slot="question-option"] .question-custom-field[data-component="text-input-v2"] {
flex: 1;
inline-size: 100%;
min-inline-size: 0;
block-size: 28px;
align-self: center;
padding: 0;
gap: 0;
border: 0;
border-radius: 6px;
background: transparent;
box-shadow: none;
outline: none;
opacity: 1;
transition: none;
[data-slot="text-input-v2-value"] {
min-inline-size: 0;
min-block-size: 0;
gap: 0;
}
[data-slot="text-input-v2-input"] {
box-sizing: border-box;
inline-size: 100%;
min-inline-size: 0;
block-size: 28px;
margin: 0;
padding: 0;
border: 0;
background: transparent;
outline: none;
font-family: var(--v2-font-family-sans);
font-size: 13px;
font-weight: 440;
line-height: var(--line-height-compact);
color: var(--v2-text-text-base);
text-align: start;
cursor: text;
&::placeholder {
color: var(--v2-text-text-base);
opacity: 1;
}
&:disabled {
cursor: not-allowed;
}
}
}
[data-slot="question-footer"] {
display: flex;
box-sizing: border-box;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding-block: 7px 8px;
padding-inline: 12px;
> [data-component="button-v2"][data-variant="ghost"] {
color: var(--v2-text-text-muted);
}
}
[data-slot="question-footer-actions"] {
display: flex;
align-items: center;
gap: 8px;
}
/* While a switch runs, the dock draws the footer buttons frame by frame; at rest these rules place them. */
[data-slot="question-footer-back"][data-shown="false"] {
visibility: hidden;
opacity: 0;
}
[data-slot="question-advance"] {
position: relative;
display: flex;
}
[data-slot="question-advance-face"] {
display: flex;
}
[data-slot="question-advance-face"][data-active="false"] {
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;
visibility: hidden;
opacity: 0;
}
[data-slot="question-advance-face"][data-active="true"] {
z-index: 1;
}
[data-slot="question-advance-label"] {
display: inline-flex;
align-items: center;
gap: 6px;
}
[data-slot="question-submit-shortcut"] {
flex-shrink: 0;
opacity: 0.6;
}
@media (hover: hover) and (pointer: fine) {
[data-slot="question-progress-segment"]:hover:not(:disabled) {
background-color: var(--v2-overlay-simple-overlay-hover);
}
}
/* Without the dock's motion there is no sliding bar, so the current question's dash lights itself. */
[data-component="session-question-dock"][data-animated="false"] & {
[data-slot="question-progress-segment"][data-active="true"] [data-slot="question-progress-bar"]::before {
background-color: var(--v2-icon-icon-base);
transform: scaleX(1);
}
}
/* Picks and answered dashes ease only while the dock's motion is on; otherwise they change on the same frame. */
[data-component="session-question-dock"][data-animated="true"] & {
[data-slot="question-progress-bar"]::before {
transition: transform var(--question-settle) var(--question-spring);
}
[data-slot="question-option-key"] {
transition:
color var(--question-pick) var(--question-spring),
box-shadow var(--question-pick) var(--question-spring);
&::before {
transition: opacity var(--question-pick) var(--question-spring);
}
}
}
}
@@ -1,43 +1,28 @@
[data-component="dock-prompt"][data-kind="question"] {
--v2-question-answer-bg-selected: light-dark(#f5f8ff, #7698fd26);
/* A bounce-0 spring sampled for CSS: with the dock's motion on, every pick and progress change eases on it, so two
answers trading places always cross in the same frames. */
--question-spring: linear(
0,
0.04,
0.131,
0.243,
0.358,
0.466,
0.562,
0.645,
0.715,
0.774,
0.821,
0.859,
0.89,
0.914,
0.934,
0.949,
0.96,
0.97,
0.977,
0.982,
1
);
--question-pick: 120ms;
--question-settle: 300ms;
[data-component="dock-prompt"][data-kind="question"]:not([data-variant="experimental"]) {
--v2-question-answer-bg-selected: color-mix(in srgb, var(--v2-border-border-focus) 15%, transparent);
--question-feedback-duration: 120ms;
position: relative;
display: flex;
flex-direction: column;
gap: 0;
min-block-size: 0;
max-block-size: var(--question-prompt-max-height, 100dvh);
font-family: var(--v2-font-family-sans);
isolation: isolate;
[data-slot="question-body"] {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
gap: 16px;
flex: 1;
min-block-size: 0;
padding: 8px;
padding: 8px 12px 12px;
background-color: var(--v2-background-bg-base);
border-radius: 10px;
box-shadow: var(--v2-elevation-raised);
}
[data-slot="question-header"] {
@@ -46,7 +31,6 @@
gap: 4px;
flex-shrink: 0;
min-inline-size: 0;
padding-inline: 10px;
}
[data-slot="question-header-top"] {
@@ -62,7 +46,7 @@
min-inline-size: 0;
font-size: 13px;
font-weight: 440;
line-height: var(--line-height-base);
line-height: var(--line-height-compact);
color: var(--v2-text-text-muted);
overflow-wrap: anywhere;
}
@@ -83,31 +67,17 @@
}
}
/* Holds the question text at its sprung height, and the outgoing copy of it while questions switch. It reaches into
the header's side padding, so text sliding past a side fades out in that gutter instead of over the text at rest. */
[data-slot="question-details-frame"] {
--question-gutter: 10px;
position: relative;
min-inline-size: 0;
margin-inline: calc(-1 * var(--question-gutter));
padding-inline: var(--question-gutter);
overflow: clip;
mask-composite: intersect;
}
/* A question switching away shrinks toward its top, and the next one grows from there. */
[data-slot="question-details"] {
display: flex;
flex-direction: column;
gap: 4px;
gap: 8px;
min-inline-size: 0;
transform-origin: 50% 0;
}
[data-slot="question-text"] {
font-size: 13px;
font-weight: 530;
line-height: var(--line-height-base);
line-height: var(--line-height-compact);
color: var(--v2-text-text-base);
overflow-wrap: anywhere;
-webkit-user-select: text;
@@ -122,40 +92,13 @@
overflow-wrap: anywhere;
}
/* Each segment is a 20px button holding a 14px dash, 2px apart, so dashes repeat every 22px from 3px in. */
[data-slot="question-progress"] {
position: relative;
display: flex;
align-items: center;
gap: 2px;
flex-shrink: 0;
}
/* The current question's bar slides along a strip that shows only through the dashes, never in the gaps. */
[data-slot="question-progress-track"] {
position: absolute;
z-index: 1;
inset-inline: 0;
inset-block-start: calc(50% - 1px);
block-size: 2px;
pointer-events: none;
-webkit-mask-image: repeating-linear-gradient(to right, transparent 0 3px, #000 3px 17px, transparent 17px 22px);
mask-image: repeating-linear-gradient(to right, transparent 0 3px, #000 3px 17px, transparent 17px 22px);
}
[data-slot="question-progress"]:has(:disabled) [data-slot="question-progress-track"] {
opacity: 0.5;
}
[data-slot="question-progress-current"] {
position: absolute;
inset-block: 0;
inset-inline-start: 3px;
inline-size: 14px;
background-color: var(--v2-icon-icon-base);
will-change: transform;
}
[data-slot="question-progress-segment"] {
display: inline-flex;
align-items: center;
@@ -170,8 +113,12 @@
cursor: pointer;
touch-action: manipulation;
&[data-answered="true"] [data-slot="question-progress-bar"]::before {
transform: scaleX(1);
&[data-answered="true"]:not([data-active="true"]) [data-slot="question-progress-bar"]::before {
opacity: 1;
}
&[data-active="true"] [data-slot="question-progress-bar"]::after {
opacity: 1;
}
&:focus-visible {
@@ -190,21 +137,23 @@
inline-size: 14px;
block-size: 2px;
flex-shrink: 0;
overflow: hidden;
background-color: var(--v2-background-bg-layer-04);
/* Answering fills the segment from its start. */
&::before {
&::before,
&::after {
content: "";
position: absolute;
inset: 0;
background-color: var(--v2-background-bg-accent);
transform: scaleX(0);
transform-origin: left;
opacity: 0;
}
&:dir(rtl)::before {
transform-origin: right;
&::before {
background-color: var(--v2-background-bg-accent);
transition: opacity var(--question-feedback-duration) ease;
}
&::after {
background-color: var(--v2-icon-icon-muted);
}
}
@@ -216,74 +165,67 @@
min-inline-size: 0;
}
/* Reaches into the body's side padding like the question text's frame, for the same gutter. */
[data-slot="question-options"] {
--question-gutter: 8px;
display: flex;
flex-direction: column;
gap: 6px;
flex: 1 1 auto;
min-block-size: 0;
min-inline-size: 0;
margin: 0 calc(-1 * var(--question-gutter));
margin: 0;
padding: 0;
overflow-y: auto;
scrollbar-width: none;
mask-composite: intersect;
&::-webkit-scrollbar {
display: none;
}
}
/* Holds the answers and the outgoing copy of them while questions switch. It clips them at its sides, so answers
sliding past never make the box scroll sideways. */
[data-slot="question-options-track"] {
position: relative;
padding-inline: var(--question-gutter);
overflow-x: clip;
}
[data-slot="question-options-list"] {
display: flex;
flex-direction: column;
gap: 2px;
[data-slot="question-option"] {
position: relative;
isolation: isolate;
transform-origin: 50% 0;
}
/* One highlight for the whole list, painted under the answers. It jumps to the hovered or keyboard-highlighted answer
by its clip, and shows only while the pointer hovers or the keys drive; the pick itself shows only on the key. */
[data-slot="question-highlight"] {
position: absolute;
inset: 0;
z-index: -1;
background:
linear-gradient(var(--v2-question-answer-bg-selected), var(--v2-question-answer-bg-selected)),
var(--v2-background-bg-layer-01);
clip-path: inset(0 0 100% round 6px);
pointer-events: none;
&[data-shown="false"] {
visibility: hidden;
}
}
[data-slot="question-option"] {
display: flex;
align-items: flex-start;
gap: 8px;
flex-shrink: 0;
box-sizing: border-box;
inline-size: 100%;
position: relative;
padding: 10px;
border: 0;
border-radius: 6px;
outline: none;
background: transparent;
background-color: var(--v2-background-bg-layer-01);
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base);
color: var(--v2-text-text-base);
text-align: start;
cursor: pointer;
touch-action: manipulation;
transition: background-color var(--question-feedback-duration) ease;
&::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background-color: var(--v2-question-answer-bg-selected);
opacity: 0;
pointer-events: none;
transition: opacity var(--question-feedback-duration) ease;
}
&[data-picked="true"] {
box-shadow: none;
&::before {
opacity: 1;
}
}
&:focus-visible {
outline: 1px solid var(--v2-border-border-focus);
outline-offset: -1px;
}
&:disabled,
&[data-disabled="true"] {
@@ -296,70 +238,87 @@
display: inline-flex;
align-items: center;
justify-content: center;
inline-size: 18px;
inline-size: 16px;
block-size: 20px;
flex: 0 0 18px;
flex: 0 0 16px;
}
/* An answer's key is its mark. One answer: a round key with a soft fill. Many: a hollow square key, like a checkbox.
Picking fills either solid, with the number in the inverse colour. */
[data-slot="question-option-key"] {
[data-slot="question-option-box"] {
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
inline-size: 18px;
block-size: 18px;
position: relative;
isolation: isolate;
border-radius: 50%;
background-color: var(--v2-background-bg-layer-03);
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base);
color: var(--v2-text-text-muted);
font-size: 11px;
font-weight: 530;
line-height: 1;
font-variant-numeric: tabular-nums;
inline-size: 16px;
block-size: 16px;
flex: 0 0 16px;
padding: 0;
border: 0;
border-radius: 4px;
background: linear-gradient(180deg, var(--v2-alpha-light-6), var(--v2-alpha-light-0)), var(--v2-background-bg-base);
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-strong);
&::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background-color: var(--v2-background-bg-accent);
[data-slot="icon-svg"] {
inline-size: 16px;
block-size: 16px;
flex: 0 0 16px;
opacity: 0;
color: var(--v2-icon-icon-contrast);
transition: opacity var(--question-feedback-duration) ease;
}
&[data-type="checkbox"] {
border-radius: 4px;
background-color: transparent;
box-shadow: inset 0 0 0 1px var(--v2-border-border-strong);
&[data-type="radio"] {
border-radius: 50%;
}
[data-slot="question-option-radio-dot"] {
inline-size: 6px;
block-size: 6px;
flex: 0 0 6px;
border-radius: 50%;
background-color: var(--v2-grey-300);
box-shadow: var(--v2-elevation-elements);
opacity: 0;
transition: opacity var(--question-feedback-duration) ease;
}
&[data-picked="true"] {
color: var(--v2-text-text-contrast);
box-shadow: inset 0 0 0 1px transparent;
background:
linear-gradient(180deg, var(--v2-alpha-light-20), var(--v2-alpha-light-0)), var(--v2-background-bg-accent);
&::before {
[data-slot="icon-svg"],
[data-slot="question-option-radio-dot"] {
opacity: 1;
}
&[data-type="radio"] {
box-shadow: none;
}
}
}
[data-slot="question-option-main"] {
display: flex;
flex-direction: column;
gap: 4px;
gap: 6px;
min-inline-size: 0;
flex: 1;
}
[data-slot="question-option-shortcut"] {
--keybind-font-size: 10px;
--keybind-font-weight: var(--font-weight-regular);
--keybind-transition-duration: var(--question-feedback-duration);
align-self: center;
block-size: 20px;
pointer-events: none;
}
[data-slot="option-label"] {
font-family: var(--v2-font-family-sans);
font-size: 13px;
font-weight: 530;
font-weight: 440;
line-height: var(--line-height-base);
letter-spacing: -0.04px;
color: var(--v2-text-text-base);
overflow-wrap: anywhere;
}
@@ -367,9 +326,10 @@
[data-slot="option-description"] {
min-inline-size: 0;
font-family: var(--v2-font-family-sans);
font-size: 13px;
font-size: 11px;
font-weight: 440;
line-height: var(--line-height-base);
line-height: var(--line-height-tight);
letter-spacing: 0.05px;
color: var(--v2-text-text-muted);
overflow-wrap: anywhere;
white-space: normal;
@@ -383,10 +343,6 @@
padding-block: 0;
padding-inline: 10px;
&:not([data-editing="true"]) [data-slot="text-input-v2-input"] {
font-weight: 530;
}
&[data-editing="true"] .question-custom-field[data-component="text-input-v2"] {
background:
linear-gradient(180deg, var(--v2-alpha-light-2), var(--v2-alpha-light-0)), var(--v2-background-bg-base);
@@ -406,9 +362,9 @@
display: inline-flex;
align-items: center;
justify-content: center;
inline-size: 18px;
inline-size: 16px;
block-size: 20px;
flex: 0 0 18px;
flex: 0 0 16px;
margin: 0;
padding: 0;
border: 0;
@@ -418,7 +374,8 @@
touch-action: manipulation;
&:focus-visible {
outline: none;
outline: 2px solid var(--v2-border-border-focus);
outline-offset: 2px;
}
&:disabled {
@@ -478,13 +435,22 @@
}
[data-slot="question-footer"] {
position: relative;
z-index: 0;
display: flex;
box-sizing: border-box;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding-block: 7px 8px;
padding-inline: 12px;
padding-block: 16px 8px;
padding-inline: 8px;
margin-block-start: -9px;
border: 0.5px solid var(--v2-border-border-base);
border-start-start-radius: 0;
border-start-end-radius: 0;
border-end-start-radius: 10px;
border-end-end-radius: 10px;
background-color: var(--v2-background-bg-layer-01);
> [data-component="button-v2"][data-variant="ghost"] {
color: var(--v2-text-text-muted);
@@ -497,72 +463,48 @@
gap: 8px;
}
/* While a switch runs, the dock draws the footer buttons frame by frame; at rest these rules place them. */
[data-slot="question-footer-back"][data-shown="false"] {
visibility: hidden;
opacity: 0;
}
[data-slot="question-advance"] {
position: relative;
display: flex;
}
[data-slot="question-advance-face"] {
display: flex;
}
[data-slot="question-advance-face"][data-active="false"] {
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;
visibility: hidden;
opacity: 0;
}
[data-slot="question-advance-face"][data-active="true"] {
z-index: 1;
/* Keep both labels in layout so the button doesn't change width. */
[data-slot="question-advance-labels"] {
display: inline-grid;
place-items: center;
}
[data-slot="question-advance-label"] {
display: inline-flex;
align-items: center;
gap: 6px;
}
grid-area: 1 / 1;
white-space: nowrap;
opacity: 0;
transition: opacity var(--question-feedback-duration) ease-out;
[data-slot="question-submit-shortcut"] {
flex-shrink: 0;
opacity: 0.6;
&[data-active="true"] {
opacity: 1;
}
}
@media (hover: hover) and (pointer: fine) {
[data-slot="question-progress-segment"]:hover:not(:disabled) {
background-color: var(--v2-overlay-simple-overlay-hover);
}
}
/* Without the dock's motion there is no sliding bar, so the current question's dash lights itself. */
[data-component="session-question-dock"][data-animated="false"] & {
[data-slot="question-progress-segment"][data-active="true"] [data-slot="question-progress-bar"]::before {
background-color: var(--v2-icon-icon-base);
transform: scaleX(1);
[data-slot="question-option"]:hover:not(:disabled):not([data-disabled="true"]):not([data-picked="true"]) {
background-color: var(--v2-background-bg-layer-02);
}
}
/* Picks and answered dashes ease only while the dock's motion is on; otherwise they change on the same frame. */
[data-component="session-question-dock"][data-animated="true"] & {
[data-slot="question-progress-bar"]::before {
transition: transform var(--question-settle) var(--question-spring);
[data-component="session-question-dock"][data-keyboard="true"] &,
:root[data-motion="reduce"] & {
--question-feedback-duration: 0s;
}
@media (prefers-reduced-motion: reduce) {
:root:not([data-motion="full"]) & {
--question-feedback-duration: 0s;
}
}
[data-slot="question-option-key"] {
transition:
color var(--question-pick) var(--question-spring),
box-shadow var(--question-pick) var(--question-spring);
&::before {
transition: opacity var(--question-pick) var(--question-spring);
}
:root[data-motion="reduce"] & {
[data-slot="question-option"],
.question-custom-field[data-component="text-input-v2"] {
transition: none;
}
}
}
+1
View File
@@ -6,6 +6,7 @@
@import "../components/message-part.css" layer(components);
@import "../components/message-nav.css" layer(components);
@import "../components/question-prompt.css" layer(components);
@import "../components/question-prompt-experimental.css" layer(components);
@import "../components/quote-highlight.css" layer(components);
@import "../components/session-review.css" layer(components);
@import "../components/session-compaction.css" layer(components);
@@ -34,6 +34,9 @@
border-radius: 2px;
flex: none;
flex-grow: 0;
transition:
background-color var(--keybind-transition-duration, 0s) ease,
box-shadow var(--keybind-transition-duration, 0s) ease;
}
[data-component="keybind-v2"][data-variant="neutral"] [data-slot="keybind-v2-key"] {
@@ -44,6 +47,11 @@
background: transparent;
}
[data-component="keybind-v2"][data-variant="outline"] [data-slot="keybind-v2-key"] {
background: transparent;
box-shadow: inset 0 0 0 1px var(--v2-border-border-strong);
}
[data-component="keybind-v2"] [data-slot="keybind-v2-label"] {
display: flex;
flex-direction: row;
@@ -53,8 +61,8 @@
padding: 0;
flex: none;
font-style: normal;
font-weight: 530;
font-size: 11px;
font-weight: var(--keybind-font-weight, 530);
font-size: var(--keybind-font-size, 11px);
line-height: 1;
text-align: center;
letter-spacing: 0.05px;
@@ -67,7 +75,7 @@
user-select: none;
}
[data-component="keybind-v2"][data-variant="neutral"] [data-slot="keybind-v2-label"] {
[data-component="keybind-v2"]:is([data-variant="neutral"], [data-variant="outline"]) [data-slot="keybind-v2-label"] {
color: var(--v2-text-text-muted);
}
@@ -5,12 +5,13 @@ Inline keybind indicator that renders one or more keyboard keys in a compact row
### API
- \`keys\`: Array of key labels to display (e.g. \`["⌘", "K"]\`).
- \`variant\`: "neutral" (gray background) | "ghost" (no background).
- \`variant\`: "neutral" (gray background) | "ghost" (no background) | "outline" (border, no background).
- Inherits native div attributes.
### Variants
- **Neutral** — each key sits on a \`#D4D4D4\` pill with darker text.
- **Ghost** — keys render without a background, lighter text color.
- **Outline** — each key has an inset border and no background, with the same dimensions as Neutral.
`
export default {
@@ -37,7 +38,7 @@ export default {
},
variant: {
control: "select",
options: ["neutral", "ghost"],
options: ["neutral", "ghost", "outline"],
},
},
}
@@ -49,6 +50,7 @@ export const Variants = {
<div style={{ display: "flex", gap: "24px", "align-items": "center" }}>
<Keybind keys={["⌘"]} variant="neutral" />
<Keybind keys={["⌘"]} variant="ghost" />
<Keybind keys={["⌘"]} variant="outline" />
</div>
),
}
@@ -58,6 +60,7 @@ export const MultipleKeys = {
<div style={{ display: "flex", gap: "24px", "align-items": "center" }}>
<Keybind keys={["⌘", "K"]} variant="neutral" />
<Keybind keys={["⌘", "K"]} variant="ghost" />
<Keybind keys={["⌘", "K"]} variant="outline" />
<Keybind keys={["Ctrl", "B"]} variant="neutral" />
<Keybind keys={["Ctrl", "B"]} variant="ghost" />
</div>
@@ -81,6 +84,13 @@ export const AllExamples = {
<Keybind keys={["⌘", "⇧", "P"]} variant="ghost" />
<Keybind keys={["Ctrl", "Shift", "B"]} variant="ghost" />
</div>
<div style={{ display: "flex", gap: "24px", "align-items": "center" }}>
<span style={{ "font-size": "11px", color: "#808080", width: "50px" }}>Outline</span>
<Keybind keys={["⌘"]} variant="outline" />
<Keybind keys={["⌘", "K"]} variant="outline" />
<Keybind keys={["⌘", "⇧", "P"]} variant="outline" />
<Keybind keys={["Ctrl", "Shift", "B"]} variant="outline" />
</div>
</div>
),
}
@@ -3,7 +3,7 @@ import "./keybind.css"
export interface KeybindProps extends ComponentProps<"div"> {
keys: string[]
variant?: "neutral" | "ghost"
variant?: "neutral" | "ghost" | "outline"
}
export function Keybind(props: KeybindProps) {
+2
View File
@@ -334,6 +334,8 @@ const source = {
"ui.question.answer.none": "(no answer)",
"ui.question.review.notAnswered": "(not answered)",
"ui.question.multiHint": "Pick any",
"ui.question.singleHint": "Select one answer",
"ui.question.classic.multiHint": "Select all answers that apply",
"ui.question.custom.placeholder": "Type your answer…",
"ui.question.custom.answerPlaceholder": "Type your own answer…",
} satisfies Record<string, string>