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