feat: complete WorkBuddy parity and Windows release workflow

This commit is contained in:
xiaohan.yuan committed 2026-10-18 12:45:21 +08:00
1 parent 143516b3a8
commit d5512df549
434 files changed
+54977 -1854

No files matched your search

+10 -9
View File
@@ -95,7 +95,7 @@ export async function listSessions(): Promise<SessionMeta[]> {
return [...store.sessions]
// 置顶任务优先(最近置顶在前),其余按更新时间倒序。
.sort((a, b) => Number(b.pinnedAt ?? 0) - Number(a.pinnedAt ?? 0) || b.updatedAt - a.updatedAt)
.map(({ id, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level, pinnedAt, archivedAt }) => ({ id, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level, pinnedAt, archivedAt }))
.map(({ id, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level, pinnedAt, archivedAt }) => ({ id, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level, pinnedAt, archivedAt }))
}
/** 侧栏可见任务:默认排除已归档;`includeArchived` 供归档视图使用。 */
@@ -125,8 +125,8 @@ export async function setSessionArchived(sessionId: string, archived: boolean):
}
function meta(session: SessionRecord): SessionMeta {
const { id, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level, pinnedAt, archivedAt } = session
return { id, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level, pinnedAt, archivedAt }
const { id, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level, pinnedAt, archivedAt } = session
return { id, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level, pinnedAt, archivedAt }
}
export async function createSession(title = '新对话', context: SessionContext = {}): Promise<SessionMeta> {
@@ -142,7 +142,7 @@ export async function createSession(title = '新对话', context: SessionContext
export async function getSessionContext(id: string): Promise<SessionContext> {
const session = (await load()).sessions.find((item) => item.id === id)
if (!session) throw new Error('会话不存在')
return { workspaceId: session.workspaceId, cwd: session.cwd, modelId: session.modelId, expertId: session.expertId, agentMode: agentMode(session.agentMode), thinkingLevel: session.thinkingLevel }
return { workspaceId: session.workspaceId, projectId: session.projectId, cwd: session.cwd, modelId: session.modelId, expertId: session.expertId, agentMode: agentMode(session.agentMode), thinkingLevel: session.thinkingLevel }
}
export async function updateSessionContext(id: string, patch: SessionContext): Promise<SessionMeta> {
const session = (await load()).sessions.find((item) => item.id === id)
@@ -153,8 +153,8 @@ export async function updateSessionContext(id: string, patch: SessionContext): P
for (const key of Object.keys(session)) if (!Object.hasOwn(previous, key)) delete (session as unknown as Record<string, unknown>)[key]
Object.assign(session, previous); throw error
}
const { id: sessionId, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level } = session
return { id: sessionId, title, createdAt, updatedAt, workspaceId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level }
const { id: sessionId, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: mode, thinkingLevel: level } = session
return { id: sessionId, title, createdAt, updatedAt, workspaceId, projectId, cwd, modelId, expertId, agentMode: agentMode(mode), thinkingLevel: level }
}
export async function getMessages(sessionId: string): Promise<ChatMessage[]> {
@@ -185,7 +185,8 @@ export async function appendMessage(sessionId: string, message: ChatMessage): Pr
export async function patchMessage(
sessionId: string,
messageId: string,
patch: Partial<ChatMessage>
patch: Partial<ChatMessage>,
options: { touchSession?: boolean } = {}
): Promise<void> {
const store = await load()
const session = store.sessions.find((s) => s.id === sessionId)
@@ -193,7 +194,7 @@ export async function patchMessage(
const message = session.messages.find((m) => m.id === messageId)
if (!message) return
Object.assign(message, patch)
session.updatedAt = Date.now()
if(options.touchSession!==false)session.updatedAt = Date.now()
await persist()
}
@@ -251,4 +252,4 @@ export async function startTurn(sessionId: string, user: ChatMessage, assistant:
export function deriveTitle(text: string): string {
const flat = text.replace(/\s+/g, ' ').trim()
return flat.length > 24 ? `${flat.slice(0, 24)}…` : flat || '新对话'
}
}