Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Julian Coy <julian@ex-machina.co> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Jay <air@live.ca> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: James Long <jlongster@users.noreply.github.com> Co-authored-by: 冯基魁 <56265583+fengjikui@users.noreply.github.com> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { useParams } from "@solidjs/router"
|
|
import { onCleanup } from "solid-js"
|
|
import { useCommand } from "@/context/command"
|
|
import { useLanguage } from "@/context/language"
|
|
import { useDialog } from "@opencode-ai/ui/context/dialog"
|
|
|
|
export function useSettingsDialog(defaultValue?: string) {
|
|
const dialog = useDialog()
|
|
const params = useParams<{ id?: string }>()
|
|
let run = 0
|
|
let dead = false
|
|
|
|
onCleanup(() => {
|
|
dead = true
|
|
})
|
|
|
|
return () => {
|
|
const current = ++run
|
|
const sessionID = params.id
|
|
void import("@/components/settings-v2").then((module) => {
|
|
if (dead || run !== current) return
|
|
void dialog.show(() => <module.DialogSettings sessionID={sessionID} defaultValue={defaultValue} />)
|
|
})
|
|
}
|
|
}
|
|
|
|
export function useSettingsCommand() {
|
|
const command = useCommand()
|
|
const language = useLanguage()
|
|
const show = useSettingsDialog()
|
|
|
|
command.register("settings", () => [
|
|
{
|
|
id: "settings.open",
|
|
title: language.t("command.settings.open"),
|
|
category: language.t("command.category.settings"),
|
|
keybind: "mod+comma",
|
|
onSelect: show,
|
|
},
|
|
])
|
|
|
|
return show
|
|
}
|