|
|
@@ -1,10 +1,11 @@
|
|
|
import { createMemo, createSignal } from "solid-js"
|
|
|
import { useConfig } from "../config"
|
|
|
import { DialogSelect } from "../ui/dialog-select"
|
|
|
+import { useTheme } from "../context/theme"
|
|
|
import { useToast } from "../ui/toast"
|
|
|
|
|
|
type Experiment = {
|
|
|
- id: "tab_drafts"
|
|
|
+ id: string
|
|
|
title: string
|
|
|
description: string
|
|
|
}
|
|
|
@@ -12,36 +13,30 @@ type Experiment = {
|
|
|
// In-flight features anyone can opt into. Each entry is temporary: an
|
|
|
// experiment either graduates (delete the entry, make the behavior
|
|
|
// unconditional) or dies (delete the entry and the branch it gated).
|
|
|
-export const experiments: Experiment[] = [
|
|
|
- {
|
|
|
- id: "tab_drafts",
|
|
|
- title: "Per-tab prompt drafts",
|
|
|
- description: "Keep unsent prompt drafts on the tab where they were written. New sessions start blank.",
|
|
|
- },
|
|
|
-]
|
|
|
+export const experiments: Experiment[] = []
|
|
|
|
|
|
export function DialogExperiments() {
|
|
|
const config = useConfig()
|
|
|
+ const theme = useTheme()
|
|
|
const toast = useToast()
|
|
|
- const [selected, setSelected] = createSignal(0)
|
|
|
+ const [selected, setSelected] = createSignal<Experiment>()
|
|
|
const [saving, setSaving] = createSignal(false)
|
|
|
|
|
|
const enabled = (experiment: Experiment) => config.data.experimental?.[experiment.id] === true
|
|
|
|
|
|
const options = createMemo(() =>
|
|
|
- experiments.map((experiment, index) => ({
|
|
|
+ experiments.map((experiment) => ({
|
|
|
title: experiment.title,
|
|
|
category: "Experiments",
|
|
|
searchText: experiment.description,
|
|
|
footer: enabled(experiment) ? "on" : "off",
|
|
|
- value: index,
|
|
|
+ value: experiment,
|
|
|
})),
|
|
|
)
|
|
|
|
|
|
// All experiments are booleans, so either direction toggles.
|
|
|
- async function change(index = selected()) {
|
|
|
+ async function change(experiment = selected()) {
|
|
|
if (saving()) return
|
|
|
- const experiment = experiments[index]
|
|
|
if (!experiment) return
|
|
|
const next = !enabled(experiment)
|
|
|
setSaving(true)
|
|
|
@@ -58,23 +53,33 @@ export function DialogExperiments() {
|
|
|
<DialogSelect
|
|
|
title="Experiments"
|
|
|
options={options()}
|
|
|
+ renderFilter={experiments.length > 0}
|
|
|
onMove={(option) => setSelected(option.value)}
|
|
|
onSelect={(option) => void change(option.value)}
|
|
|
- footerHints={[{ title: "←/→", label: "change" }]}
|
|
|
- bindings={[
|
|
|
- {
|
|
|
- bind: "left",
|
|
|
- title: "Previous value",
|
|
|
- group: "Experiments",
|
|
|
- run: () => void change(),
|
|
|
- },
|
|
|
- {
|
|
|
- bind: "right",
|
|
|
- title: "Next value",
|
|
|
- group: "Experiments",
|
|
|
- run: () => void change(),
|
|
|
- },
|
|
|
- ]}
|
|
|
+ emptyView={
|
|
|
+ <box paddingLeft={4} paddingRight={4}>
|
|
|
+ <text fg={theme.text.subdued}>No experiments available</text>
|
|
|
+ </box>
|
|
|
+ }
|
|
|
+ footerHints={experiments.length > 0 ? [{ title: "←/→", label: "change" }] : []}
|
|
|
+ bindings={
|
|
|
+ experiments.length > 0
|
|
|
+ ? [
|
|
|
+ {
|
|
|
+ bind: "left",
|
|
|
+ title: "Previous value",
|
|
|
+ group: "Experiments",
|
|
|
+ run: () => void change(),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ bind: "right",
|
|
|
+ title: "Next value",
|
|
|
+ group: "Experiments",
|
|
|
+ run: () => void change(),
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ : []
|
|
|
+ }
|
|
|
/>
|
|
|
)
|
|
|
}
|