|
|
@@ -107,8 +107,17 @@ export function Session() {
|
|
|
const { theme } = useTheme()
|
|
|
const promptRef = usePromptRef()
|
|
|
const session = createMemo(() => sync.session.get(route.sessionID)!)
|
|
|
+ const children = createMemo(() => {
|
|
|
+ const parentID = session()?.parentID ?? session()?.id
|
|
|
+ return sync.data.session
|
|
|
+ .filter((x) => x.parentID === parentID || x.id === parentID)
|
|
|
+ .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))
|
|
|
+ })
|
|
|
const messages = createMemo(() => sync.data.message[route.sessionID] ?? [])
|
|
|
- const permissions = createMemo(() => sync.data.permission[route.sessionID] ?? [])
|
|
|
+ const permissions = createMemo(() => {
|
|
|
+ if (session().parentID) return sync.data.permission[route.sessionID] ?? []
|
|
|
+ return children().flatMap((x) => sync.data.permission[x.id] ?? [])
|
|
|
+ })
|
|
|
|
|
|
const pending = createMemo(() => {
|
|
|
return messages().findLast((x) => x.role === "assistant" && !x.time.completed)?.id
|
|
|
@@ -176,28 +185,6 @@ export function Session() {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- // Auto-navigate to whichever session currently needs permission input
|
|
|
- createEffect(() => {
|
|
|
- const currentSession = session()
|
|
|
- if (!currentSession) return
|
|
|
- const currentPermissions = permissions()
|
|
|
- let targetID = currentPermissions.length > 0 ? currentSession.id : undefined
|
|
|
-
|
|
|
- if (!targetID) {
|
|
|
- const child = sync.data.session.find(
|
|
|
- (x) => x.parentID === currentSession.id && (sync.data.permission[x.id]?.length ?? 0) > 0,
|
|
|
- )
|
|
|
- if (child) targetID = child.id
|
|
|
- }
|
|
|
-
|
|
|
- if (targetID && targetID !== currentSession.id) {
|
|
|
- navigate({
|
|
|
- type: "session",
|
|
|
- sessionID: targetID,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
let scroll: ScrollBoxRenderable
|
|
|
let prompt: PromptRef
|
|
|
const keybind = useKeybind()
|
|
|
@@ -257,18 +244,14 @@ export function Session() {
|
|
|
const local = useLocal()
|
|
|
|
|
|
function moveChild(direction: number) {
|
|
|
- const parentID = session()?.parentID ?? session()?.id
|
|
|
- let children = sync.data.session
|
|
|
- .filter((x) => x.parentID === parentID || x.id === parentID)
|
|
|
- .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))
|
|
|
- if (children.length === 1) return
|
|
|
- let next = children.findIndex((x) => x.id === session()?.id) + direction
|
|
|
- if (next >= children.length) next = 0
|
|
|
- if (next < 0) next = children.length - 1
|
|
|
- if (children[next]) {
|
|
|
+ if (children().length === 1) return
|
|
|
+ let next = children().findIndex((x) => x.id === session()?.id) + direction
|
|
|
+ if (next >= children().length) next = 0
|
|
|
+ if (next < 0) next = children().length - 1
|
|
|
+ if (children()[next]) {
|
|
|
navigate({
|
|
|
type: "session",
|
|
|
- sessionID: children[next].id,
|
|
|
+ sessionID: children()[next].id,
|
|
|
})
|
|
|
}
|
|
|
}
|