Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(app): cut a conversation title without leaving half a character (#740)
ANIRUDDHA ADAK34a29bf11c6e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f6e928bc..da1fd3d1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,10 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.## Unreleased+- A conversation title cut at 60 characters no longer ends in half an emoji. `slice` counts UTF-16+ code units and an emoji is two of them, so a title cut between the halves rendered a replacement+ character in the sidebar and the picker, where the character itself should have been.+- A tool result that arrives before the call it answers is now paired with that call by the LangGraphBot, as the sibling Bots already did. Read back from the durable thread store the result arrivesfirst, which is a payload no provider accepts: a tool message with no preceding call, then a calldiff --git a/app/src/lib/channels/label.ts b/app/src/lib/channels/label.tsindex b5f731a1..fd0fa855 100644--- a/app/src/lib/channels/label.ts+++ b/app/src/lib/channels/label.ts@@ -1,9 +1,15 @@+import { openingOf } from "@/lib/voice/cut";+/*** How a conversation is named in a picker: its Bot and, once it has one, its title.** The name alone is the Bot's for every one-Bot conversation, so a list of "General Assistant"* twelve times gave no way to choose. The title is what the sidebar shows: the summary once the* conversation has been named, its last message until then.+ *+ * The cut drops a trailing half character rather than keeping it, because `slice` counts UTF-16 code+ * units and an emoji is two of them: a title cut between the halves renders a replacement character+ * where the character should be.*/export function conversationLabel(channel: {name: string;@@ -11,5 +17,5 @@ export function conversationLabel(channel: {lastMessage?: string | null;}): string {const title = (channel.summary || channel.lastMessage || "").trim();- return title ? `${channel.name}: ${title.slice(0, 60)}` : channel.name;+ return title ? `${channel.name}: ${openingOf(title, 60)}` : channel.name;}diff --git a/app/tests/channel-label.test.ts b/app/tests/channel-label.test.tsnew file mode 100644index 00000000..f3c505c3--- /dev/null+++ b/app/tests/channel-label.test.ts@@ -0,0 +1,46 @@+import { describe, expect, test } from "bun:test";+import { conversationLabel } from "../src/lib/channels/label";++/**+ * A lone surrogate is half of an astral character, which is what a caption, a sidebar and a font all+ * draw as a replacement character.+ */+function hasLoneSurrogate(text: string): boolean {+ return /[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(text);+}++describe("a conversation label", () => {+ test("keeps a short title whole", () => {+ expect(+ conversationLabel({ name: "General", summary: "What is in the PRD?" }),+ ).toBe("General: What is in the PRD?");+ });++ test("cuts a long title to the limit", () => {+ expect(+ conversationLabel({ name: "General", summary: "a".repeat(80) }),+ ).toBe(`General: ${"a".repeat(60)}`);+ });++ test("does not leave half a character when the cut lands on one", () => {+ /*+ * 59 ASCII characters and then an emoji: the emoji is two code units, so the 60th is its high+ * surrogate and the cut lands between the halves. The label is what the sidebar and the picker+ * draw, so it showed a replacement character where the emoji should have been.+ */+ const label = conversationLabel({+ name: "General",+ summary: `${"a".repeat(59)}\u{1F600}tail`,+ });++ expect(hasLoneSurrogate(label)).toBe(false);+ expect(label).toBe(`General: ${"a".repeat(59)}`);+ });++ test("falls back to the name when there is no title", () => {+ expect(conversationLabel({ name: "General" })).toBe("General");+ expect(conversationLabel({ name: "General", summary: " " })).toBe(+ "General",+ );+ });+});