Keep attachments visible after creating an agent (#2030)

* fix(chat): keep attachments visible after creating agents

Agent creation could receive the canonical user message before the client knew the new agent ID. Hand the local rich presentation to that message and preserve it through later timeline hydration.

* refactor(chat): clarify local message presentation naming

* fix(chat): clear pending state after message handoff
This commit is contained in:
Mohamed Boudra
2026-07-13 11:05:07 +02:00
committed by GitHub
parent a1e81685a1
commit 1f7efbd185
7 changed files with 240 additions and 70 deletions
@@ -123,8 +123,8 @@ export function useDraftAgentCreateFlow<TDraftAgent, TCreateResult>({
const updatePendingAgentId = useCreateFlowStore((state) => state.updateAgentId);
const markPendingCreateLifecycle = useCreateFlowStore((state) => state.markLifecycle);
const clearPendingCreateAttempt = useCreateFlowStore((state) => state.clear);
const appendOptimisticUserMessageToAgentStream = useSessionStore(
(state) => state.appendOptimisticUserMessageToAgentStream,
const handoffCreatedAgentUserMessage = useSessionStore(
(state) => state.handoffCreatedAgentUserMessage,
);
const formErrorMessage = machine.tag === "draft" ? machine.errorMessage : "";
@@ -189,7 +189,7 @@ export function useDraftAgentCreateFlow<TDraftAgent, TCreateResult>({
if (createResult.agentId) {
updatePendingAgentId({ draftId, agentId: createResult.agentId });
appendOptimisticUserMessageToAgentStream(
handoffCreatedAgentUserMessage(
pendingServerId,
createResult.agentId,
buildOptimisticUserMessage({
@@ -199,7 +199,6 @@ export function useDraftAgentCreateFlow<TDraftAgent, TCreateResult>({
images: attempt.images,
attachments: attempt.attachments,
}),
{ placement: "tail", skipIfUserMessageExists: true },
);
markPendingCreateLifecycle({ draftId, lifecycle: "sent" });
}
@@ -216,7 +215,7 @@ export function useDraftAgentCreateFlow<TDraftAgent, TCreateResult>({
}
},
[
appendOptimisticUserMessageToAgentStream,
handoffCreatedAgentUserMessage,
clearPendingCreateAttempt,
createRequest,
draftId,