* feat(chat): fork assistant turns into new drafts Builds chat-history attachments on the daemon and routes them into draft composers so users can continue an assistant turn in an existing workspace tab or New Workspace. * fix(chat): clean up fork draft handling * fix(chat): address fork draft review feedback * fix(server): build fork context from bounded timeline * fix(app): restore assistant turn footer in streams * fix(app): preserve fork draft setup * fix(app): tighten assistant fork footers * fix(app): lock active fork draft handoff * fix(app): preserve attachment-only draft retries * fix(app): unify composer attachment scopes * fix(app): align chat history attachment labels * fix(app): centralize attachment pill content * fix(app): trim fork context for workspace naming
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import type {
|
|
ComposerAttachment,
|
|
PullRequestContextAttachment,
|
|
UserComposerAttachment,
|
|
WorkspaceComposerAttachment,
|
|
} from "@/attachments/types";
|
|
import type { AgentAttachment } from "@getpaseo/protocol/messages";
|
|
|
|
export function isPullRequestContextAttachment(
|
|
attachment: ComposerAttachment | undefined,
|
|
): attachment is PullRequestContextAttachment {
|
|
return (
|
|
attachment?.kind === "github.pull_request_comment" ||
|
|
attachment?.kind === "github.pull_request_review" ||
|
|
attachment?.kind === "github.pull_request_check"
|
|
);
|
|
}
|
|
|
|
export function isWorkspaceAttachment(
|
|
attachment: ComposerAttachment | undefined,
|
|
): attachment is WorkspaceComposerAttachment {
|
|
return (
|
|
attachment?.kind === "review" ||
|
|
attachment?.kind === "browser_element" ||
|
|
attachment?.kind === "chat_history" ||
|
|
isPullRequestContextAttachment(attachment)
|
|
);
|
|
}
|
|
|
|
export function userAttachmentsOnly(
|
|
attachments: readonly ComposerAttachment[],
|
|
): UserComposerAttachment[] {
|
|
return attachments.filter(
|
|
(attachment): attachment is UserComposerAttachment =>
|
|
attachment.kind !== "review" &&
|
|
attachment.kind !== "browser_element" &&
|
|
attachment.kind !== "chat_history" &&
|
|
!isPullRequestContextAttachment(attachment),
|
|
);
|
|
}
|
|
|
|
export function workspaceAttachmentToSubmitAttachment(
|
|
attachment: ComposerAttachment,
|
|
): AgentAttachment | null {
|
|
if (attachment.kind === "browser_element") {
|
|
return {
|
|
type: "text",
|
|
mimeType: "text/plain",
|
|
title: `Browser element · ${attachment.attachment.tag}`,
|
|
text: attachment.attachment.formatted,
|
|
};
|
|
}
|
|
if (isPullRequestContextAttachment(attachment)) {
|
|
return {
|
|
type: "text",
|
|
mimeType: "text/plain",
|
|
title: attachment.title,
|
|
text: attachment.text,
|
|
};
|
|
}
|
|
if (attachment.kind === "chat_history") {
|
|
return attachment.attachment;
|
|
}
|
|
return attachment.kind === "review" ? attachment.attachment : null;
|
|
}
|