Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions apps/web/src/hooks/use-agent-messages.ts
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
import { useCallback } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";

// The message shape is defined once on the server and imported type-only —
// esbuild erases this import, so nothing from the server reaches the web
// bundle.
import type { StoredMessage } from "../../../server/src/messages/store";

import { api } from "@/lib/api";

export type AgentMessage = {
id: string;
senderAgentId: string;
recipientAgentId: string;
senderName: string;
recipientName: string;
content: string;
delivered: boolean;
readAt: string | null;
createdAt: string;
};
/**
* Wire shape of a message row. GET /api/v1/agents/:id/messages returns
* `MessageStore.listForAgent()` verbatim, but the /api/v1/history detail query
* projects the same row without the repo-root columns and reuses this type, so
* those two fields are omitted rather than aliased through.
*/
export type AgentMessage = Omit<
StoredMessage,
"senderRepoRoot" | "recipientRepoRoot"
>;

type MessagesPayload = {
messages: AgentMessage[];
Expand Down
Loading