A desktop coding agent with free access to frontier models.
TypeScript
fix: quote chips show plain words and keep Expand on one line
ogsamratd2c730b7ca3c
diff --git a/apps/app/src/components/chat/quote.ts b/apps/app/src/components/chat/quote.tsindex b549de4b..4187fda9 100644--- a/apps/app/src/components/chat/quote.ts+++ b/apps/app/src/components/chat/quote.ts@@ -29,9 +29,17 @@ export function clipGraphemes(text: string, max: number): string {return graphemes.length > max ? `${graphemes.slice(0, max).join("").trimEnd()}…` : text}-/** The chip label: `Quote: first words…` (sendToChat makes it unique among the draft's chips). */+/** Markdown marks left out of a label (headings, emphasis, code ticks, quote markers, list bullets, link brackets). */+function plainWords(text: string): string {+ return text+ .replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+|\d+[.)]\s+)/gm, "")+ .replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1")+ .replace(/(\*\*|__|\*|_|~~|`+)/g, "")+}++/** The chip label: `Quote: first words…` as plain words (sendToChat makes it unique among the draft's chips). */export function quoteLabel(text: string): string {- const flat = text.replace(/\s+/g, " ").trim()+ const flat = plainWords(text).replace(/\s+/g, " ").trim()return `Quote: ${clipGraphemes(flat, LABEL_WORDS)}`}diff --git a/apps/app/src/react-app/domains/session/surface/composer/editor.tsx b/apps/app/src/react-app/domains/session/surface/composer/editor.tsxindex 71bbacd9..54262b60 100644--- a/apps/app/src/react-app/domains/session/surface/composer/editor.tsx+++ b/apps/app/src/react-app/domains/session/surface/composer/editor.tsx@@ -338,17 +338,19 @@ function pastedTextChipLabel(label: string, lines: number) {function createPastedTextChipDom(label: string, lines: number) {const dom = document.createElement("span");- dom.className = "inline-flex items-center gap-1 rounded-full border border-amber-6/35 bg-amber-3/15 px-2.5 py-1 text-xs font-medium text-warning";+ dom.className = "inline-flex max-w-full items-center gap-1 rounded-full border border-amber-6/35 bg-amber-3/15 px-2.5 py-1 text-xs font-medium text-warning";dom.contentEditable = "false";dom.setAttribute("spellcheck", "false");dom.title = `Pasted text · ${label}`;const text = document.createElement("span");+ // A long label shortens; the Expand link keeps its one line.+ text.className = "min-w-0 truncate";text.textContent = pastedTextChipLabel(label, lines);const button = document.createElement("button");button.type = "button";- button.className = "ml-1 inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[11px] font-medium text-warning underline decoration-amber-8 underline-offset-2 transition-colors hover:bg-amber-4 hover:text-amber-12";+ button.className = "ml-1 inline-flex shrink-0 whitespace-nowrap items-center gap-0.5 rounded px-1 py-0.5 text-[11px] font-medium text-warning underline decoration-amber-8 underline-offset-2 transition-colors hover:bg-amber-4 hover:text-amber-12";button.title = "Expand";button.setAttribute("aria-label", "Expand pasted text in composer");button.dataset.pastedExpandLabel = label;diff --git a/apps/app/tests/chat-quote.test.ts b/apps/app/tests/chat-quote.test.tsindex 24147f45..f5a7cb27 100644--- a/apps/app/tests/chat-quote.test.ts+++ b/apps/app/tests/chat-quote.test.ts@@ -15,5 +15,7 @@ describe("quote / reply", () => {test("the label is short and on one line", () => {expect(quoteLabel("short\ntext")).toBe("Quote: short text");expect(quoteLabel("x".repeat(100))).toBe(`Quote: ${"x".repeat(48)}…`);+ expect(quoteLabel("## Project overview\nThe project has **one** entry point, `src/main.js`.")).toBe(`Quote: ${"Project overview The project has one entry point, src/main.js.".slice(0, 48).trimEnd()}…`);+ expect(quoteLabel("> quoted\n- item [link](http://x)")).toBe("Quote: quoted item link");});});