Add skills catalog and sidebar tooling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createSignal } from "solid-js"
|
||||
|
||||
import type { Session, Agent, Provider } from "../types/session"
|
||||
import type { Session, Agent, Provider, SkillSelection } from "../types/session"
|
||||
import { deleteSession, loadMessages } from "./session-api"
|
||||
import { showToastNotification } from "../lib/notifications"
|
||||
import { messageStoreBus } from "./message-v2/bus"
|
||||
@@ -164,14 +164,19 @@ async function persistSessionTasks(instanceId: string) {
|
||||
if (!instanceSessions) return
|
||||
|
||||
const sessionTasks: Record<string, any[]> = {}
|
||||
const sessionSkills: Record<string, SkillSelection[]> = {}
|
||||
for (const [sessionId, session] of instanceSessions) {
|
||||
if (session.tasks && session.tasks.length > 0) {
|
||||
sessionTasks[sessionId] = session.tasks
|
||||
}
|
||||
if (session.skills && session.skills.length > 0) {
|
||||
sessionSkills[sessionId] = session.skills
|
||||
}
|
||||
}
|
||||
|
||||
await updateInstanceConfig(instanceId, (draft) => {
|
||||
draft.sessionTasks = sessionTasks
|
||||
draft.sessionSkills = sessionSkills
|
||||
})
|
||||
} catch (error) {
|
||||
log.error("Failed to persist session tasks", error)
|
||||
@@ -264,6 +269,17 @@ function getSessionFamily(instanceId: string, parentId: string): Session[] {
|
||||
return [parent, ...children]
|
||||
}
|
||||
|
||||
function getSessionSkills(instanceId: string, sessionId: string): SkillSelection[] {
|
||||
const session = sessions().get(instanceId)?.get(sessionId)
|
||||
return session?.skills ?? []
|
||||
}
|
||||
|
||||
function setSessionSkills(instanceId: string, sessionId: string, skills: SkillSelection[]): void {
|
||||
withSession(instanceId, sessionId, (session) => {
|
||||
session.skills = skills
|
||||
})
|
||||
}
|
||||
|
||||
function isSessionBusy(instanceId: string, sessionId: string): boolean {
|
||||
const instanceSessions = sessions().get(instanceId)
|
||||
if (!instanceSessions) return false
|
||||
@@ -283,8 +299,13 @@ async function isBlankSession(session: Session, instanceId: string, fetchIfNeede
|
||||
const created = session.time?.created || 0
|
||||
const updated = session.time?.updated || 0
|
||||
const hasChildren = getChildSessions(instanceId, session.id).length > 0
|
||||
const hasTasks = Boolean(session.tasks && session.tasks.length > 0)
|
||||
const isFreshSession = created === updated && !hasChildren
|
||||
|
||||
if (hasTasks) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Common short-circuit: fresh sessions without children
|
||||
if (!fetchIfNeeded) {
|
||||
return isFreshSession
|
||||
@@ -423,4 +444,6 @@ export {
|
||||
getSessionInfo,
|
||||
isBlankSession,
|
||||
cleanupBlankSessions,
|
||||
getSessionSkills,
|
||||
setSessionSkills,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user