Fix TypeScript compilation errors in native mode session management
Some checks failed
Release Binaries / release (push) Has been cancelled
Some checks failed
Release Binaries / release (push) Has been cancelled
This commit is contained in:
@@ -601,7 +601,7 @@ You are committed to excellence and take pride in delivering code that professio
|
||||
<div class="px-3 py-1.5 flex items-center justify-between border-t border-white/5 bg-zinc-950/30">
|
||||
<span class="text-[9px] font-bold text-zinc-500 uppercase tracking-widest">Saved Agents</span>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); loadAgents(); fetchAgents(); }}
|
||||
onClick={(e) => { e.stopPropagation(); loadAgents(); fetchAgents(props.instanceId); }}
|
||||
class="p-1 hover:bg-white/5 rounded text-zinc-500 hover:text-zinc-300 transition-colors"
|
||||
title="Refresh agents"
|
||||
>
|
||||
|
||||
@@ -52,7 +52,7 @@ interface ToolCallProps {
|
||||
instanceId: string
|
||||
sessionId: string
|
||||
onContentRendered?: () => void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -671,6 +671,7 @@ export default function ToolCall(props: ToolCallProps) {
|
||||
<Markdown
|
||||
part={markdownPart}
|
||||
isDark={isDark()}
|
||||
instanceId={props.instanceId}
|
||||
disableHighlight={disableHighlight}
|
||||
onRendered={handleMarkdownRendered}
|
||||
/>
|
||||
@@ -906,11 +907,11 @@ export default function ToolCall(props: ToolCallProps) {
|
||||
{expanded() && (
|
||||
<div class="tool-call-details">
|
||||
{renderToolBody()}
|
||||
|
||||
|
||||
{renderError()}
|
||||
|
||||
|
||||
{renderPermissionBlock()}
|
||||
|
||||
|
||||
<Show when={status() === "pending" && !pendingPermission()}>
|
||||
<div class="tool-call-pending-message">
|
||||
<span class="spinner-small"></span>
|
||||
@@ -919,7 +920,7 @@ export default function ToolCall(props: ToolCallProps) {
|
||||
</Show>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
<Show when={diagnosticsEntries().length}>
|
||||
|
||||
{renderDiagnosticsSection(
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
|
||||
import { createSignal, createMemo, batch } from "solid-js"
|
||||
import type { Session } from "../types/session"
|
||||
import type { Message, Part } from "../types/message"
|
||||
import { nativeSessionApi, isLiteMode, NativeSession, NativeMessage } from "../lib/lite-mode"
|
||||
import type { Message } from "../types/message"
|
||||
import { nativeSessionApi, isLiteMode } from "../lib/lite-mode"
|
||||
import type { NativeSession, NativeMessage } from "../lib/lite-mode"
|
||||
import { getLogger } from "../lib/logger"
|
||||
|
||||
const log = getLogger("native-sessions")
|
||||
@@ -53,24 +54,29 @@ export function forceLiteMode(enabled: boolean): void {
|
||||
}
|
||||
|
||||
// Convert native session to UI session format
|
||||
function nativeToUiSession(native: NativeSession): Session {
|
||||
function nativeToUiSession(native: NativeSession, workspaceId?: string): Session {
|
||||
return {
|
||||
id: native.id,
|
||||
title: native.title,
|
||||
parentId: native.parentId ?? undefined,
|
||||
createdAt: native.createdAt,
|
||||
updatedAt: native.updatedAt,
|
||||
agent: native.agent,
|
||||
instanceId: workspaceId || native.workspaceId,
|
||||
title: native.title || "",
|
||||
parentId: native.parentId ?? null,
|
||||
agent: native.agent || "Assistant",
|
||||
model: native.model ? {
|
||||
providerId: native.model.providerId,
|
||||
modelId: native.model.modelId,
|
||||
} : undefined,
|
||||
} : { providerId: "", modelId: "" },
|
||||
version: "0",
|
||||
time: {
|
||||
created: native.createdAt,
|
||||
updated: native.updatedAt
|
||||
},
|
||||
skills: []
|
||||
}
|
||||
}
|
||||
|
||||
// Convert native message to UI message format
|
||||
function nativeToUiMessage(native: NativeMessage): Message {
|
||||
const parts: Part[] = []
|
||||
const parts: any[] = []
|
||||
|
||||
if (native.content) {
|
||||
parts.push({
|
||||
@@ -82,19 +88,22 @@ function nativeToUiMessage(native: NativeMessage): Message {
|
||||
return {
|
||||
id: native.id,
|
||||
sessionId: native.sessionId,
|
||||
role: native.role,
|
||||
createdAt: native.createdAt,
|
||||
type: native.role === "user" ? "user" : "assistant",
|
||||
parts,
|
||||
timestamp: native.createdAt,
|
||||
status: native.status === "completed" ? "complete" : "streaming",
|
||||
version: 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch sessions from native API
|
||||
*/
|
||||
export async function fetchNativeSessions(workspaceId: string): Promise<Session[]> {
|
||||
try {
|
||||
const sessions = await nativeSessionApi.listSessions(workspaceId)
|
||||
const uiSessions = sessions.map(nativeToUiSession)
|
||||
const uiSessions = sessions.map(s => nativeToUiSession(s, workspaceId))
|
||||
|
||||
// Update state
|
||||
setNativeSessions(prev => {
|
||||
@@ -227,9 +236,11 @@ export async function sendNativeMessage(
|
||||
const userMessage: Message = {
|
||||
id: `temp-${Date.now()}`,
|
||||
sessionId,
|
||||
role: "user",
|
||||
createdAt: Date.now(),
|
||||
parts: [{ type: "text", text: content }],
|
||||
type: "user",
|
||||
timestamp: Date.now(),
|
||||
parts: [{ type: "text", text: content } as any],
|
||||
status: "complete",
|
||||
version: 0
|
||||
}
|
||||
|
||||
const key = `${workspaceId}:${sessionId}`
|
||||
@@ -264,9 +275,11 @@ export async function sendNativeMessage(
|
||||
const assistantMessage: Message = {
|
||||
id: `msg-${Date.now()}`,
|
||||
sessionId,
|
||||
role: "assistant",
|
||||
createdAt: Date.now(),
|
||||
parts: [{ type: "text", text: fullContent }],
|
||||
type: "assistant",
|
||||
timestamp: Date.now(),
|
||||
parts: [{ type: "text", text: fullContent } as any],
|
||||
status: "complete",
|
||||
version: 0
|
||||
}
|
||||
|
||||
setNativeMessages(prev => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { instances, activeInstanceId } from "./instances"
|
||||
import { addTaskMessage } from "./task-actions"
|
||||
|
||||
import { addRecentModelPreference, setAgentModelPreference, getAgentModelPreference } from "./preferences"
|
||||
import { sessions, withSession, providers, setActiveParentSession, setActiveSession } from "./session-state"
|
||||
import { sessions, setSessions, withSession, providers, setActiveParentSession, setActiveSession } from "./session-state"
|
||||
import { getDefaultModel, isModelValid } from "./session-models"
|
||||
import { updateSessionInfo } from "./message-v2/session-info"
|
||||
import { messageStoreBus } from "./message-v2/bus"
|
||||
@@ -25,6 +25,8 @@ import { QwenOAuthManager } from "../lib/integrations/qwen-oauth"
|
||||
import { getUserScopedKey } from "../lib/user-storage"
|
||||
import { loadSkillDetails } from "./skills"
|
||||
import { serverApi } from "../lib/api-client"
|
||||
import { nativeSessionApi } from "../lib/lite-mode"
|
||||
import type { Session } from "../types/session"
|
||||
|
||||
const log = getLogger("actions")
|
||||
|
||||
@@ -1936,13 +1938,16 @@ async function updateSessionAgent(instanceId: string, sessionId: string, agent:
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if (agent && shouldApplyModel && !agentModelPreference) {
|
||||
await setAgentModelPreference(instanceId, agent, nextModel)
|
||||
}
|
||||
|
||||
const isNative = instance.binaryPath === "__nomadarch_native__"
|
||||
const instance = instances().get(instanceId)
|
||||
const isNative = instance?.binaryPath === "__nomadarch_native__"
|
||||
if (isNative) {
|
||||
await nativeSessionApi.updateSession(instanceId, sessionId, { agent })
|
||||
|
||||
}
|
||||
|
||||
if (shouldApplyModel) {
|
||||
@@ -2168,7 +2173,7 @@ async function forkSession(instanceId: string, sessionId: string): Promise<strin
|
||||
parentId: session.parentId || session.id,
|
||||
agent: session.agent,
|
||||
model: session.model,
|
||||
skills: [...session.skills],
|
||||
skills: [...(session.skills || [])],
|
||||
version: forkedVersion,
|
||||
time: forkedTime,
|
||||
revert: forkedRevert
|
||||
|
||||
@@ -846,8 +846,8 @@ async function fetchAgents(instanceId: string): Promise<void> {
|
||||
mode: "native"
|
||||
}]
|
||||
} else {
|
||||
const response = await instance.client!.agents.list()
|
||||
agentList = (response.data || []).map((agent) => ({
|
||||
const response = await instance.client!.app.agents()
|
||||
agentList = (response.data || []).map((agent: any) => ({
|
||||
name: agent.name,
|
||||
description: agent.description || "",
|
||||
mode: agent.mode as "standard" | "subagent",
|
||||
@@ -1006,7 +1006,7 @@ async function loadMessages(instanceId: string, sessionId: string, force = false
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
const response = await instance.client!.session.getMessages({ path: { id: sessionId } })
|
||||
const response = await instance.client!.session.messages({ path: { id: sessionId } })
|
||||
if (!response.data || !Array.isArray(response.data)) {
|
||||
return
|
||||
}
|
||||
@@ -1041,8 +1041,8 @@ async function loadMessages(instanceId: string, sessionId: string, force = false
|
||||
let providerID = ""
|
||||
let modelID = ""
|
||||
|
||||
for (let i = response.data.length - 1; i >= 0; i--) {
|
||||
const apiMessage = response.data[i]
|
||||
for (let i = apiMessages.length - 1; i >= 0; i--) {
|
||||
const apiMessage = apiMessages[i]
|
||||
const info = apiMessage.info || apiMessage
|
||||
|
||||
if (info.role === "assistant") {
|
||||
@@ -1053,6 +1053,7 @@ async function loadMessages(instanceId: string, sessionId: string, force = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!agentName && !providerID && !modelID) {
|
||||
const defaultModel = await getDefaultModel(instanceId, session.agent)
|
||||
agentName = session.agent
|
||||
|
||||
Reference in New Issue
Block a user