feat(coding): complete PI conversation UI
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
getCodingProjectConfig,
|
||||
listCodingProjectConversations,
|
||||
listCodingProjects,
|
||||
patchCodingProjectConversation,
|
||||
type CodingProjectCatalog,
|
||||
} from '@/lib/coding-projects';
|
||||
import type {
|
||||
@@ -26,6 +27,10 @@ interface CodingWorkspaceDependencies {
|
||||
agentId: string;
|
||||
title: string;
|
||||
}): Promise<CodingConversationMetadata>;
|
||||
patchConversation(
|
||||
conversationId: string,
|
||||
patch: { title?: string; archived?: boolean; unread?: boolean },
|
||||
): Promise<CodingConversationMetadata>;
|
||||
}
|
||||
|
||||
export interface CodingWorkspaceState {
|
||||
@@ -42,6 +47,11 @@ export interface CodingWorkspaceState {
|
||||
selectAgent(agentId: string): void;
|
||||
ensureConversation(agentId: string): Promise<CodingConversationMetadata>;
|
||||
createConversation(agentId: string): Promise<CodingConversationMetadata>;
|
||||
patchConversation(
|
||||
conversationId: string,
|
||||
patch: { title?: string; archived?: boolean; unread?: boolean },
|
||||
): Promise<CodingConversationMetadata>;
|
||||
upsertConversation(conversation: CodingConversationMetadata): void;
|
||||
}
|
||||
|
||||
function enabledAgent(config: CodingProjectConfig | null, agentId: string | null): CodingProjectAgent | null {
|
||||
@@ -72,6 +82,7 @@ function defaultDependencies(): CodingWorkspaceDependencies {
|
||||
getConfig: getCodingProjectConfig,
|
||||
listConversations: listCodingProjectConversations,
|
||||
createConversation: createCodingProjectConversation,
|
||||
patchConversation: patchCodingProjectConversation,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -200,6 +211,27 @@ export function createCodingWorkspaceStore(
|
||||
conversationFlights.set(flightKey, flight);
|
||||
return await flight;
|
||||
},
|
||||
|
||||
async patchConversation(conversationId, patch) {
|
||||
set({ error: null });
|
||||
try {
|
||||
const conversation = await deps.patchConversation(conversationId, patch);
|
||||
get().upsertConversation(conversation);
|
||||
return conversation;
|
||||
} catch (error) {
|
||||
set({ error: error instanceof Error ? error.message : String(error) });
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
upsertConversation(conversation) {
|
||||
set((current) => ({
|
||||
conversations: [
|
||||
conversation,
|
||||
...current.conversations.filter((item) => item.id !== conversation.id),
|
||||
],
|
||||
}));
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user