Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useKV } from "../context/kv"
import { createDebouncedSignal } from "../util/signal"
import { Spinner } from "./spinner"

export function DialogSessionList() {
export function DialogSessionList(props: { initialSessionID?: string } = {}) {
const dialog = useDialog()
const route = useRoute()
const sync = useSync()
Expand All @@ -30,7 +30,7 @@ export function DialogSessionList() {
return result.data ?? []
})

const currentSessionID = createMemo(() => (route.data.type === "session" ? route.data.sessionID : undefined))
const currentSessionID = createMemo(() => props.initialSessionID ?? (route.data.type === "session" ? route.data.sessionID : undefined))

const sessions = createMemo(() => searchResults() ?? sync.data.session)

Expand Down Expand Up @@ -99,7 +99,8 @@ export function DialogSessionList() {
keybind: keybind.all.session_rename?.[0],
title: "rename",
onTrigger: async (option) => {
dialog.replace(() => <DialogSessionRename session={option.value} />)
const back = () => dialog.replace(() => <DialogSessionList initialSessionID={option.value} />)
dialog.replace(() => <DialogSessionRename session={option.value} onSuccess={back} onCancel={back} />)
},
},
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { useSDK } from "../context/sdk"

interface DialogSessionRenameProps {
session: string
onSuccess?: () => void
onCancel?: () => void
}

export function DialogSessionRename(props: DialogSessionRenameProps) {
Expand All @@ -18,14 +20,18 @@ export function DialogSessionRename(props: DialogSessionRenameProps) {
<DialogPrompt
title="Rename Session"
value={session()?.title}
onConfirm={(value) => {
sdk.client.session.update({
onConfirm={async (value) => {
await sdk.client.session.update({
sessionID: props.session,
title: value,
})
dialog.clear()
if (props.onSuccess) props.onSuccess()
else dialog.clear()
}}
onCancel={() => {
if (props.onCancel) props.onCancel()
else dialog.clear()
}}
onCancel={() => dialog.clear()}
/>
)
}