feat(24-00): shared types, validators, and Wave 0 test stubs for phase 24

- Add ChatMessageSearchResult, ChatMessageSearchResponse to shared types
- Add ChatBookmark, ChatBookmarkWithMessage, ChatBookmarkListResponse, ChatBookmarkToggleResponse
- Add parentConversationId + branchFromMessageId to ChatConversation and ChatConversationListItem
- Add searchMessagesSchema + branchConversationSchema to validators
- Re-export all new types and validators from shared/src/index.ts
- Add Wave 0 it.todo stubs: searchMessages, toggleBookmark, branchConversation, exportConversation
- Add Wave 0 it.todo stubs for 4 new route groups in chat-routes.test.ts
This commit is contained in:
Nexus Dev 2026-04-01 22:27:04 +00:00
parent 65f5603c23
commit 3eb4463cbb
5 changed files with 101 additions and 0 deletions

View file

@ -562,10 +562,14 @@ export {
updateConversationSchema,
createMessageSchema,
handoffSchema,
searchMessagesSchema,
branchConversationSchema,
type CreateConversation,
type UpdateConversation,
type CreateMessage,
type Handoff,
type SearchMessages,
type BranchConversation,
} from "./validators/index.js";
export type {
@ -574,6 +578,12 @@ export type {
ChatMessage,
ChatConversationListResponse,
ChatMessageListResponse,
ChatMessageSearchResult,
ChatMessageSearchResponse,
ChatBookmark,
ChatBookmarkWithMessage,
ChatBookmarkListResponse,
ChatBookmarkToggleResponse,
} from "./types/chat.js";
export { API_PREFIX, API } from "./api.js";

View file

@ -8,6 +8,8 @@ export interface ChatConversation {
deletedAt: string | null;
createdAt: string;
updatedAt: string;
parentConversationId: string | null;
branchFromMessageId: string | null;
}
export interface ChatConversationListItem {
@ -19,6 +21,8 @@ export interface ChatConversationListItem {
archivedAt: string | null;
updatedAt: string;
lastMessagePreview: string | null;
parentConversationId: string | null;
branchFromMessageId: string | null;
}
export interface ChatMessage {
@ -41,3 +45,39 @@ export interface ChatMessageListResponse {
items: ChatMessage[];
hasMore: boolean;
}
export interface ChatMessageSearchResult {
messageId: string;
conversationId: string;
conversationTitle: string | null;
content: string;
role: "user" | "assistant" | "system";
agentId: string | null;
createdAt: string;
rank: number;
}
export interface ChatMessageSearchResponse {
items: ChatMessageSearchResult[];
}
export interface ChatBookmark {
id: string;
companyId: string;
messageId: string;
conversationId: string;
createdAt: string;
}
export interface ChatBookmarkWithMessage extends ChatBookmark {
message: ChatMessage;
conversationTitle: string | null;
}
export interface ChatBookmarkListResponse {
items: ChatBookmarkWithMessage[];
}
export interface ChatBookmarkToggleResponse {
bookmarked: boolean;
}

View file

@ -33,3 +33,15 @@ export type CreateConversation = z.infer<typeof createConversationSchema>;
export type UpdateConversation = z.infer<typeof updateConversationSchema>;
export type CreateMessage = z.infer<typeof createMessageSchema>;
export type Handoff = z.infer<typeof handoffSchema>;
export const searchMessagesSchema = z.object({
q: z.string().min(2).max(200),
limit: z.coerce.number().int().min(1).max(50).optional(),
});
export const branchConversationSchema = z.object({
branchFromMessageId: z.string().uuid(),
});
export type SearchMessages = z.infer<typeof searchMessagesSchema>;
export type BranchConversation = z.infer<typeof branchConversationSchema>;

View file

@ -196,4 +196,22 @@ describe("chatRoutes", () => {
);
});
});
describe("GET /companies/:id/messages/search", () => {
it.todo("returns 200 with search results");
it.todo("returns 400 for short query");
});
describe("POST /conversations/:id/bookmarks", () => {
it.todo("toggles bookmark on/off");
});
describe("POST /conversations/:id/branch", () => {
it.todo("returns 201 with branched conversation");
});
describe("GET /conversations/:id/export", () => {
it.todo("returns markdown file download");
it.todo("returns JSON file download");
});
});

View file

@ -383,4 +383,25 @@ describe("chatService", () => {
expect(result.items.length).toBe(50);
});
});
describe("searchMessages", () => {
it.todo("returns ranked results for matching term");
it.todo("returns empty for no match");
it.todo("respects companyId scope");
});
describe("toggleBookmark", () => {
it.todo("creates bookmark when not exists");
it.todo("removes bookmark when exists");
});
describe("branchConversation", () => {
it.todo("creates child conversation with copied messages");
it.todo("throws not found for invalid message id");
});
describe("exportConversation", () => {
it.todo("exports as markdown with agent names");
it.todo("exports as JSON with all messages");
});
});