diff --git a/apps/web/src/components/ChatView.logic.test.ts b/apps/web/src/components/ChatView.logic.test.ts index dbbb445a5ec95..04acb40ae2be8 100644 --- a/apps/web/src/components/ChatView.logic.test.ts +++ b/apps/web/src/components/ChatView.logic.test.ts @@ -26,6 +26,7 @@ import { import { ProviderDriverKind, type ServerProvider } from "@t3tools/contracts"; import { deriveProviderInstanceEntries } from "../providerInstances"; import { ensureInlineContextReferences } from "../lib/composerContextReferences"; +import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations"; import { responseContextRecord, responseContextReference, @@ -78,6 +79,17 @@ import { const environmentId = EnvironmentId.make("environment-local"); const projectId = ProjectId.make("project-1"); const threadId = ThreadId.make("thread-1"); +const trayCitation = { + version: 1 as const, + environmentId, + threadId, + messageId: MessageId.make("source"), + text: "Source", + start: 0, + end: 6, + prefix: "", + suffix: "", +}; const now = "2026-03-29T00:00:00.000Z"; function makeThread(overrides: Partial = {}): Thread { @@ -143,6 +155,12 @@ describe("deriveComposerSendState", () => { ], }); + for (const citationCount of [0, 1]) { + expect( + deriveComposerSendState({ prompt: "", imageCount: 0, terminalContexts: [], citationCount }) + .hasSendableContent, + ).toBe(citationCount > 0); + } expect(state.trimmedPrompt).toBe("yoo waddup"); expect(state.expiredTerminalContextCount).toBe(1); expect(state.hasSendableContent).toBe(true); @@ -1233,10 +1251,18 @@ describe("snapshotComposerSend", () => { it("drops expired terminal contexts from the contexts and from the prompt", () => { const snapshot = snapshotComposerSend({ - prompt: ensureInlineContextReferences("run", [ + draftPrompt: ensureInlineContextReferences("run", [ terminalContextReference(expired), terminalContextReference(live), ]), + trayCitations: [trayCitation], + prompt: + serializeAssistantCitation(trayCitation) + + "\n" + + ensureInlineContextReferences("run", [ + terminalContextReference(expired), + terminalContextReference(live), + ]), images: [], files: [], terminalContexts: [expired, live], @@ -1248,9 +1274,15 @@ describe("snapshotComposerSend", () => { replyTo: null, }); + expect(snapshot.draftPrompt).toBe( + ensureInlineContextReferences("run", [terminalContextReference(live)]).trim(), + ); + expect(snapshot.trayCitations).toEqual([trayCitation]); expect(snapshot.terminalContexts).toEqual([live]); expect(snapshot.messageText).toBe( - ensureInlineContextReferences("run", [terminalContextReference(live)]).trim(), + serializeAssistantCitation(trayCitation) + + "\n" + + ensureInlineContextReferences("run", [terminalContextReference(live)]).trim(), ); }); @@ -1272,7 +1304,13 @@ describe("snapshotComposerSend", () => { }); const reference = responseContextReference(replyTo); const snapshot = snapshotComposerSend({ - prompt: ensureInlineContextReferences("", [reference]) + " why there?", + prompt: + serializeAssistantCitation(replyTo.citation) + + "\n" + + ensureInlineContextReferences("", [reference]) + + " why there?", + draftPrompt: "why there?", + trayCitations: [replyTo.citation], images: [], files: [], terminalContexts: [], @@ -1285,8 +1323,9 @@ describe("snapshotComposerSend", () => { }); expect(snapshot.messageText).toContain(`t3-context://v1/response/${replyTo.contextId}`); - expect(snapshot.draftText).toBe("why there?"); + expect(snapshot.draftPrompt).toBe("why there?"); expect(snapshot.replyTo).toBe(replyTo); + expect(snapshot.trayCitations).toEqual([replyTo.citation]); }); }); diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.ts index 1992b748331a2..71bfa8a8f9498 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -1,7 +1,11 @@ import { toServerClock } from "@t3tools/client-runtime/clock"; +import { + type AssistantCitation, + type OrchestrationV2ProviderTurn, + type RunAttemptId, +} from "@t3tools/contracts"; import { msg } from "gt-react"; import { m, type MessageResolver } from "../i18n/messages"; -import { type OrchestrationV2ProviderTurn, type RunAttemptId } from "@t3tools/contracts"; import { deriveLatestThreadRun, deriveThreadRuntime, @@ -748,6 +752,7 @@ export function cloneComposerImageForRetry( export function deriveComposerSendState(options: { prompt: string; imageCount: number; + citationCount?: number; existingAttachmentCount?: number; terminalContexts: ReadonlyArray; elementContextCount?: number; @@ -769,6 +774,7 @@ export function deriveComposerSendState(options: { hasSendableContent: trimmedPrompt.length > 0 || options.imageCount > 0 || + (options.citationCount ?? 0) > 0 || (options.existingAttachmentCount ?? 0) > 0 || sendableTerminalContexts.length > 0 || elementContextCount > 0, @@ -1319,6 +1325,8 @@ export function makeModelDisabledReason( /** What the composer held when the user pressed send, after a direct annotation merged in. */ export interface ComposerSendContents { + readonly draftPrompt?: string; + readonly trayCitations?: ReadonlyArray; readonly prompt: string; readonly images: ReadonlyArray; readonly files: ReadonlyArray; @@ -1341,15 +1349,18 @@ export function snapshotComposerSend(contents: ComposerSendContents) { const images = [...contents.images]; const files = [...contents.files]; const terminalContexts = [...contents.sendableTerminalContexts]; - const messageText = contents.terminalContexts - .filter((context) => !terminalContexts.includes(context)) - .reduce( - (text, context) => - removeInlineContextReference(text, terminalContextReference(context).contextId).prompt, - contents.prompt, - ) - .trim(); + const cleanPrompt = (prompt: string) => + contents.terminalContexts + .filter((context) => !terminalContexts.includes(context)) + .reduce( + (text, context) => + removeInlineContextReference(text, terminalContextReference(context).contextId).prompt, + prompt, + ) + .trim(); return { + draftPrompt: cleanPrompt(contents.draftPrompt ?? contents.prompt), + trayCitations: [...(contents.trayCitations ?? [])], images, files, attachments: [...images, ...files], @@ -1359,11 +1370,7 @@ export function snapshotComposerSend(contents: ComposerSendContents) { threadContexts: [...contents.threadContexts], environmentContexts: [...contents.environmentContexts], replyTo: contents.replyTo, - messageText, - /** What a failed send puts back in the composer: the reply returns above it, not in the text. */ - draftText: contents.replyTo - ? removeInlineContextReference(messageText, contents.replyTo.contextId).prompt.trimStart() - : messageText, + messageText: cleanPrompt(contents.prompt), }; } diff --git a/apps/web/src/components/ComposerPromptEditorTiptap.citationDraft.browser.test.tsx b/apps/web/src/components/ComposerPromptEditorTiptap.citationDraft.browser.test.tsx index 69c2ac1fd4d59..378ccf9405ba0 100644 --- a/apps/web/src/components/ComposerPromptEditorTiptap.citationDraft.browser.test.tsx +++ b/apps/web/src/components/ComposerPromptEditorTiptap.citationDraft.browser.test.tsx @@ -1,9 +1,13 @@ -import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts"; +import { + AssistantCitationTray, + type AssistantCitationTrayHandle, +} from "./chat/AssistantCitationTray"; +import { type AssistantCitation, EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts"; import { serializeAssistantCitation, withAssistantCitationComment, } from "@t3tools/shared/assistantCitations"; -import { createRef, useState } from "react"; +import { createRef, useRef, useState } from "react"; import { expect, it } from "vite-plus/test"; import { page, userEvent } from "vite-plus/test/browser"; @@ -107,6 +111,168 @@ it("keeps an unsaved citation comment when a question takes the composer", async await expect.element(page.getByLabelText("Edit citation comment")).toBeInTheDocument(); }); +function TrayComposer({ + question = false, + trayRef, +}: { + question?: boolean; + trayRef?: React.RefObject; +}) { + const [sent, setSent] = useState(false); + const editorRef = useRef(null); + const [prompt, setPrompt] = useState(promptBefore); + const [answer, setAnswer] = useState(""); + const [tray, setTray] = useState>([]); + return ( + <> +
+

+ hello world +

+
+ + + { + setSent(true); + return true; + }} + citations={tray} + onChange={setTray} + onInsertInline={ + question + ? undefined + : (item) => { + setPrompt((text) => `${text}${serializeAssistantCitation(item)}`); + return true; + } + } + /> + {}} + onMoveCitationToTray={question ? undefined : (item) => setTray((items) => [...items, item])} + /> + + ); +} + +it("opens a source comment for tray citations and preserves saved and cancelled citations", async () => { + const trayRef = createRef(); + await using screen = await render(); + await page.getByRole("button", { name: "Cite to tray", exact: true }).click(); + await expect.element(page.getByLabelText("Comment on selected text")).toBeVisible(); + await page.getByLabelText("Comment on selected text").fill("Keep this comment"); + await userEvent.keyboard("{Tab}"); + await expect.element(page.getByRole("button", { name: "Save", exact: true })).toHaveFocus(); + await page.getByRole("button", { name: "Save", exact: true }).click(); + const state = () => screen.container.querySelector("output")?.dataset; + expect(state()?.trayCount).toBe("1"); + expect(state()?.prompt).not.toContain("t3-citation"); + await page.getByRole("button", { name: "1 annotation", exact: true }).click(); + await page.getByRole("button", { name: "Edit annotation 1", exact: true }).click(); + await page.getByLabelText("Comment on selected text").fill("Keep the dismissed edit"); + await page.getByText("hello world", { exact: true }).click(); + await page.getByRole("button", { name: "1 annotation", exact: true }).click(); + await expect.element(page.getByText("User comment: Keep the dismissed edit")).toBeVisible(); + await page.getByRole("button", { name: "Edit annotation 1", exact: true }).click(); + await page.getByLabelText("Comment on selected text").fill("Discard the cancelled edit"); + await page.getByRole("button", { name: "Cancel", exact: true }).click(); + await expect.element(page.getByText("User comment: Keep the dismissed edit")).toBeVisible(); + await page.getByRole("button", { name: "Edit annotation 1", exact: true }).click(); + await page.getByLabelText("Comment on selected text").fill("Keep the settled edit"); + await act(() => { + expect(trayRef.current?.settleDraft()).toBe(true); + }); + await expect.element(page.getByText("User comment: Keep the settled edit")).toBeVisible(); + await page.getByRole("button", { name: "Edit annotation 1", exact: true }).click(); + await page.getByLabelText("Comment on selected text").fill("Keep the dismissed edit"); + await userEvent.keyboard("{Control>}{Enter}{/Control}"); + expect(state()?.sent).toBe("true"); + await expect.element(page.getByText("User comment: Keep the dismissed edit")).toBeVisible(); + await page.getByRole("button", { name: "Cite to tray", exact: true }).click(); + await page.getByRole("button", { name: "Save", exact: true }).click(); + await page.getByRole("button", { name: "2 annotations", exact: true }).click(); + await page.getByRole("button", { name: "Edit annotation 1", exact: true }).click(); + await page.getByLabelText("Comment on selected text").fill("Keep the edit after deletion"); + await page.getByRole("button", { name: "Delete annotation 2", exact: true }).click(); + await expect.element(page.getByText("User comment: Keep the edit after deletion")).toBeVisible(); + await screen.rerender(); + await expect + .element(page.getByRole("button", { name: "Insert annotation 1 inline", exact: true })) + .not.toBeInTheDocument(); + expect(state()?.trayCount).toBe("1"); + await screen.rerender(); + await page.getByRole("button", { name: "Insert annotation 1 inline", exact: true }).click(); + expect(state()?.trayCount).toBe("0"); + expect(state()?.prompt).toContain( + serializeAssistantCitation( + withAssistantCitationComment(citation, "Keep the edit after deletion"), + ), + ); + await page.getByRole("button", { name: "Cite to tray", exact: true }).click(); + await expect.element(page.getByLabelText("Comment on selected text")).toBeVisible(); + await page.getByLabelText("Comment on selected text").fill("Discard this comment"); + await page.getByRole("button", { name: "Cancel", exact: true }).click(); + expect(state()?.trayCount).toBe("1"); + expect(state()?.prompt).toBe("See "); + await page.getByRole("button", { name: "1 annotation", exact: true }).click(); + await page.getByRole("button", { name: "Insert annotation 1 inline", exact: true }).click(); + expect(state()?.prompt).toContain(serializeAssistantCitation(citation)); + expect(state()?.prompt).not.toContain("Discard this comment"); +}); + +it.each(["Save", "dismiss"])( + "keeps question citations inline on %s when tray transfer is unavailable", + async (action) => { + await using screen = await render(); + await page.getByRole("button", { name: "Cite to tray", exact: true }).click(); + await expect.element(page.getByLabelText("Comment on selected text")).toBeVisible(); + await page.getByLabelText("Comment on selected text").fill("Question comment"); + if (action === "Save") await page.getByRole("button", { name: "Save", exact: true }).click(); + else await page.getByText("hello world", { exact: true }).click(); + const state = screen.container.querySelector("output")?.dataset; + expect(state?.trayCount).toBe("0"); + expect(state?.answer).toContain( + serializeAssistantCitation(withAssistantCitationComment(citation, "Question comment")), + ); + }, +); + it("clears the sent prompt when an empty citation comment sends it", async () => { const editorRef = createRef(); await using screen = await render(); diff --git a/apps/web/src/components/ComposerPromptEditorTiptap.tsx b/apps/web/src/components/ComposerPromptEditorTiptap.tsx index e54703d83b3df..e3cb0be0d0793 100644 --- a/apps/web/src/components/ComposerPromptEditorTiptap.tsx +++ b/apps/web/src/components/ComposerPromptEditorTiptap.tsx @@ -205,6 +205,7 @@ export interface ComposerPromptEditorProps { onPageScrollKeyDown?: (key: "PageUp" | "PageDown") => void; onPageScrollKeyUp?: (key: string) => void; onPageScrollRelease?: () => void; + onMoveCitationToTray?: ((citation: AssistantCitation) => void) | undefined; onCitationSubmitAndSend?: () => boolean; /** Saves unsaved citation text into replacedValue when a controlled rewrite replaces the document. */ onCitationDraftSave?: (replacedValue: string, savedValue: string) => void; @@ -213,6 +214,7 @@ export interface ComposerPromptEditorProps { } export type ComposerCitationCommentRequest = { + destination?: "inline" | "tray" | undefined; previousValue: string; value: string; citationStart: number; @@ -224,6 +226,7 @@ type CitationInsertedSpaces = { before: boolean; after: boolean }; type OpenCitationComment = { key: string; + destination?: "inline" | "tray" | undefined; sourceAnchor?: AssistantCitationSourceAnchor; removeOnCancel?: CitationInsertedSpaces; }; @@ -232,6 +235,7 @@ const ComposerCitationCommentContext = createContext<{ openComment: OpenCitationComment | null; onOpenChange: (citeKey: string, open: boolean) => void; onDraftChange: (citeKey: string, comment: string) => void; + onMoveToTray?: ((citation: AssistantCitation) => void) | undefined; onSubmitAndSend: () => boolean; }>({ openComment: null, @@ -470,6 +474,7 @@ function ComposerCitationNodeView({ node, editor, getPos }: NodeViewProps) { return typeof pos === "number" ? pos : null; }; + const destination = commentContext.onMoveToTray ? commentTarget?.destination : "inline"; const onSaveComment = (comment: string): boolean => { if (!editor.isEditable) return false; const pos = nodePos(); @@ -478,6 +483,11 @@ function ComposerCitationNodeView({ node, editor, getPos }: NodeViewProps) { if (!current || current.type.name !== "composer-citation") return false; const currentCitation = current.attrs.citation as AssistantCitation; const next = withAssistantCitationComment(currentCitation, comment); + if (destination === "tray" && commentContext.onMoveToTray) { + commentContext.onMoveToTray(next); + onRemove(); + return true; + } const tr = editor.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, citation: next, @@ -553,9 +563,36 @@ function ComposerCitationNodeView({ node, editor, getPos }: NodeViewProps) { sourceAnchor: commentTarget?.sourceAnchor, onOpenChange: (open) => { if (open && !editor.isEditable) return; + if (!open && destination === "tray" && commentContext.onMoveToTray) { + const pos = nodePos(); + const current = pos === null ? null : editor.state.doc.nodeAt(pos); + if (current?.type.name === "composer-citation" && current.attrs.citeKey === citeKey) { + commentContext.onMoveToTray(current.attrs.citation as AssistantCitation); + onRemove(); + } + } commentContext.onOpenChange(citeKey, open); }, - ...(removeOnCancel ? { onCancel: onRemove } : {}), + ...(removeOnCancel + ? { + onCancel: () => { + if (destination === "tray") commentContext.onMoveToTray?.(citation); + onRemove(); + }, + } + : {}), + onMoveToTray: commentContext.onMoveToTray + ? (comment) => { + const pos = nodePos(); + if (pos === null || !editor.isEditable) return; + commentContext.onMoveToTray?.(withAssistantCitationComment(citation, comment)); + editor + .chain() + .focus() + .deleteRange({ from: pos, to: pos + node.nodeSize }) + .run(); + } + : undefined, onSave: onSaveComment, onDraftChange: (comment) => commentContext.onDraftChange(citeKey, comment), onSaveAndSend: (comment) => { @@ -965,6 +1002,7 @@ function ComposerPromptEditorTiptapInner( onPageScrollKeyDown, onPageScrollKeyUp, onPageScrollRelease, + onMoveCitationToTray, onCitationSubmitAndSend, onCitationDraftSave, onPaste, @@ -1018,6 +1056,7 @@ function ComposerPromptEditorTiptapInner( const citationCommentActions = { openComment: openCitation, + onMoveToTray: onMoveCitationToTray, onOpenChange: (nodeKey: string, open: boolean) => { if (!open && citationDraftRef.current?.key === nodeKey) citationDraftRef.current = null; setOpenCitation((current) => { @@ -1671,6 +1710,7 @@ function ComposerPromptEditorTiptapInner( key: citeKey, sourceAnchor: pendingCitation.sourceAnchor, removeOnCancel: pendingCitation.insertedSpaces, + destination: pendingCitation.destination, }); } } @@ -1792,6 +1832,7 @@ function ComposerPromptEditorTiptapInner( key: citeKey, sourceAnchor: request.sourceAnchor, removeOnCancel: request.insertedSpaces, + destination: request.destination, }); } }, diff --git a/apps/web/src/components/chat/AssistantCitationChip.tsx b/apps/web/src/components/chat/AssistantCitationChip.tsx index c64bf5125c66b..7666d9b2c6d47 100644 --- a/apps/web/src/components/chat/AssistantCitationChip.tsx +++ b/apps/web/src/components/chat/AssistantCitationChip.tsx @@ -24,6 +24,8 @@ import { assistantCitationRoute, } from "../../lib/assistantCitationNavigation"; import { cn } from "~/lib/utils"; +import { observeResize } from "~/lib/observeResize"; +import { getVirtualizedScrollFadeClassName } from "../ui/scroll-area"; import { useQuietThreadShell } from "~/state/entities"; import { ContextChip, ContextChipAction, ContextChipLabel } from "../ContextChip"; import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover"; @@ -189,6 +191,7 @@ export function AssistantCitationChip({ sourceAnchor?: AssistantCitationSourceAnchor | undefined; onOpenChange: (open: boolean) => void; onCancel?: () => void; + onMoveToTray?: ((comment: string) => void) | undefined; onSave: (comment: string) => boolean; onSaveAndSend?: (comment: string) => boolean; onDraftChange?: (comment: string) => void; @@ -337,6 +340,8 @@ export function AssistantCitationChip({ { @@ -372,3 +377,34 @@ export function AssistantCitationChip({ ); } + +export function AssistantCitationQuote({ citation }: { citation: AssistantCitation }) { + const [fade, setFade] = useState({ top: false, bottom: false }); + const updateFade = (element: HTMLElement) => { + const top = element.scrollTop > 1; + const bottom = element.scrollHeight - element.clientHeight - element.scrollTop > 1; + setFade((current) => + current.top === top && current.bottom === bottom ? current : { top, bottom }, + ); + }; + const observeFade = (element: HTMLDivElement | null) => + element ? observeResize(element, () => updateFade(element)) : undefined; + return ( +
updateFade(event.currentTarget)} + className={cn( + "max-h-64 min-h-0 space-y-3 self-stretch overflow-y-auto whitespace-pre-wrap wrap-break-word", + getVirtualizedScrollFadeClassName(fade), + )} + > +
+ {citation.text} +
+ {citation.comment ?

{citation.comment}

: null} +
+ ); +} diff --git a/apps/web/src/components/chat/AssistantCitationCommentEditor.tsx b/apps/web/src/components/chat/AssistantCitationCommentEditor.tsx index c8909ddc31fef..f0a98da5df31d 100644 --- a/apps/web/src/components/chat/AssistantCitationCommentEditor.tsx +++ b/apps/web/src/components/chat/AssistantCitationCommentEditor.tsx @@ -1,4 +1,5 @@ import { ASSISTANT_CITATION_MAX_COMMENT_LENGTH, type AssistantCitation } from "@t3tools/contracts"; +import { ArchiveIcon, TextCursorInputIcon } from "lucide-react"; import { T, useGT, Var } from "gt-react"; import { use, useEffect, useRef, useState, type RefObject } from "react"; @@ -7,12 +8,16 @@ import { textDirection } from "~/textDirection"; import { ComposerContextActionsContext } from "../composerContextActions"; import { Button } from "../ui/button"; +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; export function AssistantCitationCommentEditor({ citation, inputRef, onSubmit, onSubmitAndSend, + onMove, + moveLabel, + moveAriaLabel, onCancel, onDraftChange, onVoiceSetupOpenChange, @@ -20,7 +25,10 @@ export function AssistantCitationCommentEditor({ citation: AssistantCitation; inputRef?: RefObject; onSubmit: (comment: string) => boolean; - onSubmitAndSend?: (comment: string) => boolean; + onMove?: ((comment: string) => void) | undefined; + moveLabel?: string; + moveAriaLabel?: string; + onSubmitAndSend?: ((comment: string) => boolean) | undefined; onCancel: () => void; onDraftChange?: (comment: string) => void; onVoiceSetupOpenChange?: (open: boolean) => void; @@ -120,6 +128,25 @@ export function AssistantCitationCommentEditor({ ) : null}
+ {onMove ? ( + + onMove(comment)} + /> + } + > + {moveLabel === gt("Insert inline") ? : } + + {moveLabel} + + ) : null} {/* Wrap as a pair so the recording pill never pushes Save alone onto a new row under Cancel. */}
+
+ ); +} diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx index fb4ed5eb0f626..ae93aceeef66c 100644 --- a/apps/web/src/components/chat/ChatComposer.tsx +++ b/apps/web/src/components/chat/ChatComposer.tsx @@ -1,3 +1,6 @@ +import { AssistantCitationTray, type AssistantCitationTrayHandle } from "./AssistantCitationTray"; +import { useCitationDestination } from "./citationDestination"; +import { serializeComposerTray } from "./composerSubmission"; import { copySnapshot } from "./copySnapshot"; import { VoiceInputSetup } from "./VoiceInputSetup"; import { useComposerTypingGuard } from "./useComposerTypingGuard"; @@ -683,6 +686,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) }, []); const questionPreparations = useQuestionAttachmentPreparation((state) => state.counts); const prompt = composerDraft.prompt; + const composerImages = attachmentDraft.images; const composerFiles = attachmentDraft.files; const inlineFileIdSet = (() => { @@ -833,6 +837,17 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) (store) => store.syncPersistedAttachments, ); const getComposerDraft = useComposerDraftStore((store) => store.getComposerDraft); + const [citationDestination] = useCitationDestination(); + const citationTrayRef = useRef(null); + const setTrayCitations = useStableCallback((citations: ReadonlyArray) => + useComposerDraftStore.getState().setTrayCitations(composerDraftTarget, citations), + ); + const appendTrayCitation = useStableCallback((citation: AssistantCitation) => + setTrayCitations([...(getComposerDraft(composerDraftTarget)?.trayCitations ?? []), citation]), + ); + const submissionPrompt = useStableCallback(() => + serializeComposerTray(promptRef.current, getComposerDraft(composerDraftTarget)?.trayCitations), + ); const setComposerDraftReplyTo = useComposerDraftStore((store) => store.setReplyTo); const navigate = useNavigate(); @@ -1118,6 +1133,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) const composerSendState = deriveComposerSendState({ prompt, + citationCount: composerDraft.trayCitations?.length ?? 0, imageCount: composerImages.length + composerFiles.length, existingAttachmentCount: editingQueuedAttachments?.length ?? 0, terminalContexts: composerTerminalContexts, @@ -1429,7 +1445,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) } if (composerSubmissionError !== null) { - const nextError = getComposerPromptLengthValidationMessage(prompt, m); + const nextError = getComposerPromptLengthValidationMessage( + serializeComposerTray(prompt, composerDraft.trayCitations), + m, + ); if (nextError !== composerSubmissionError) { setComposerSubmissionError(nextError); } @@ -1760,6 +1779,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) start: number; sourceAnchor: AssistantCitationSourceAnchor; insertedSpaces: ComposerCitationCommentRequest["insertedSpaces"]; + destination?: "inline" | "tray" | undefined; }; }, ): boolean => { @@ -1796,6 +1816,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) citationStart: options.citationComment.start, sourceAnchor: options.citationComment.sourceAnchor, insertedSpaces: options.citationComment.insertedSpaces, + destination: options.citationComment.destination, }); } promptRef.current = next.text; @@ -2225,7 +2246,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) return true; } const submission = submitComposerDraft({ - prompt: promptRef.current, + prompt: submissionPrompt(), submissionTarget, event, onSend: (sendEvent) => { @@ -2435,6 +2456,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) deleteStashEntryStable, toggleStashMenuStable, } = useComposerStash({ + settleTrayDraft: () => citationTrayRef.current?.settleDraft() ?? true, environmentId, composerDraftTarget, promptRef, @@ -2641,6 +2663,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) options?: { ensureLeadingBoundary?: boolean; citationCommentAnchor?: AssistantCitationSourceAnchor; + citationDestination?: "inline" | "tray" | undefined; clipboardData?: DataTransfer; }, ): boolean => { @@ -2672,6 +2695,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) citationComment: { start: cursor + (needsLeadingSpace ? 1 : 0), sourceAnchor: options.citationCommentAnchor, + destination: options.citationDestination, insertedSpaces: { before: needsLeadingSpace, after: rangeEnd === cursor }, }, focusEditorAfterReplace: false, @@ -3129,14 +3153,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) focusComposer(); return true; }, - citeAssistantText: (citation, sourceAnchor) => - insertComposerTextStable( + citeAssistantText: (citation, sourceAnchor) => { + return insertComposerTextStable( formatAssistantCitationForComposer(citation, citation.comment), "cursor", - { ensureLeadingBoundary: true, citationCommentAnchor: sourceAnchor }, - ), + { ensureLeadingBoundary: true, citationCommentAnchor: sourceAnchor, citationDestination }, + ); + }, replyToResponse: (response) => { - // An open question owns the composer, and its answer would not carry the reply. if (pendingUserInputs.length > 0 || projectSelectionRequired) return false; setComposerDraftReplyTo(composerDraftTarget, response); focusComposer(); @@ -3281,7 +3305,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) shownPendingApprovalIds: pendingApprovals .map((approval) => approval.requestId) .filter((requestId) => !heldRequestIds.has(requestId)), - prompt: promptRef.current, + prompt: submissionPrompt(), images: composerImagesRef.current, files: composerFilesRef.current, terminalContexts: composerTerminalContextsRef.current, @@ -3335,6 +3359,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) insertComposerDraftTerminalContext, setComposerDraftReplyTo, insertComposerTextStable, + citationDestination, + appendTrayCitation, + submissionPrompt, insertComposerTextAtEndStable, promptRef, composerImagesRef, @@ -3688,7 +3715,27 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps) /> ) : null} + + insertComposerTextStable( + formatAssistantCitationForComposer(citation, citation.comment), + "cursor", + { ensureLeadingBoundary: true }, + ) + } + /> { expect(approvalRedirectNotice(settled)).toBeNull(); }); }); + +it("detects tray edits while uploads are pending", () => { + const citation = { + version: 1 as const, + environmentId: local, + threadId: ThreadId.make("thread"), + messageId: MessageId.make("message"), + text: "quote", + start: 0, + end: 5, + prefix: "", + suffix: "", + }; + const input = { + prompt: "draft", + promptAtSend: "draft", + promptForSend: "draft", + attachmentIds: ["upload"], + attachmentIdsAtSend: ["upload"], + attachmentIdsBeforeAnnotation: ["upload"], + annotationImageId: undefined, + trayCitations: [citation], + liveTrayCitations: [citation], + replyTo: null, + liveReplyTo: null, + }; + expect(composerDraftChangedSinceSend(input)).toBe(false); + expect( + composerDraftChangedSinceSend({ + ...input, + replyTo: responseContextRecord({ citation, itemId: TurnItemId.make("item"), subagents: [] }), + }), + ).toBe(true); + expect( + composerDraftChangedSinceSend({ + ...input, + liveTrayCitations: [{ ...citation, comment: "edited" }], + }), + ).toBe(true); + expect(composerDraftChangedSinceSend({ ...input, liveTrayCitations: [] })).toBe(true); +}); diff --git a/apps/web/src/components/chat/composerSend.logic.ts b/apps/web/src/components/chat/composerSend.logic.ts index 7614822648d10..edbbea1d09763 100644 --- a/apps/web/src/components/chat/composerSend.logic.ts +++ b/apps/web/src/components/chat/composerSend.logic.ts @@ -1,4 +1,10 @@ -import type { EnvironmentId, ThreadContextRecord } from "@t3tools/contracts"; +import type { + AssistantCitation, + EnvironmentId, + ResponseContextRecord, + ThreadContextRecord, +} from "@t3tools/contracts"; +import { serializeComposerTray } from "./composerSubmission"; import { msg } from "gt-react"; import { m, type MessageResolver } from "../../i18n/messages"; import { collectInlineContextIds } from "../../lib/composerContextReferences"; @@ -22,7 +28,8 @@ export function composerDraftContentChanged( before.reviewComments !== after.reviewComments || before.threadContexts !== after.threadContexts || before.environmentContexts !== after.environmentContexts || - before.replyTo !== after.replyTo + before.replyTo !== after.replyTo || + before.trayCitations !== after.trayCitations ); } @@ -120,3 +127,33 @@ export function approvalRedirectNotice( } return null; } + +export function composerDraftChangedSinceSend(input: { + prompt: string; + promptAtSend: string; + promptForSend: string; + attachmentIds: ReadonlyArray; + attachmentIdsAtSend: ReadonlyArray; + attachmentIdsBeforeAnnotation: ReadonlyArray; + annotationImageId: string | undefined; + trayCitations: ReadonlyArray; + liveTrayCitations: ReadonlyArray; + replyTo: ResponseContextRecord | null; + liveReplyTo: ResponseContextRecord | null; +}) { + const sameIds = (left: ReadonlyArray, right: ReadonlyArray) => + left.length === right.length && left.every((id, index) => id === right[index]); + const promptUnchanged = + input.prompt === input.promptAtSend || input.prompt === input.promptForSend; + const attachmentsUnchanged = + sameIds(input.attachmentIds, input.attachmentIdsAtSend) || + (input.annotationImageId !== undefined && + sameIds(input.attachmentIds, input.attachmentIdsBeforeAnnotation)); + return ( + !promptUnchanged || + !attachmentsUnchanged || + input.liveReplyTo !== input.replyTo || + serializeComposerTray("", input.trayCitations) !== + serializeComposerTray("", input.liveTrayCitations) + ); +} diff --git a/apps/web/src/components/chat/composerSubmission.test.ts b/apps/web/src/components/chat/composerSubmission.test.ts index 23e85c9c644b6..a71db60456a75 100644 --- a/apps/web/src/components/chat/composerSubmission.test.ts +++ b/apps/web/src/components/chat/composerSubmission.test.ts @@ -11,7 +11,12 @@ import { } from "@t3tools/shared/assistantCitations"; import { describe, expect, it, vi } from "vite-plus/test"; -import { isComposerSubmissionBlocked, submitComposerDraft } from "./composerSubmission"; +import { + isComposerSubmissionBlocked, + getComposerPromptLengthValidationMessage, + serializeComposerTray, + submitComposerDraft, +} from "./composerSubmission"; const assistantCitation = { version: 1 as const, @@ -209,6 +214,34 @@ describe("submitComposerDraft", () => { }); }); +it("serializes ordered tray citations before inline citations and text", () => { + const second = { ...assistantCitation, comment: "Second" }; + const inline = serializeAssistantCitation({ ...assistantCitation, comment: "Inline" }); + expect(serializeComposerTray(`Reply ${inline}`, [assistantCitation, second])).toBe( + `${serializeAssistantCitation(assistantCitation)}\n${serializeAssistantCitation(second)}\nReply ${inline}`, + ); + expect(serializeComposerTray("Draft")).toBe("Draft"); + expect(serializeComposerTray("", [assistantCitation])).toBe( + serializeAssistantCitation(assistantCitation), + ); +}); + +it("retains tray-inclusive limit errors until the tray is shortened", () => { + const prompt = "x".repeat(PROVIDER_SEND_TURN_MAX_INPUT_CHARS - 1); + const combined = serializeComposerTray(prompt, [assistantCitation]); + const result = submitComposerDraft({ + prompt: combined, + submissionTarget: "provider-turn", + event: undefined, + onSend: vi.fn(), + }); + expect(result.validationMessage).not.toBeNull(); + expect( + getComposerPromptLengthValidationMessage(serializeComposerTray(prompt, [assistantCitation])), + ).toBe(result.validationMessage); + expect(getComposerPromptLengthValidationMessage(prompt)).toBeNull(); +}); + describe("isComposerSubmissionBlocked", () => { const sendBlocked = { noProviderAvailable: true, diff --git a/apps/web/src/components/chat/composerSubmission.ts b/apps/web/src/components/chat/composerSubmission.ts index 147ef6481db8c..2c94137c3e75d 100644 --- a/apps/web/src/components/chat/composerSubmission.ts +++ b/apps/web/src/components/chat/composerSubmission.ts @@ -1,3 +1,5 @@ +import type { AssistantCitation } from "@t3tools/contracts"; +import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations"; import { PROVIDER_SEND_TURN_MAX_INPUT_CHARS } from "@t3tools/contracts"; import { expandAssistantCitationsForProvider } from "@t3tools/shared/assistantCitations"; import { msg } from "gt-react"; @@ -78,3 +80,10 @@ export function submitComposerDraft( } return { validationMessage: null, didDispatch: true }; } + +export function serializeComposerTray( + prompt: string, + citations: ReadonlyArray = [], +): string { + return [...citations.map(serializeAssistantCitation), prompt].filter(Boolean).join("\n"); +} diff --git a/apps/web/src/components/chat/queuedMessageEdit.test.ts b/apps/web/src/components/chat/queuedMessageEdit.test.ts index f67d1843c38be..f2446dac3abcd 100644 --- a/apps/web/src/components/chat/queuedMessageEdit.test.ts +++ b/apps/web/src/components/chat/queuedMessageEdit.test.ts @@ -77,7 +77,18 @@ describe("queued message file edits", () => { ).rejects.toThrow("Retry or remove"); }); - it("keeps file-only edits when another client starts the queued run", () => { + const citation = { + version: 1 as const, + environmentId, + threadId: threadTarget.threadId, + messageId: MessageId.make("message"), + text: "Quote", + start: 0, + end: 5, + prefix: "", + suffix: "", + }; + it.each(["file", "citation"])("keeps %s-only edits when the queued run leaves", (kind) => { const store = useComposerDraftStore.getState(); store.setPrompt(editTarget, "Original message"); const elsewhere: ComposerFileAttachment = { @@ -88,14 +99,20 @@ describe("queued message file edits", () => { uploadedAttachmentId: "upload:elsewhere", uploadEnvironmentId: EnvironmentId.make("other-environment"), }; - store.addFiles(editTarget, [file, elsewhere]); + if (kind === "file") store.addFiles(editTarget, [file, elsewhere]); + else store.setTrayCitations(editTarget, [citation]); expect( recoverQueuedMessageEdit({ editTarget, threadTarget, originalText: "Original message" }), ).toBe("kept"); expect(store.getComposerDraft(threadTarget)?.prompt).toBe("Original message"); // An upload this environment cannot reach comes back as a file to reattach, not a dropped chip. const { uploadedAttachmentId: _id, uploadEnvironmentId: _env, ...reattach } = elsewhere; - expect(store.getComposerDraft(threadTarget)?.files).toEqual([file, reattach]); + expect(store.getComposerDraft(threadTarget)?.files).toEqual( + kind === "file" ? [file, reattach] : [], + ); + expect(store.getComposerDraft(threadTarget)?.trayCitations ?? []).toEqual( + kind === "citation" ? [citation] : [], + ); expect(store.getComposerDraft(editTarget)).toBeNull(); }); diff --git a/apps/web/src/components/chat/queuedMessageEdit.ts b/apps/web/src/components/chat/queuedMessageEdit.ts index c3f14d6fe2247..524253547fa8a 100644 --- a/apps/web/src/components/chat/queuedMessageEdit.ts +++ b/apps/web/src/components/chat/queuedMessageEdit.ts @@ -36,7 +36,10 @@ export function recoverQueuedMessageEdit(input: { editChanged: input.removedExistingAttachment === true || (draft !== null && - (draft.prompt !== input.originalText || draft.images.length > 0 || draft.files.length > 0)), + (draft.prompt !== input.originalText || + draft.images.length > 0 || + draft.files.length > 0 || + (draft.trayCitations?.length ?? 0) > 0)), // A cleared edit has nothing to put back, so it can only be discarded. threadDraftEmpty: composerDraftHasUserContent(draft) && diff --git a/apps/web/src/components/chat/useComposerSend.ts b/apps/web/src/components/chat/useComposerSend.ts index 19a524369cbf7..7a10da513ecd4 100644 --- a/apps/web/src/components/chat/useComposerSend.ts +++ b/apps/web/src/components/chat/useComposerSend.ts @@ -1,3 +1,4 @@ +import { serializeComposerTray } from "./composerSubmission"; import { msg } from "gt-react"; import { thrownErrorMessage } from "@t3tools/client-runtime/errors"; import { m } from "~/i18n/messages"; @@ -101,6 +102,7 @@ import { useClientSettingsHydrated } from "../../hooks/useSettings"; import { useStableCallback } from "../../hooks/useStableCallback"; import { environmentPresentations } from "../../state/presentation"; import { + composerDraftChangedSinceSend, approvalRedirectNotice, composerDraftContentChanged, loadBalancingSendWarning, @@ -494,6 +496,10 @@ export function useComposerSend(input: ComposerSendInput) { }); return; } + const trayCitations = [ + ...(useComposerDraftStore.getState().getComposerDraft(composerDraftTarget)?.trayCitations ?? + []), + ]; // Where side chats are unavailable, `/side` text can still be a literal answer. if (sideChatDisabledReason !== null && sideChatCommand && !answeringQuestion) { toastManager.add( @@ -507,6 +513,7 @@ export function useComposerSend(input: ComposerSendInput) { } if (onSideChat && sendCtx && sideChatCommand && sideChatDisabledReason === null) { if ( + trayCitations.length > 0 || sendCtx.images.length > 0 || sendCtx.files.length > 0 || filterTerminalContextsWithText(sendCtx.terminalContexts).length > 0 || @@ -609,19 +616,19 @@ export function useComposerSend(input: ComposerSendInput) { }); // A direct "send annotation" writes the draft and sends in the same tick; the reference // must be in the text now, not after the next render. - const draftPrompt = directAnnotation - ? ensureInlineContextReferences(promptRef.current, [ + const serializedPrompt = directAnnotation + ? ensureInlineContextReferences(sendCtx.prompt, [ previewAnnotationContextReference(directAnnotation.annotation), ]) - : promptRef.current; + : sendCtx.prompt; const replyTo = useComposerDraftStore.getState().getComposerDraft(composerDraftTarget)?.replyTo ?? null; // The reply leads the message, so its card sits above the text it is about. Text that // already points at that response, from a pasted card, keeps its one reference. const promptForSend = - replyTo && !collectInlineContextIds(draftPrompt).includes(replyTo.contextId) - ? `${formatInlineContextReference(responseContextReference(replyTo))} ${draftPrompt}` - : draftPrompt; + replyTo && !collectInlineContextIds(serializedPrompt).includes(replyTo.contextId) + ? `${formatInlineContextReference(responseContextReference(replyTo))} ${serializedPrompt}` + : serializedPrompt; const strandedThread = threadContextsOutsideEnvironment({ text: promptForSend, records: composerThreadContexts, @@ -701,8 +708,27 @@ export function useComposerSend(input: ComposerSendInput) { composerThreadContexts.length + composerEnvironmentContexts.length, }); + const commandText = directAnnotation ? trimmed : promptAtSend.trim(); + if ( + trayCitations.length > 0 && + ((freshSessionAvailable && isClearComposerCommand(commandText)) || + (ctxSelectedProvider === "codex" && + multipleModelSelections === null && + parseCodexFeedbackCommand(commandText) !== null)) + ) { + toastManager.add( + stackedThreadToast({ + type: "warning", + title: m(msg("This command takes text only")), + description: m(msg("Remove the tray citations, then send the command again.")), + }), + ); + return; + } const feedbackCommand = ctxSelectedProvider === "codex" && + trayCitations.length === 0 && + replyTo === null && composerImages.length === 0 && composerFiles.length === 0 && sendableComposerTerminalContexts.length === 0 && @@ -710,7 +736,7 @@ export function useComposerSend(input: ComposerSendInput) { composerReviewComments.length === 0 && composerThreadContexts.length === 0 && composerEnvironmentContexts.length === 0 - ? parseCodexFeedbackCommand(trimmed) + ? parseCodexFeedbackCommand(commandText) : null; if (feedbackCommand && multipleModelSelections === null) { if (!isServerThread || activeThread.activeProviderThreadId === null) { @@ -728,7 +754,7 @@ export function useComposerSend(input: ComposerSendInput) { { submission: { id: newMessageId(), - command: trimmed, + command: commandText, createdAt: new Date().toISOString(), }, clearDraft: () => { @@ -762,6 +788,7 @@ export function useComposerSend(input: ComposerSendInput) { return; } const composerHoldsOnlyText = + trayCitations.length === 0 && composerImages.length === 0 && composerFiles.length === 0 && sendableComposerTerminalContexts.length === 0 && @@ -770,7 +797,7 @@ export function useComposerSend(input: ComposerSendInput) { composerThreadContexts.length === 0 && composerEnvironmentContexts.length === 0 && replyTo === null; - if (freshSessionAvailable && composerHoldsOnlyText && isClearComposerCommand(trimmed)) { + if (freshSessionAvailable && composerHoldsOnlyText && isClearComposerCommand(commandText)) { armFreshSession(routeThreadKey); promptRef.current = ""; clearComposerDraftContent(composerDraftTarget); @@ -807,6 +834,12 @@ export function useComposerSend(input: ComposerSendInput) { } const threadIdForSend = activeThread.id; const sendSnapshot = snapshotComposerSend({ + draftPrompt: directAnnotation + ? ensureInlineContextReferences(promptAtSend, [ + previewAnnotationContextReference(directAnnotation.annotation), + ]) + : promptAtSend, + trayCitations, prompt: promptForSend, images: composerImages, files: composerFiles, @@ -1034,6 +1067,44 @@ export function useComposerSend(input: ComposerSendInput) { return; } } + // A draft edited since send, or a paste still landing in it, is no longer the message + // the user sent. + const attachmentIdsAtSend = composerAttachmentsSnapshot.map((attachment) => attachment.id); + // A direct annotation send writes its image and reference into the draft as it sends, + // so the live draft may still lack them; anything else differing is a real edit. + const annotationImageId = directAnnotation?.image?.id; + const attachmentIdsBeforeAnnotation = attachmentIdsAtSend.filter( + (id) => id !== annotationImageId, + ); + const draftChangedSinceSend = () => { + if (composerRef.current?.hasPendingAttachments() === true) return true; + const sendContext = composerRef.current?.getSendContext(); + const attachmentIds = sendContext + ? [...sendContext.images, ...sendContext.files].map((attachment) => attachment.id) + : attachmentIdsAtSend; + return composerDraftChangedSinceSend({ + prompt: promptRef.current, + promptAtSend, + promptForSend, + attachmentIds, + attachmentIdsAtSend, + attachmentIdsBeforeAnnotation, + annotationImageId, + trayCitations, + replyTo, + liveReplyTo: + useComposerDraftStore.getState().getComposerDraft(composerDraftTarget)?.replyTo ?? null, + liveTrayCitations: + useComposerDraftStore.getState().getComposerDraft(composerDraftTarget)?.trayCitations ?? + [], + }); + }; + if (currentRouteThreadKeyRef.current === routeThreadKey && draftChangedSinceSend()) { + sendInFlightRef.current = false; + setThreadError(threadIdForSend, m(msg("Your message changed, so it wasn't sent."))); + return; + } + // A message sent while approvals are pending redirects the agent. They are declined only // here, after everything above has accepted the send, so local commands and rejected // drafts leave them alone. After navigating away during an upload, the shown approvals @@ -1045,34 +1116,6 @@ export function useComposerSend(input: ComposerSendInput) { ) : []; if (approvalsToDecline.length > 0 || approvalFeedbackTarget !== undefined) { - // A draft edited since send, or a paste still landing in it, is no longer the message - // the user sent. - const attachmentIdsAtSend = composerAttachmentsSnapshot.map((attachment) => attachment.id); - // A direct annotation send writes its image and reference into the draft as it sends, - // so the live draft may still lack them; anything else differing is a real edit. - const annotationImageId = directAnnotation?.image?.id; - const attachmentIdsBeforeAnnotation = attachmentIdsAtSend.filter( - (id) => id !== annotationImageId, - ); - const sameIds = (left: ReadonlyArray, right: ReadonlyArray) => - left.length === right.length && left.every((id, index) => id === right[index]); - const draftChangedSinceSend = () => { - if (composerRef.current?.hasPendingAttachments() === true) return true; - const sendContext = composerRef.current?.getSendContext(); - const attachmentIds = sendContext - ? [...sendContext.images, ...sendContext.files].map((attachment) => attachment.id) - : attachmentIdsAtSend; - const promptUnchanged = - promptRef.current === promptAtSend || promptRef.current === promptForSend; - const attachmentsUnchanged = - sameIds(attachmentIds, attachmentIdsAtSend) || - (annotationImageId !== undefined && - sameIds(attachmentIds, attachmentIdsBeforeAnnotation)); - // The reply is not in the prompt, so cancelling or changing it is checked on its own. - const liveReply = - useComposerDraftStore.getState().getComposerDraft(composerDraftTarget)?.replyTo ?? null; - return !promptUnchanged || !attachmentsUnchanged || liveReply !== replyTo; - }; const draftBeforeDecline = useComposerDraftStore .getState() .getComposerDraft(composerDraftTarget); @@ -1493,7 +1536,10 @@ export function useComposerSend(input: ComposerSendInput) { ) ) { // A draft typed meanwhile keeps the composer, so the failed text stays reachable here. - const failedText = sendSnapshot.draftText; + const failedText = serializeComposerTray( + sendSnapshot.draftPrompt, + sendSnapshot.trayCitations, + ); const hasText = failedText.trim().length > 0; // An image-only message has nothing to copy, but its failure still needs a notice. toastManager.add( @@ -1529,16 +1575,16 @@ export function useComposerSend(input: ComposerSendInput) { } else { const retryComposerImages = restoreComposerDraft(composerDraftTarget, sendSnapshot); if (currentRouteThreadKeyRef.current === routeThreadKey) { - promptRef.current = sendSnapshot.draftText; + promptRef.current = sendSnapshot.draftPrompt; composerImagesRef.current = retryComposerImages; composerFilesRef.current = composerFilesSnapshot; composerTerminalContextsRef.current = composerTerminalContextsSnapshot; composerRef.current?.resetCursorState({ cursor: collapseExpandedComposerCursor( - sendSnapshot.draftText, - sendSnapshot.draftText.length, + sendSnapshot.draftPrompt, + sendSnapshot.draftPrompt.length, ), - prompt: sendSnapshot.draftText, + prompt: sendSnapshot.draftPrompt, detectTrigger: true, }); } diff --git a/apps/web/src/components/chat/useComposerStash.ts b/apps/web/src/components/chat/useComposerStash.ts index b574b8a78eb91..68319f749e312 100644 --- a/apps/web/src/components/chat/useComposerStash.ts +++ b/apps/web/src/components/chat/useComposerStash.ts @@ -76,6 +76,7 @@ import { useStableCallback } from "../../hooks/useStableCallback"; * and the stash shortcut. Its state lives here so the composer body only wires it up. */ export function useComposerStash(input: { + readonly settleTrayDraft?: () => boolean; readonly environmentId: EnvironmentId; readonly composerDraftTarget: ChatComposerProps["composerDraftTarget"]; readonly promptRef: ChatComposerProps["promptRef"]; @@ -261,6 +262,13 @@ export function useComposerStash(input: { }) : reference.source; }); + const currentDraft = getComposerDraft(composerDraftTarget); + useComposerDraftStore + .getState() + .setTrayCitations(composerDraftTarget, [ + ...(currentDraft?.trayCitations ?? []), + ...(entry.trayCitations ?? []), + ]); const currentPrompt = promptRef.current; const nextPrompt = restoredPrompt.length === 0 @@ -505,6 +513,7 @@ export function useComposerStash(input: { const deleteStashEntryStable = useStableCallback(deleteStashEntry); const stashCurrentPrompt = async () => { + if (input.settleTrayDraft?.() === false) return; // Stashing clears the draft. A pasted attachment still downloading would then land in the // emptied composer instead of travelling with the entry it belongs to. if (pendingDraftWork.has(attachmentTargetKey)) { @@ -539,7 +548,12 @@ export function useComposerStash(input: { }), ), ]; - if (prompt.length === 0 && images.length === 0 && files.length === 0) { + if ( + prompt.length === 0 && + !getComposerDraft(composerDraftTarget)?.trayCitations?.length && + images.length === 0 && + files.length === 0 + ) { const entries = usePromptStashStore.getState().entries; const entry = entries.length === 1 ? entries[0] : undefined; if (entry && !entry.pendingImageCount) { @@ -607,6 +621,7 @@ export function useComposerStash(input: { id: entryId, createdAt: new Date().toISOString(), prompt, + trayCitations: getComposerDraft(composerDraftTarget)?.trayCitations ?? [], attachments: [], ...(stashedFiles.length > 0 ? { files: stashedFiles } : {}), droppedImageNames: [], diff --git a/apps/web/src/components/chat/useMultipleModelSend.ts b/apps/web/src/components/chat/useMultipleModelSend.ts index 9b9827ed8cde5..e1b28edd730a8 100644 --- a/apps/web/src/components/chat/useMultipleModelSend.ts +++ b/apps/web/src/components/chat/useMultipleModelSend.ts @@ -249,13 +249,13 @@ export function useMultipleModelSend(input: MultipleModelSendInput) { if (clearedDraft) { restoreComposerDraft(composerDraftTarget, sendSnapshot); if (composerRef.current && currentRouteThreadKeyRef.current === routeThreadKey) { - promptRef.current = sendSnapshot.draftText; + promptRef.current = sendSnapshot.draftPrompt; composerRef.current.resetCursorState({ cursor: collapseExpandedComposerCursor( - sendSnapshot.draftText, - sendSnapshot.draftText.length, + sendSnapshot.draftPrompt, + sendSnapshot.draftPrompt.length, ), - prompt: sendSnapshot.draftText, + prompt: sendSnapshot.draftPrompt, detectTrigger: true, }); } diff --git a/apps/web/src/components/promptLinks/copyPromptLink.test.ts b/apps/web/src/components/promptLinks/copyPromptLink.test.ts new file mode 100644 index 0000000000000..3a7993c87e256 --- /dev/null +++ b/apps/web/src/components/promptLinks/copyPromptLink.test.ts @@ -0,0 +1,43 @@ +import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts"; +import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations"; +import { expect, it } from "vite-plus/test"; +import { useComposerDraftStore } from "../../composerDraftStore"; +import { composerPromptLink, promptLinkFor } from "./copyPromptLink"; + +it.each([false, true])("exports tray quotes and comments with context=%s", (withContext) => { + const target = scopeThreadRef(EnvironmentId.make("link-test"), ThreadId.make("tray")); + const citation = { + version: 1 as const, + environmentId: target.environmentId, + threadId: target.threadId, + messageId: MessageId.make("source"), + text: "quote", + start: 0, + end: 5, + prefix: "", + suffix: "", + comment: "Keep this", + }; + const store = useComposerDraftStore.getState(); + store.setTrayCitations(target, [citation]); + for (const prompt of ["", "Reply"]) { + store.setPrompt(target, prompt); + expect( + composerPromptLink({ + target, + project: undefined, + providers: [], + threadModelSelection: null, + threadStarted: false, + withContext, + }), + ).toBe( + promptLinkFor( + [serializeAssistantCitation(citation), prompt].filter(Boolean).join("\n"), + withContext ? { repository: null, provider: null, model: null } : undefined, + ), + ); + } + store.clearComposerContent(target); +}); diff --git a/apps/web/src/components/promptLinks/copyPromptLink.ts b/apps/web/src/components/promptLinks/copyPromptLink.ts index 8525495a6dbfb..a4a2aedf25c4a 100644 --- a/apps/web/src/components/promptLinks/copyPromptLink.ts +++ b/apps/web/src/components/promptLinks/copyPromptLink.ts @@ -18,6 +18,8 @@ import { writeTextToClipboard } from "~/hooks/useCopyToClipboard"; import { configuredHostedAppUrl } from "~/hostedPairing"; import { draftModelSelectionApplies } from "~/lib/chatThreadActions"; +import { serializeComposerTray } from "../chat/composerSubmission"; + import { stackedThreadToast, toastManager } from "../ui/toast"; import { msg } from "gt-react"; import { m } from "~/i18n/messages"; @@ -57,7 +59,8 @@ export function composerPromptLink(input: { }): string | null { const draft = useComposerDraftStore.getState().getComposerDraft(input.target); if (!draft) return null; - if (!input.withContext) return promptLinkFor(draft.prompt); + const prompt = serializeComposerTray(draft.prompt, draft.trayCitations); + if (!input.withContext) return promptLinkFor(prompt); const selection = (draft.activeProvider && draftModelSelectionApplies(draft, input.threadStarted) ? draft.modelSelectionByProvider[draft.activeProvider] @@ -66,7 +69,7 @@ export function composerPromptLink(input: { ? (input.providers.find((candidate) => candidate.instanceId === selection.instanceId)?.driver ?? null) : null; - return promptLinkFor(draft.prompt, { + return promptLinkFor(prompt, { repository: promptLinkRepositoryOf(input.project), provider, model: provider === null ? null : (selection?.model ?? null), diff --git a/apps/web/src/components/settings/CitationDestinationSetting.tsx b/apps/web/src/components/settings/CitationDestinationSetting.tsx new file mode 100644 index 0000000000000..32d9e0b44da7c --- /dev/null +++ b/apps/web/src/components/settings/CitationDestinationSetting.tsx @@ -0,0 +1,25 @@ +import { useGT } from "gt-react"; +import { useCitationDestination } from "../chat/citationDestination"; +import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select"; +export function CitationDestinationSetting() { + const gt = useGT(); + const [destination, setDestination] = useCitationDestination(); + return ( + + ); +} diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx index e0a12417848fa..eec7f7f0669cc 100644 --- a/apps/web/src/components/settings/SettingsPanels.tsx +++ b/apps/web/src/components/settings/SettingsPanels.tsx @@ -1,3 +1,4 @@ +import { CitationDestinationSetting } from "./CitationDestinationSetting"; import { thrownErrorMessage } from "@t3tools/client-runtime/errors"; import { m as resolveMessage } from "~/i18n/messages"; import { useAtomValue } from "@effect/atom-react"; @@ -1228,6 +1229,11 @@ export function ChatSettingsPanel() { return ( + } + /> { }); }); +describe("composer citation tray", () => { + beforeEach(resetComposerDraftStore); + it("persists a citation-only draft, moves drafts, and clears citations with sent content", () => { + const source = scopeThreadRef(TEST_ENVIRONMENT_ID, ThreadId.make("tray-source")); + const target = scopeThreadRef(TEST_ENVIRONMENT_ID, ThreadId.make("tray-target")); + const citation = { + version: 1 as const, + environmentId: TEST_ENVIRONMENT_ID, + threadId: source.threadId, + messageId: MessageId.make("message"), + text: "Quote", + start: 0, + end: 5, + prefix: "", + suffix: "", + comment: "Comment", + }; + const store = useComposerDraftStore.getState(); + store.setTrayCitations(source, [citation]); + const persisted = JSON.parse( + JSON.stringify(partializeComposerDraftStoreState(useComposerDraftStore.getState())), + ); + const merge = useComposerDraftStore.persist.getOptions().merge!; + const restored = merge(persisted, useComposerDraftStore.getInitialState()); + expect(restored.draftsByThreadKey[scopedThreadKey(source)]?.trayCitations).toEqual([citation]); + persisted.draftsByThreadKey[scopedThreadKey(source)].prompt = "Legacy draft"; + delete persisted.draftsByThreadKey[scopedThreadKey(source)].trayCitations; + const legacy = merge(persisted, useComposerDraftStore.getInitialState()); + expect(legacy.draftsByThreadKey[scopedThreadKey(source)]?.prompt).toBe("Legacy draft"); + expect(legacy.draftsByThreadKey[scopedThreadKey(source)]?.trayCitations ?? []).toEqual([]); + store.setTrayCitations(target, [citation]); + store.setTrayCitations(target, []); + expect(store.getComposerDraft(target)).toBeNull(); + store.moveComposerContent(source, target); + expect(store.getComposerDraft(target)?.trayCitations).toEqual([citation]); + expect(store.getComposerDraft(source)?.trayCitations ?? []).toEqual([]); + store.clearComposerContent(target); + expect(store.getComposerDraft(target)?.trayCitations ?? []).toEqual([]); + }); +}); + describe("composerDraftStore checkout pull request", () => { const projectId = ProjectId.make("project-checkout"); const projectRef = scopeProjectRef(TEST_ENVIRONMENT_ID, projectId); diff --git a/apps/web/src/composerDraftStore.ts b/apps/web/src/composerDraftStore.ts index 3c64aa0f65817..d607a60cad39b 100644 --- a/apps/web/src/composerDraftStore.ts +++ b/apps/web/src/composerDraftStore.ts @@ -1,3 +1,4 @@ +import { AssistantCitation } from "@t3tools/contracts"; import { composerFileAttachmentMimeType, composerImageDedupKey, @@ -338,6 +339,7 @@ type PersistedTerminalContextDraft = typeof PersistedTerminalContextDraft.Type; const PersistedComposerThreadDraftState = Schema.Struct({ prompt: Schema.String, + trayCitations: Schema.optionalKey(Schema.Array(AssistantCitation)), attachments: Schema.Array(PersistedComposerImageAttachment), files: Schema.optionalKey(Schema.Array(PersistedComposerDraftFileAttachment)), terminalContexts: Schema.optionalKey(Schema.Array(PersistedTerminalContextDraft)), @@ -464,6 +466,7 @@ const contextInsertionHandlers = new Map; images: ComposerImageAttachment[]; files: ComposerFileAttachment[]; nonPersistedImageIds: string[]; @@ -489,6 +492,7 @@ export function composerDraftHasUserContent( return false; } return ( + (draft.trayCitations?.length ?? 0) > 0 || draft.prompt.trim().length > 0 || draft.images.length > 0 || draft.files.length > 0 || @@ -635,6 +639,10 @@ interface ComposerDraftStoreState { finalizePromotedDraftThread: (threadRef: ComposerThreadTarget) => void; clearDraftThread: (threadRef: ComposerThreadTarget) => void; setStickyModelSelection: (modelSelection: ModelSelection | null | undefined) => void; + setTrayCitations: ( + threadRef: ComposerThreadTarget, + citations: ReadonlyArray, + ) => void; setPrompt: (threadRef: ComposerThreadTarget, prompt: string) => void; setTerminalContexts: (threadRef: ComposerThreadTarget, contexts: TerminalContextDraft[]) => void; setModelSelection: ( @@ -896,6 +904,7 @@ const EMPTY_THREAD_DRAFT = Object.freeze({ function createEmptyThreadDraft(): ComposerThreadDraftState { return { + trayCitations: [], prompt: "", images: [], files: [], @@ -1011,6 +1020,7 @@ function normalizeTerminalContextsForThread( function shouldRemoveDraft(draft: ComposerThreadDraftState): boolean { return ( + (draft.trayCitations?.length ?? 0) === 0 && draft.prompt.length === 0 && draft.images.length === 0 && draft.files.length === 0 && @@ -2250,6 +2260,7 @@ function normalizePersistedDraftsByThreadId( const hasModelData = Object.keys(modelSelectionByProvider).length > 0 || activeProvider !== null; if ( + !draftCandidate.trayCitations?.length && promptCandidate.length === 0 && attachments.length === 0 && files.length === 0 && @@ -2279,6 +2290,9 @@ function normalizePersistedDraftsByThreadId( })(); nextDraftsByThreadKey[normalizedThreadKey] = { prompt, + trayCitations: Array.isArray(draftCandidate.trayCitations) + ? draftCandidate.trayCitations.filter(Schema.is(AssistantCitation)) + : [], attachments, ...(files.length > 0 ? { files } : {}), ...(terminalContexts.length > 0 ? { terminalContexts } : {}), @@ -2304,6 +2318,7 @@ function normalizePersistedDraftsByThreadId( function persistedComposerDraftHasUserContent(draft: PersistedComposerThreadDraftState): boolean { return ( + (draft.trayCitations?.length ?? 0) > 0 || draft.prompt.trim().length > 0 || draft.attachments.length > 0 || (draft.files?.length ?? 0) > 0 || @@ -2384,6 +2399,7 @@ export function partializeComposerDraftStoreState( const hasModelData = Object.keys(draft.modelSelectionByProvider).length > 0 || draft.activeProvider !== null; if ( + (draft.trayCitations?.length ?? 0) === 0 && draft.prompt.length === 0 && draft.persistedAttachments.length === 0 && draft.files.length === 0 && @@ -2401,6 +2417,7 @@ export function partializeComposerDraftStoreState( } const persistedDraft: DeepMutable = { prompt: draft.prompt, + ...(draft.trayCitations?.length ? { trayCitations: [...draft.trayCitations] } : {}), attachments: draft.persistedAttachments, ...(draft.files.length > 0 ? { @@ -2713,6 +2730,7 @@ function toHydratedThreadDraft( })) ?? []; return { + trayCitations: persistedDraft.trayCitations ?? [], prompt: ensureInlineContextReferences(persistedDraft.prompt, [ ...(persistedDraft.reviewComments ?? []).map(reviewCommentContextReference), ...(persistedDraft.previewAnnotations ?? []).map(previewAnnotationContextReference), @@ -3259,6 +3277,20 @@ const composerDraftStore = create()( return { draftsByThreadKey: nextDraftsByThreadKey }; }); }, + setTrayCitations: (threadRef, citations) => { + const threadKey = resolveComposerDraftKey(get(), threadRef); + if (!threadKey) return; + set((state) => { + const nextDraft = { + ...(state.draftsByThreadKey[threadKey] ?? createEmptyThreadDraft()), + trayCitations: citations, + }; + const draftsByThreadKey = { ...state.draftsByThreadKey }; + if (shouldRemoveDraft(nextDraft)) delete draftsByThreadKey[threadKey]; + else draftsByThreadKey[threadKey] = nextDraft; + return { draftsByThreadKey }; + }); + }, setPrompt: (threadRef, prompt) => { const threadKey = resolveComposerDraftKey(get(), threadRef) ?? ""; if (threadKey.length === 0) { @@ -4404,6 +4436,7 @@ const composerDraftStore = create()( } const nextDraft: ComposerThreadDraftState = { ...current, + trayCitations: [], prompt: ensureInlineContextReferences("", [ ...current.terminalContexts.map(terminalContextReference), ...current.reviewComments.map(reviewCommentContextReference), diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 4c9f0f6d27e4f..6e7084058b171 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -3104,6 +3104,7 @@ "f8031a49c6e9fe25": "Zitierten Assistententext anzeigen: {label}", "bc8c06fc6e15744d": "Zitatkommentar bearbeiten", "3461664615eadd38": "Kommentar zum Zitat hinzufügen", + "3d91ca20565a6da9": "In die Ablage verschieben", "0fe5a2bc51368d37": "Ausgewählten Text kommentieren", "65f7fd6a7f3a586e": "Enter speichert den Zitatkommentar; Command/Ctrl+Enter speichert und sendet; Shift+Enter für eine neue Zeile.", "e3903eb8bb6b0731": "Optionalen Kommentar hinzufügen...", @@ -3123,6 +3124,18 @@ "2d52b83b33b6d842": "Klicke auf das Zitat, um es erneut zu versuchen.", "a1b2db80983184df": "Der zitierte Text hat sich geändert", "c6a4cb25e4dca706": "Die Quellantwort wird angezeigt. Das gespeicherte Zitat bleibt unverändert.", + "bd85eb1999402fef": "{count, plural, one {{count} Anmerkung} other {{count} Anmerkungen}}", + "ecfffb229d32aa51": "Zitatablage", + "3a9c3017a3494d29": "{number}. Ausgewählter Text:", + "21dd7ece52b5e85b": "Benutzerkommentar: {comment}", + "f86d1b3defd75cea": "Keine", + "f6e34055516fc5dd": "Im Text einfügen", + "78defd0b8aed3e59": "Anmerkung {number} im Text einfügen", + "7c9c33f828f5e5ac": "Anmerkung {number} bearbeiten", + "79ae43d8b6d1cce4": "Kommentar bearbeiten", + "2db4199182e9a7c3": "Anmerkung {number} löschen", + "d44cdf2b7aa3dec7": "Anmerkung löschen", + "12fa84568a7dc61f": "Alle Anmerkungen löschen", "65d4ba7177bca2bf": "Die Auswahl ist zu lang zum Zitieren", "3390f0b2396998c0": "Auswahl im Eingabefeld zitieren", "e5dc8d61a6d178ed": "Auswahl kürzen", @@ -4607,6 +4620,8 @@ "811b25d99525bcf7": "Der Agent dieses Rechners kann „{title}“ nicht lesen. Entferne es oder wechsle zum Senden zurück zu {owner}.", "55f9621a69825e20": "Nachricht in der Warteschlange nicht aktualisiert", "1072fb0e2846f2a4": "Eine eingereihte Nachricht kann nicht in einen Nebenchat verschoben werden. Entferne /side oder /btw, um sie zu speichern.", + "9c9e764995cff9e2": "Dieser Befehl akzeptiert nur Text", + "6f2e21443a2ba9f0": "Entferne die Zitate aus der Ablage und sende den Befehl erneut.", "170ab9bcffd26887": "Starte zuerst einen Codex-Thread", "c9852e2500018a3c": "Sende eine Nachricht, bevor du Feedback gibst.", "837c3082352db701": "Wähle zuerst ein Projekt", @@ -5167,7 +5182,6 @@ "1e3375e17e0b0704": "Erforderlich", "a7f7db481296601d": "Installiert", "010a240f0d18e933": "Die Versionen wurden nicht geprüft.", - "f86d1b3defd75cea": "Keine", "a1c433ed68afa03e": "Graustufen", "29ae38749c912213": "Rot / Grün (Protanopie)", "ab6d391ce2ab64c1": "Grün / Rot (Deuteranopie)", @@ -6715,7 +6729,6 @@ "9e65f6bc12538296": "Aufgelöst", "d74fc95719fe5478": "Offen", "4276743ee60a3c62": "{count, plural, one {{count} Kommentar} other {{count} Kommentare}}", - "79ae43d8b6d1cce4": "Kommentar bearbeiten", "1eadc7b869a55c68": "Weitere Kommentare laden", "3f9bc820dffd099f": "Antwort", "7975bd47236d8207": "Auf diese Unterhaltung antworten", @@ -7634,6 +7647,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Ziel für neue Zitate", + "771d5e7bf4487c68": "Im Text (Standard)", + "f955b5bd7b177178": "In der Ablage", "d0e747ae0c4f68a5": "t3 konnte nicht installiert werden", "ba3ac338f36cba74": "t3 konnte nicht entfernt werden", "9c942b53b58119b8": "t3 konnte nicht zu PATH hinzugefügt werden", @@ -9735,6 +9751,7 @@ "c7b0bcb64f48db85": "Zeitstempelformat", "21846d2fd70b4f80": "{modifierLabel} + Enter für mehrzeilige Prompts", "761ac81a418bd87d": "Immer {modifierLabel} + Enter", + "2270c6ae8906c7fa": "Wähle aus, wo neu zitierter Assistententext auf diesem Client eingefügt wird.", "3a6fb236cd3f521b": "Formatiertes Markdown beim Tippen anzeigen.", "f9251f92691626cd": "Rich-Text-Eingabefeld auf Standard zurücksetzen", "b59ca5c465dbe742": "Lege fest, wann Enter einen Prompt sendet oder eine neue Zeile einfügt", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index c40470b46e6ae..c2ccde9390910 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "View cited assistant text: {label}", "bc8c06fc6e15744d": "Edit citation comment", "3461664615eadd38": "Add comment to citation", + "3d91ca20565a6da9": "Move to tray", "0fe5a2bc51368d37": "Comment on selected text", "65f7fd6a7f3a586e": "Enter to save the citation comment; Command/Ctrl+Enter to save and send; Shift+Enter for a new line.", "e3903eb8bb6b0731": "Add an optional comment...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Click the citation to try again.", "a1b2db80983184df": "The quoted text has changed", "c6a4cb25e4dca706": "Showing the source response. The saved quote is unchanged.", + "bd85eb1999402fef": "{count, plural, one {{count} annotation} other {{count} annotations}}", + "ecfffb229d32aa51": "Citation tray", + "3a9c3017a3494d29": "{number}. Selected text:", + "21dd7ece52b5e85b": "User comment: {comment}", + "f86d1b3defd75cea": "None", + "f6e34055516fc5dd": "Insert inline", + "78defd0b8aed3e59": "Insert annotation {number} inline", + "7c9c33f828f5e5ac": "Edit annotation {number}", + "79ae43d8b6d1cce4": "Edit comment", + "2db4199182e9a7c3": "Delete annotation {number}", + "d44cdf2b7aa3dec7": "Delete annotation", + "12fa84568a7dc61f": "Clear all annotations", "65d4ba7177bca2bf": "Selection is too long to cite", "3390f0b2396998c0": "Cite selection in composer", "e5dc8d61a6d178ed": "Shorten selection", @@ -4606,6 +4619,8 @@ "811b25d99525bcf7": "This machine's agent can't read \"{title}\". Remove it, or switch back to {owner} to send.", "55f9621a69825e20": "Queued message not updated", "1072fb0e2846f2a4": "A queued message can't move to a side chat. Remove /side or /btw to save it.", + "9c9e764995cff9e2": "This command takes text only", + "6f2e21443a2ba9f0": "Remove the tray citations, then send the command again.", "170ab9bcffd26887": "Start a Codex thread first", "c9852e2500018a3c": "Send a message before you submit feedback.", "837c3082352db701": "Choose a project first", @@ -5168,7 +5183,6 @@ "1e3375e17e0b0704": "Required", "a7f7db481296601d": "Installed", "010a240f0d18e933": "Versions have not been checked.", - "f86d1b3defd75cea": "None", "a1c433ed68afa03e": "Grayscale", "29ae38749c912213": "Red / green (protanopia)", "ab6d391ce2ab64c1": "Green / red (deuteranopia)", @@ -6721,7 +6735,6 @@ "9e65f6bc12538296": "Resolved", "d74fc95719fe5478": "Open", "4276743ee60a3c62": "{count, plural, one {{count} comment} other {{count} comments}}", - "79ae43d8b6d1cce4": "Edit comment", "1eadc7b869a55c68": "Load more comments", "3f9bc820dffd099f": "Reply", "7975bd47236d8207": "Reply to this conversation", @@ -7641,6 +7654,9 @@ "v": "v" } ], + "cca81c19189ddf54": "New citations go", + "771d5e7bf4487c68": "Inline (default)", + "f955b5bd7b177178": "In the tray", "d0e747ae0c4f68a5": "Could not install t3", "ba3ac338f36cba74": "Could not remove t3", "9c942b53b58119b8": "Could not add t3 to PATH", @@ -9744,6 +9760,7 @@ "c7b0bcb64f48db85": "Timestamp format", "21846d2fd70b4f80": "{modifierLabel} + Enter for multiline prompts", "761ac81a418bd87d": "{modifierLabel} + Enter always", + "2270c6ae8906c7fa": "Choose where newly cited assistant text is added on this client.", "3a6fb236cd3f521b": "Show formatted Markdown as you type.", "f9251f92691626cd": "Reset rich text composer to default", "b59ca5c465dbe742": "Choose when Enter sends a prompt or inserts a new line", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 68f63f589f51e..4b03507b24241 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "Ver el texto citado del asistente: {label}", "bc8c06fc6e15744d": "Editar comentario de la cita", "3461664615eadd38": "Añadir comentario a la cita", + "3d91ca20565a6da9": "Mover a la bandeja", "0fe5a2bc51368d37": "Comentar el texto seleccionado", "65f7fd6a7f3a586e": "Enter para guardar el comentario de la cita; Command/Ctrl+Enter para guardar y enviar; Shift+Enter para una línea nueva.", "e3903eb8bb6b0731": "Añade un comentario opcional...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Haz clic en la cita para volver a intentarlo.", "a1b2db80983184df": "El texto citado ha cambiado", "c6a4cb25e4dca706": "Se muestra la respuesta original. La cita guardada no cambia.", + "bd85eb1999402fef": "{count, plural, one {{count} anotación} other {{count} anotaciones}}", + "ecfffb229d32aa51": "Bandeja de citas", + "3a9c3017a3494d29": "{number}. Texto seleccionado:", + "21dd7ece52b5e85b": "Comentario del usuario: {comment}", + "f86d1b3defd75cea": "Ninguno", + "f6e34055516fc5dd": "Insertar en el texto", + "78defd0b8aed3e59": "Insertar la anotación {number} en el texto", + "7c9c33f828f5e5ac": "Editar la anotación {number}", + "79ae43d8b6d1cce4": "Editar comentario", + "2db4199182e9a7c3": "Eliminar la anotación {number}", + "d44cdf2b7aa3dec7": "Eliminar anotación", + "12fa84568a7dc61f": "Eliminar todas las anotaciones", "65d4ba7177bca2bf": "La selección es demasiado larga para citarla", "3390f0b2396998c0": "Citar la selección en el cuadro de mensaje", "e5dc8d61a6d178ed": "Acortar selección", @@ -4604,6 +4617,8 @@ "811b25d99525bcf7": "El agente de esta máquina no puede leer \"{title}\". Quítalo o vuelve a {owner} para enviar.", "55f9621a69825e20": "Mensaje en cola no actualizado", "1072fb0e2846f2a4": "Un mensaje en cola no puede pasar a un chat lateral. Quita /side o /btw para guardarlo.", + "9c9e764995cff9e2": "Este comando solo acepta texto", + "6f2e21443a2ba9f0": "Elimina las citas de la bandeja y vuelve a enviar el comando.", "170ab9bcffd26887": "Inicia primero un hilo de Codex", "c9852e2500018a3c": "Envía un mensaje antes de enviar comentarios.", "837c3082352db701": "Elige primero un proyecto", @@ -5166,7 +5181,6 @@ "1e3375e17e0b0704": "Requerida", "a7f7db481296601d": "Instaladas", "010a240f0d18e933": "No se han comprobado las versiones.", - "f86d1b3defd75cea": "Ninguno", "a1c433ed68afa03e": "Escala de grises", "29ae38749c912213": "Rojo / verde (protanopía)", "ab6d391ce2ab64c1": "Verde / rojo (deuteranopía)", @@ -6714,7 +6728,6 @@ "9e65f6bc12538296": "Resuelta", "d74fc95719fe5478": "Abierta", "4276743ee60a3c62": "{count, plural, one {{count} comentario} other {{count} comentarios}}", - "79ae43d8b6d1cce4": "Editar comentario", "1eadc7b869a55c68": "Cargar más comentarios", "3f9bc820dffd099f": "Responder", "7975bd47236d8207": "Responder a esta conversación", @@ -7633,6 +7646,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Destino de las nuevas citas", + "771d5e7bf4487c68": "En el texto (predeterminado)", + "f955b5bd7b177178": "En la bandeja", "d0e747ae0c4f68a5": "No se pudo instalar t3", "ba3ac338f36cba74": "No se pudo quitar t3", "9c942b53b58119b8": "No se pudo añadir t3 al PATH", @@ -9732,6 +9748,7 @@ "c7b0bcb64f48db85": "Formato de marca de tiempo", "21846d2fd70b4f80": "{modifierLabel} + Enter para prompts de varias líneas", "761ac81a418bd87d": "{modifierLabel} + Enter siempre", + "2270c6ae8906c7fa": "Elige dónde se añade el texto del asistente que cites a partir de ahora en este cliente.", "3a6fb236cd3f521b": "Muestra el Markdown con formato mientras escribes.", "f9251f92691626cd": "Restablecer el cuadro de mensaje con texto enriquecido al valor predeterminado", "b59ca5c465dbe742": "Elige cuándo Enter envía un prompt o inserta una línea nueva", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 442c22ed3a2d7..954c249254f82 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "Voir le texte cité de l’assistant : {label}", "bc8c06fc6e15744d": "Modifier le commentaire de la citation", "3461664615eadd38": "Ajouter un commentaire à la citation", + "3d91ca20565a6da9": "Déplacer vers le bac", "0fe5a2bc51368d37": "Commenter le texte sélectionné", "65f7fd6a7f3a586e": "Enter pour enregistrer le commentaire de la citation ; Command/Ctrl+Enter pour enregistrer et envoyer ; Shift+Enter pour une nouvelle ligne.", "e3903eb8bb6b0731": "Ajoutez un commentaire facultatif...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Cliquez sur la citation pour réessayer.", "a1b2db80983184df": "Le texte cité a changé", "c6a4cb25e4dca706": "Affichage de la réponse source. La citation enregistrée n’a pas changé.", + "bd85eb1999402fef": "{count, plural, one {{count} annotation} other {{count} annotations}}", + "ecfffb229d32aa51": "Bac à citations", + "3a9c3017a3494d29": "{number}. Texte sélectionné :", + "21dd7ece52b5e85b": "Commentaire de l’utilisateur : {comment}", + "f86d1b3defd75cea": "Aucun", + "f6e34055516fc5dd": "Insérer dans le texte", + "78defd0b8aed3e59": "Insérer l’annotation {number} dans le texte", + "7c9c33f828f5e5ac": "Modifier l’annotation {number}", + "79ae43d8b6d1cce4": "Modifier le commentaire", + "2db4199182e9a7c3": "Supprimer l’annotation {number}", + "d44cdf2b7aa3dec7": "Supprimer l’annotation", + "12fa84568a7dc61f": "Supprimer toutes les annotations", "65d4ba7177bca2bf": "Sélection trop longue pour être citée", "3390f0b2396998c0": "Citer la sélection dans la zone de saisie", "e5dc8d61a6d178ed": "Raccourcir la sélection", @@ -4605,6 +4618,8 @@ "811b25d99525bcf7": "L’agent de cette machine ne peut pas lire « {title} ». Retirez-le, ou revenez à {owner} pour envoyer.", "55f9621a69825e20": "Message en file d’attente non mis à jour", "1072fb0e2846f2a4": "Un message en file d’attente ne peut pas passer dans une discussion annexe. Retirez /side ou /btw pour l’enregistrer.", + "9c9e764995cff9e2": "Cette commande accepte uniquement du texte", + "6f2e21443a2ba9f0": "Retirez les citations du bac, puis renvoyez la commande.", "170ab9bcffd26887": "Démarrez d’abord un fil Codex", "c9852e2500018a3c": "Envoyez un message avant de soumettre des commentaires.", "837c3082352db701": "Choisissez d’abord un projet", @@ -5167,7 +5182,6 @@ "1e3375e17e0b0704": "Requise", "a7f7db481296601d": "Installées", "010a240f0d18e933": "Les versions n’ont pas été vérifiées.", - "f86d1b3defd75cea": "Aucun", "a1c433ed68afa03e": "Niveaux de gris", "29ae38749c912213": "Rouge / vert (protanopie)", "ab6d391ce2ab64c1": "Vert / rouge (deutéranopie)", @@ -6715,7 +6729,6 @@ "9e65f6bc12538296": "Résolue", "d74fc95719fe5478": "Ouverte", "4276743ee60a3c62": "{count, plural, one {{count} commentaire} other {{count} commentaires}}", - "79ae43d8b6d1cce4": "Modifier le commentaire", "1eadc7b869a55c68": "Charger plus de commentaires", "3f9bc820dffd099f": "Répondre", "7975bd47236d8207": "Répondre à cette conversation", @@ -7634,6 +7647,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Destination des nouvelles citations", + "771d5e7bf4487c68": "Dans le texte (par défaut)", + "f955b5bd7b177178": "Dans le bac", "d0e747ae0c4f68a5": "Impossible d’installer t3", "ba3ac338f36cba74": "Impossible de supprimer t3", "9c942b53b58119b8": "Impossible d’ajouter t3 au PATH", @@ -9734,6 +9750,7 @@ "c7b0bcb64f48db85": "Format de l’horodatage", "21846d2fd70b4f80": "{modifierLabel} + Enter pour les prompts multilignes", "761ac81a418bd87d": "{modifierLabel} + Enter toujours", + "2270c6ae8906c7fa": "Choisissez où le texte de l’assistant nouvellement cité est ajouté dans ce client.", "3a6fb236cd3f521b": "Affiche le Markdown mis en forme pendant la saisie.", "f9251f92691626cd": "Réinitialiser la zone de saisie en texte enrichi à la valeur par défaut", "b59ca5c465dbe742": "Choisissez quand Enter envoie un prompt ou insère une nouvelle ligne", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index c9417551b208c..d4361f5012302 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -3101,6 +3101,7 @@ "f8031a49c6e9fe25": "引用されたアシスタントのテキストを表示: {label}", "bc8c06fc6e15744d": "引用のコメントを編集", "3461664615eadd38": "引用にコメントを追加", + "3d91ca20565a6da9": "トレイに移動", "0fe5a2bc51368d37": "選択したテキストにコメント", "65f7fd6a7f3a586e": "Enter で引用のコメントを保存、Command/Ctrl+Enter で保存して送信、Shift+Enter で改行します。", "e3903eb8bb6b0731": "コメントを追加 (省略可)...", @@ -3120,6 +3121,18 @@ "2d52b83b33b6d842": "引用をクリックして再試行してください。", "a1b2db80983184df": "引用されたテキストが変更されています", "c6a4cb25e4dca706": "元の応答を表示しています。保存された引用は変更されていません。", + "bd85eb1999402fef": "{count, plural, one {{count}件の注釈} other {{count}件の注釈}}", + "ecfffb229d32aa51": "引用トレイ", + "3a9c3017a3494d29": "{number}. 選択したテキスト:", + "21dd7ece52b5e85b": "ユーザーのコメント: {comment}", + "f86d1b3defd75cea": "なし", + "f6e34055516fc5dd": "本文に挿入", + "78defd0b8aed3e59": "注釈{number}を本文に挿入", + "7c9c33f828f5e5ac": "注釈{number}を編集", + "79ae43d8b6d1cce4": "コメントを編集", + "2db4199182e9a7c3": "注釈{number}を削除", + "d44cdf2b7aa3dec7": "注釈を削除", + "12fa84568a7dc61f": "すべての注釈を削除", "65d4ba7177bca2bf": "選択範囲が長すぎて引用できません", "3390f0b2396998c0": "選択範囲を入力欄で引用", "e5dc8d61a6d178ed": "選択範囲を短くしてください", @@ -4594,6 +4607,8 @@ "811b25d99525bcf7": "このマシンのエージェントは \"{title}\" を読み取れません。削除するか、{owner} に戻してから送信してください。", "55f9621a69825e20": "キュー内のメッセージは更新されませんでした", "1072fb0e2846f2a4": "キュー内のメッセージはサイドチャットに移動できません。保存するには /side または /btw を削除してください。", + "9c9e764995cff9e2": "このコマンドはテキストのみ受け付けます", + "6f2e21443a2ba9f0": "トレイ内の引用を削除してから、コマンドを再送信してください。", "170ab9bcffd26887": "まず Codex のスレッドを開始してください", "c9852e2500018a3c": "フィードバックを送信する前にメッセージを送信してください。", "837c3082352db701": "まずプロジェクトを選択してください", @@ -5150,7 +5165,6 @@ "1e3375e17e0b0704": "必須", "a7f7db481296601d": "インストール済み", "010a240f0d18e933": "バージョンはまだ確認されていません。", - "f86d1b3defd75cea": "なし", "a1c433ed68afa03e": "グレースケール", "29ae38749c912213": "赤 / 緑 (1 型色覚)", "ab6d391ce2ab64c1": "緑 / 赤 (2 型色覚)", @@ -6683,7 +6697,6 @@ "9e65f6bc12538296": "解決済み", "d74fc95719fe5478": "未解決", "4276743ee60a3c62": "{count, plural, other {{count} 件のコメント}}", - "79ae43d8b6d1cce4": "コメントを編集", "1eadc7b869a55c68": "さらにコメントを読み込む", "3f9bc820dffd099f": "返信", "7975bd47236d8207": "この会話に返信", @@ -7598,6 +7611,9 @@ }, ")" ], + "cca81c19189ddf54": "新しい引用の追加先", + "771d5e7bf4487c68": "本文内(既定)", + "f955b5bd7b177178": "トレイ内", "d0e747ae0c4f68a5": "t3 をインストールできませんでした", "ba3ac338f36cba74": "t3 を削除できませんでした", "9c942b53b58119b8": "t3 を PATH に追加できませんでした", @@ -9686,6 +9702,7 @@ "c7b0bcb64f48db85": "タイムスタンプの形式", "21846d2fd70b4f80": "複数行のプロンプトでは {modifierLabel} + Enter", "761ac81a418bd87d": "常に {modifierLabel} + Enter", + "2270c6ae8906c7fa": "このクライアントで新しく引用したアシスタントのテキストを追加する場所を選択します。", "3a6fb236cd3f521b": "入力中に Markdown を整形して表示します。", "f9251f92691626cd": "リッチテキスト入力欄をデフォルトにリセット", "b59ca5c465dbe742": "Enter でプロンプトを送信するか改行するかを選択します", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index 362d29d071a87..bc259fdbee575 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -3102,6 +3102,7 @@ "f8031a49c6e9fe25": "인용된 어시스턴트 텍스트 보기: {label}", "bc8c06fc6e15744d": "인용 댓글 편집", "3461664615eadd38": "인용에 댓글 추가", + "3d91ca20565a6da9": "트레이로 이동", "0fe5a2bc51368d37": "선택한 텍스트에 댓글 달기", "65f7fd6a7f3a586e": "Enter로 인용 댓글 저장, Command/Ctrl+Enter로 저장 후 보내기, Shift+Enter로 줄 바꿈.", "e3903eb8bb6b0731": "선택 사항으로 댓글 추가...", @@ -3121,6 +3122,18 @@ "2d52b83b33b6d842": "인용을 클릭하여 다시 시도하세요.", "a1b2db80983184df": "인용된 텍스트가 변경되었습니다", "c6a4cb25e4dca706": "원본 응답을 표시합니다. 저장된 인용은 변경되지 않습니다.", + "bd85eb1999402fef": "{count, plural, one {주석 {count}개} other {주석 {count}개}}", + "ecfffb229d32aa51": "인용 트레이", + "3a9c3017a3494d29": "{number}. 선택한 텍스트:", + "21dd7ece52b5e85b": "사용자 댓글: {comment}", + "f86d1b3defd75cea": "없음", + "f6e34055516fc5dd": "본문에 삽입", + "78defd0b8aed3e59": "주석 {number} 본문에 삽입", + "7c9c33f828f5e5ac": "주석 {number} 편집", + "79ae43d8b6d1cce4": "댓글 편집", + "2db4199182e9a7c3": "주석 {number} 삭제", + "d44cdf2b7aa3dec7": "주석 삭제", + "12fa84568a7dc61f": "모든 주석 삭제", "65d4ba7177bca2bf": "선택 영역이 너무 길어 인용할 수 없습니다", "3390f0b2396998c0": "입력창에 선택 영역 인용", "e5dc8d61a6d178ed": "선택 영역 줄이기", @@ -4591,6 +4604,8 @@ "811b25d99525bcf7": "이 머신의 에이전트는 \"{title}\"을(를) 읽을 수 없습니다. 제거하거나 {owner}(으)로 다시 전환한 후 보내세요.", "55f9621a69825e20": "대기열 메시지가 업데이트되지 않음", "1072fb0e2846f2a4": "대기열 메시지는 사이드 채팅으로 옮길 수 없습니다. 저장하려면 /side 또는 /btw를 제거하세요.", + "9c9e764995cff9e2": "이 명령은 텍스트만 입력할 수 있습니다", + "6f2e21443a2ba9f0": "트레이의 인용을 삭제한 후 명령을 다시 보내세요.", "170ab9bcffd26887": "먼저 Codex 스레드를 시작하세요", "c9852e2500018a3c": "피드백을 제출하기 전에 메시지를 보내세요.", "837c3082352db701": "먼저 프로젝트를 선택하세요", @@ -5147,7 +5162,6 @@ "1e3375e17e0b0704": "필요", "a7f7db481296601d": "설치됨", "010a240f0d18e933": "버전을 아직 확인하지 않았습니다.", - "f86d1b3defd75cea": "없음", "a1c433ed68afa03e": "흑백", "29ae38749c912213": "적색/녹색(적색맹)", "ab6d391ce2ab64c1": "녹색/적색(녹색맹)", @@ -6687,7 +6701,6 @@ "9e65f6bc12538296": "해결됨", "d74fc95719fe5478": "열림", "4276743ee60a3c62": "{count, plural, other {댓글 {count}개}}", - "79ae43d8b6d1cce4": "댓글 편집", "1eadc7b869a55c68": "댓글 더 불러오기", "3f9bc820dffd099f": "답글", "7975bd47236d8207": "이 대화에 답글 달기", @@ -7600,6 +7613,9 @@ }, ")" ], + "cca81c19189ddf54": "새 인용 추가 위치", + "771d5e7bf4487c68": "본문 내 (기본값)", + "f955b5bd7b177178": "트레이 내", "d0e747ae0c4f68a5": "t3를 설치할 수 없습니다", "ba3ac338f36cba74": "t3를 제거할 수 없습니다", "9c942b53b58119b8": "t3를 PATH에 추가할 수 없습니다", @@ -9689,6 +9705,7 @@ "c7b0bcb64f48db85": "타임스탬프 형식", "21846d2fd70b4f80": "여러 줄 프롬프트는 {modifierLabel} + Enter", "761ac81a418bd87d": "항상 {modifierLabel} + Enter", + "2270c6ae8906c7fa": "이 클라이언트에서 새로 인용한 어시스턴트 텍스트가 추가될 위치를 선택하세요.", "3a6fb236cd3f521b": "입력하는 동안 서식이 적용된 Markdown을 표시합니다.", "f9251f92691626cd": "서식 있는 텍스트 입력창 기본값으로 재설정", "b59ca5c465dbe742": "Enter 키로 프롬프트를 보낼지 새 줄을 넣을지 선택합니다", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index b598943e92383..72d637e5bd78b 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "Ver o texto citado do assistente: {label}", "bc8c06fc6e15744d": "Editar comentário da citação", "3461664615eadd38": "Adicionar comentário à citação", + "3d91ca20565a6da9": "Mover para a bandeja", "0fe5a2bc51368d37": "Comentar o texto selecionado", "65f7fd6a7f3a586e": "Enter para salvar o comentário da citação; Command/Ctrl+Enter para salvar e enviar; Shift+Enter para nova linha.", "e3903eb8bb6b0731": "Adicione um comentário opcional...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Clique na citação para tentar novamente.", "a1b2db80983184df": "O texto citado mudou", "c6a4cb25e4dca706": "Mostrando a resposta de origem. A citação salva não mudou.", + "bd85eb1999402fef": "{count, plural, one {{count} anotação} other {{count} anotações}}", + "ecfffb229d32aa51": "Bandeja de citações", + "3a9c3017a3494d29": "{number}. Texto selecionado:", + "21dd7ece52b5e85b": "Comentário do usuário: {comment}", + "f86d1b3defd75cea": "Nenhum", + "f6e34055516fc5dd": "Inserir no texto", + "78defd0b8aed3e59": "Inserir a anotação {number} no texto", + "7c9c33f828f5e5ac": "Editar a anotação {number}", + "79ae43d8b6d1cce4": "Editar comentário", + "2db4199182e9a7c3": "Excluir a anotação {number}", + "d44cdf2b7aa3dec7": "Excluir anotação", + "12fa84568a7dc61f": "Limpar todas as anotações", "65d4ba7177bca2bf": "A seleção é longa demais para citar", "3390f0b2396998c0": "Citar a seleção no editor de mensagens", "e5dc8d61a6d178ed": "Encurtar seleção", @@ -4604,6 +4617,8 @@ "811b25d99525bcf7": "O agente desta máquina não consegue ler \"{title}\". Remova-a ou volte para {owner} para enviar.", "55f9621a69825e20": "Mensagem na fila não atualizada", "1072fb0e2846f2a4": "Uma mensagem na fila não pode ir para um chat paralelo. Remova /side ou /btw para salvá-la.", + "9c9e764995cff9e2": "Este comando aceita apenas texto", + "6f2e21443a2ba9f0": "Remova as citações da bandeja e envie o comando novamente.", "170ab9bcffd26887": "Inicie uma thread no Codex primeiro", "c9852e2500018a3c": "Envie uma mensagem antes de enviar feedback.", "837c3082352db701": "Escolha um projeto primeiro", @@ -5166,7 +5181,6 @@ "1e3375e17e0b0704": "Exigida", "a7f7db481296601d": "Instaladas", "010a240f0d18e933": "As versões não foram verificadas.", - "f86d1b3defd75cea": "Nenhum", "a1c433ed68afa03e": "Escala de cinza", "29ae38749c912213": "Vermelho / verde (protanopia)", "ab6d391ce2ab64c1": "Verde / vermelho (deuteranopia)", @@ -6714,7 +6728,6 @@ "9e65f6bc12538296": "Resolvida", "d74fc95719fe5478": "Aberta", "4276743ee60a3c62": "{count, plural, one {{count} comentário} other {{count} comentários}}", - "79ae43d8b6d1cce4": "Editar comentário", "1eadc7b869a55c68": "Carregar mais comentários", "3f9bc820dffd099f": "Resposta", "7975bd47236d8207": "Responder a esta discussão", @@ -7633,6 +7646,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Destino das novas citações", + "771d5e7bf4487c68": "No texto (padrão)", + "f955b5bd7b177178": "Na bandeja", "d0e747ae0c4f68a5": "Não foi possível instalar o t3", "ba3ac338f36cba74": "Não foi possível remover o t3", "9c942b53b58119b8": "Não foi possível adicionar o t3 ao PATH", @@ -9733,6 +9749,7 @@ "c7b0bcb64f48db85": "Formato de horário", "21846d2fd70b4f80": "{modifierLabel} + Enter para prompts de várias linhas", "761ac81a418bd87d": "{modifierLabel} + Enter sempre", + "2270c6ae8906c7fa": "Escolha onde o texto do assistente recém-citado será adicionado neste cliente.", "3a6fb236cd3f521b": "Mostra o Markdown formatado enquanto você digita.", "f9251f92691626cd": "Redefinir o editor de mensagens com rich text para o padrão", "b59ca5c465dbe742": "Escolha quando Enter envia um prompt ou insere uma nova linha", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index a8a54a6500e59..0db177dd20b2d 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "Посмотреть цитируемый текст ассистента: {label}", "bc8c06fc6e15744d": "Изменить комментарий к цитате", "3461664615eadd38": "Добавить комментарий к цитате", + "3d91ca20565a6da9": "Переместить в лоток", "0fe5a2bc51368d37": "Комментировать выделенный текст", "65f7fd6a7f3a586e": "Enter — сохранить комментарий; Command/Ctrl+Enter — сохранить и отправить; Shift+Enter — новая строка.", "e3903eb8bb6b0731": "Добавьте комментарий (необязательно)...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Нажмите на цитату, чтобы повторить.", "a1b2db80983184df": "Цитируемый текст изменился", "c6a4cb25e4dca706": "Показан исходный ответ. Сохранённая цитата не изменилась.", + "bd85eb1999402fef": "{count, plural, one {{count} примечание} few {{count} примечания} many {{count} примечаний} other {{count} примечания}}", + "ecfffb229d32aa51": "Лоток цитат", + "3a9c3017a3494d29": "{number}. Выделенный текст:", + "21dd7ece52b5e85b": "Комментарий пользователя: {comment}", + "f86d1b3defd75cea": "Нет", + "f6e34055516fc5dd": "Вставить в текст", + "78defd0b8aed3e59": "Вставить примечание {number} в текст", + "7c9c33f828f5e5ac": "Изменить примечание {number}", + "79ae43d8b6d1cce4": "Изменить комментарий", + "2db4199182e9a7c3": "Удалить примечание {number}", + "d44cdf2b7aa3dec7": "Удалить примечание", + "12fa84568a7dc61f": "Удалить все примечания", "65d4ba7177bca2bf": "Выделение слишком длинное для цитаты", "3390f0b2396998c0": "Процитировать выделенное в поле ввода", "e5dc8d61a6d178ed": "Сократите выделение", @@ -4604,6 +4617,8 @@ "811b25d99525bcf7": "Агент этой машины не может прочитать «{title}». Удалите его или переключитесь обратно на {owner}, чтобы отправить.", "55f9621a69825e20": "Сообщение в очереди не обновлено", "1072fb0e2846f2a4": "Сообщение в очереди нельзя перенести в боковой чат. Удалите /side или /btw, чтобы сохранить его.", + "9c9e764995cff9e2": "Эта команда принимает только текст", + "6f2e21443a2ba9f0": "Удалите цитаты из лотка и отправьте команду ещё раз.", "170ab9bcffd26887": "Сначала начните тред Codex", "c9852e2500018a3c": "Отправьте сообщение, прежде чем оставлять отзыв.", "837c3082352db701": "Сначала выберите проект", @@ -5166,7 +5181,6 @@ "1e3375e17e0b0704": "Требуется", "a7f7db481296601d": "Установлены", "010a240f0d18e933": "Версии не проверены.", - "f86d1b3defd75cea": "Нет", "a1c433ed68afa03e": "Оттенки серого", "29ae38749c912213": "Красный / зелёный (протанопия)", "ab6d391ce2ab64c1": "Зелёный / красный (дейтеранопия)", @@ -6714,7 +6728,6 @@ "9e65f6bc12538296": "Решено", "d74fc95719fe5478": "Открыто", "4276743ee60a3c62": "{count, plural, one {{count} комментарий} few {{count} комментария} many {{count} комментариев} other {{count} комментария}}", - "79ae43d8b6d1cce4": "Изменить комментарий", "1eadc7b869a55c68": "Загрузить ещё комментарии", "3f9bc820dffd099f": "Ответ", "7975bd47236d8207": "Ответить в этом обсуждении", @@ -7633,6 +7646,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Куда добавлять новые цитаты", + "771d5e7bf4487c68": "В тексте (по умолчанию)", + "f955b5bd7b177178": "В лотке", "d0e747ae0c4f68a5": "Не удалось установить t3", "ba3ac338f36cba74": "Не удалось удалить t3", "9c942b53b58119b8": "Не удалось добавить t3 в PATH", @@ -9736,6 +9752,7 @@ "c7b0bcb64f48db85": "Формат времени", "21846d2fd70b4f80": "{modifierLabel} + Enter для многострочных промптов", "761ac81a418bd87d": "Всегда {modifierLabel} + Enter", + "2270c6ae8906c7fa": "Выберите, куда в этом клиенте добавляется текст ассистента при создании новых цитат.", "3a6fb236cd3f521b": "Показывать форматированный Markdown при вводе.", "f9251f92691626cd": "Сбросить поле ввода с форматированием к значению по умолчанию", "b59ca5c465dbe742": "Когда Enter отправляет промпт, а когда вставляет новую строку", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index adaf8566b6411..51627d9ba61a0 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -3103,6 +3103,7 @@ "f8031a49c6e9fe25": "Visa citerad assistenttext: {label}", "bc8c06fc6e15744d": "Redigera citatkommentar", "3461664615eadd38": "Lägg till kommentar till citatet", + "3d91ca20565a6da9": "Flytta till facket", "0fe5a2bc51368d37": "Kommentera markerad text", "65f7fd6a7f3a586e": "Enter för att spara citatkommentaren; Command/Ctrl+Enter för att spara och skicka; Shift+Enter för ny rad.", "e3903eb8bb6b0731": "Lägg till en valfri kommentar...", @@ -3122,6 +3123,18 @@ "2d52b83b33b6d842": "Klicka på citatet för att försöka igen.", "a1b2db80983184df": "Den citerade texten har ändrats", "c6a4cb25e4dca706": "Visar källsvaret. Det sparade citatet är oförändrat.", + "bd85eb1999402fef": "{count, plural, one {{count} anteckning} other {{count} anteckningar}}", + "ecfffb229d32aa51": "Citatfack", + "3a9c3017a3494d29": "{number}. Markerad text:", + "21dd7ece52b5e85b": "Användarkommentar: {comment}", + "f86d1b3defd75cea": "Ingen", + "f6e34055516fc5dd": "Infoga i texten", + "78defd0b8aed3e59": "Infoga anteckning {number} i texten", + "7c9c33f828f5e5ac": "Redigera anteckning {number}", + "79ae43d8b6d1cce4": "Redigera kommentar", + "2db4199182e9a7c3": "Ta bort anteckning {number}", + "d44cdf2b7aa3dec7": "Ta bort anteckning", + "12fa84568a7dc61f": "Ta bort alla anteckningar", "65d4ba7177bca2bf": "Markeringen är för lång för att citeras", "3390f0b2396998c0": "Citera markeringen i inmatningsfältet", "e5dc8d61a6d178ed": "Korta ned markeringen", @@ -4605,6 +4618,8 @@ "811b25d99525bcf7": "Den här datorns agent kan inte läsa ”{title}”. Ta bort den eller byt tillbaka till {owner} för att skicka.", "55f9621a69825e20": "Det köade meddelandet uppdaterades inte", "1072fb0e2846f2a4": "Ett köat meddelande kan inte flyttas till en sidochatt. Ta bort /side eller /btw för att spara det.", + "9c9e764995cff9e2": "Det här kommandot tar bara emot text", + "6f2e21443a2ba9f0": "Ta bort citaten från facket och skicka sedan kommandot igen.", "170ab9bcffd26887": "Starta en Codex-tråd först", "c9852e2500018a3c": "Skicka ett meddelande innan du skickar feedback.", "837c3082352db701": "Välj ett projekt först", @@ -5167,7 +5182,6 @@ "1e3375e17e0b0704": "Krävs", "a7f7db481296601d": "Installerade", "010a240f0d18e933": "Versionerna har inte kontrollerats.", - "f86d1b3defd75cea": "Ingen", "a1c433ed68afa03e": "Gråskala", "29ae38749c912213": "Röd/grön (protanopi)", "ab6d391ce2ab64c1": "Grön/röd (deuteranopi)", @@ -6720,7 +6734,6 @@ "9e65f6bc12538296": "Löst", "d74fc95719fe5478": "Öppen", "4276743ee60a3c62": "{count, plural, one {{count} kommentar} other {{count} kommentarer}}", - "79ae43d8b6d1cce4": "Redigera kommentar", "1eadc7b869a55c68": "Läs in fler kommentarer", "3f9bc820dffd099f": "Svar", "7975bd47236d8207": "Svara i den här konversationen", @@ -7639,6 +7652,9 @@ "v": "v" } ], + "cca81c19189ddf54": "Nya citat läggs till", + "771d5e7bf4487c68": "I texten (standard)", + "f955b5bd7b177178": "I facket", "d0e747ae0c4f68a5": "Kunde inte installera t3", "ba3ac338f36cba74": "Kunde inte ta bort t3", "9c942b53b58119b8": "Kunde inte lägga till t3 i PATH", @@ -9742,6 +9758,7 @@ "c7b0bcb64f48db85": "Format för tidsstämplar", "21846d2fd70b4f80": "{modifierLabel} + Enter för promptar på flera rader", "761ac81a418bd87d": "Alltid {modifierLabel} + Enter", + "2270c6ae8906c7fa": "Välj var nyligen citerad assistenttext läggs till i den här klienten.", "3a6fb236cd3f521b": "Visa formaterad Markdown medan du skriver.", "f9251f92691626cd": "Återställ inmatningsfält med formaterad text till standard", "b59ca5c465dbe742": "Välj när Enter skickar en prompt eller infogar en ny rad", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index f386e717a0614..109590f4f3460 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -3107,6 +3107,7 @@ "f8031a49c6e9fe25": "查看引用的助手回复:{label}", "bc8c06fc6e15744d": "编辑引用批注", "3461664615eadd38": "为引用添加批注", + "3d91ca20565a6da9": "移到托盘", "0fe5a2bc51368d37": "为选中的文字添加批注", "65f7fd6a7f3a586e": "按 Enter 保存批注;按 Command/Ctrl+Enter 保存并发送;按 Shift+Enter 换行。", "e3903eb8bb6b0731": "添加批注(可选)…", @@ -3126,6 +3127,18 @@ "2d52b83b33b6d842": "请再次点击引用重试。", "a1b2db80983184df": "引用的原文已变化", "c6a4cb25e4dca706": "正在显示原回复,已保存的引用内容不变。", + "bd85eb1999402fef": "{count, plural, one {{count} 条批注} other {{count} 条批注}}", + "ecfffb229d32aa51": "引用托盘", + "3a9c3017a3494d29": "{number}. 选中的文字:", + "21dd7ece52b5e85b": "用户批注:{comment}", + "f86d1b3defd75cea": "无", + "f6e34055516fc5dd": "内联插入", + "78defd0b8aed3e59": "内联插入批注 {number}", + "7c9c33f828f5e5ac": "编辑批注 {number}", + "79ae43d8b6d1cce4": "编辑评论", + "2db4199182e9a7c3": "删除批注 {number}", + "d44cdf2b7aa3dec7": "删除批注", + "12fa84568a7dc61f": "清空所有批注", "65d4ba7177bca2bf": "选中的内容太长,无法引用", "3390f0b2396998c0": "在输入框中引用选中内容", "e5dc8d61a6d178ed": "请缩短选中内容", @@ -4611,6 +4624,8 @@ "811b25d99525bcf7": "此机器的智能体无法读取“{title}”。请将其移除,或切换回 {owner} 再发送。", "55f9621a69825e20": "排队消息未更新", "1072fb0e2846f2a4": "排队消息无法移到侧聊。请移除 /side 或 /btw 后保存。", + "9c9e764995cff9e2": "此命令仅接受文本", + "6f2e21443a2ba9f0": "请移除托盘中的引用,然后重新发送命令。", "170ab9bcffd26887": "请先开始一个 Codex 会话", "c9852e2500018a3c": "提交反馈前请先发送一条消息。", "837c3082352db701": "请先选择项目", @@ -5173,7 +5188,6 @@ "1e3375e17e0b0704": "所需版本", "a7f7db481296601d": "已安装", "010a240f0d18e933": "尚未检查版本。", - "f86d1b3defd75cea": "无", "a1c433ed68afa03e": "灰度", "29ae38749c912213": "红 / 绿(红色盲)", "ab6d391ce2ab64c1": "绿 / 红(绿色盲)", @@ -6728,7 +6742,6 @@ "9e65f6bc12538296": "已解决", "d74fc95719fe5478": "未解决", "4276743ee60a3c62": "{count, plural, other {{count} 条评论}}", - "79ae43d8b6d1cce4": "编辑评论", "1eadc7b869a55c68": "加载更多评论", "3f9bc820dffd099f": "回复", "7975bd47236d8207": "回复此对话", @@ -7651,6 +7664,9 @@ "v": "v" } ], + "cca81c19189ddf54": "新引用的添加位置", + "771d5e7bf4487c68": "内联(默认)", + "f955b5bd7b177178": "托盘中", "d0e747ae0c4f68a5": "无法安装 t3", "ba3ac338f36cba74": "无法移除 t3", "9c942b53b58119b8": "无法将 t3 添加到 PATH", @@ -9749,6 +9765,7 @@ "c7b0bcb64f48db85": "时间格式", "21846d2fd70b4f80": "{modifierLabel} + Enter 发送多行提示词", "761ac81a418bd87d": "始终 {modifierLabel} + Enter", + "2270c6ae8906c7fa": "选择在此客户端中新引用的助手回复文字的添加位置。", "3a6fb236cd3f521b": "输入时显示 Markdown 格式效果。", "f9251f92691626cd": "重置富文本输入框为默认值", "b59ca5c465dbe742": "选择 Enter 是发送提示词还是插入换行", diff --git a/apps/web/src/promptStashStore.test.ts b/apps/web/src/promptStashStore.test.ts index 1e40dfc884bfd..6902897c75e09 100644 --- a/apps/web/src/promptStashStore.test.ts +++ b/apps/web/src/promptStashStore.test.ts @@ -104,11 +104,19 @@ describe("promptStashStore", () => { writePromptStashStorageForTest( JSON.stringify({ version: 2, - state: { entries: [makeEntry({ id: "citation-stash", prompt })] }, + state: { + entries: [ + { + ...makeEntry({ id: "citation-stash", prompt }), + trayCitations: [citation, { version: 999 }], + }, + ], + }, }), ); const restored = usePromptStashStore.getState().takeEntry("citation-stash").entry; expect(restored?.prompt).toBe(prompt); + expect(restored?.trayCitations).toEqual([citation]); expect( collectAssistantCitations(restored?.prompt ?? "").map((entry) => entry.citation), ).toEqual([citation]); diff --git a/apps/web/src/promptStashStore.ts b/apps/web/src/promptStashStore.ts index 0afb52eb01838..393c6dce42370 100644 --- a/apps/web/src/promptStashStore.ts +++ b/apps/web/src/promptStashStore.ts @@ -1,4 +1,8 @@ -import { ComposerContextRecord, ForwardCompatibleArray } from "@t3tools/contracts"; +import { + AssistantCitation, + ComposerContextRecord, + ForwardCompatibleArray, +} from "@t3tools/contracts"; import * as Schema from "effect/Schema"; import { create } from "zustand"; @@ -20,6 +24,7 @@ const StashEntrySchema = Schema.Struct({ id: Schema.String, createdAt: Schema.String, prompt: Schema.String, + trayCitations: Schema.optionalKey(ForwardCompatibleArray(AssistantCitation)), attachments: Schema.Array(PersistedComposerImageAttachment), files: Schema.optionalKey(Schema.Array(PersistedComposerFileAttachment)), droppedImageNames: Schema.Array(Schema.String), diff --git a/docs/user/composer.md b/docs/user/composer.md index 89a96f120d4d0..c0920234ee69b 100644 --- a/docs/user/composer.md +++ b/docs/user/composer.md @@ -142,6 +142,10 @@ delete it like other inline context. Copying, reloading, and restoring a with its quote, and sending tells the agent which words were quoted and which comment you wrote. The quoted text and comment count toward the message limit. +On web and desktop, set **New citations go** to **In the tray** in **Settings → Chat** +to collect quotes above the input. The default is **Inline**. Tray quotes are sent +before your message in their listed order and stay with saved drafts and stashed prompts. + Mobile displays saved quotes and comments, but does not create citations or navigate to their sources.