Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

feat(web): fold long Task briefs and show replies as prose

LeoXing4ad38f362f99
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.test.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.test.tsx
index 0f9c0424..224f5173 100644
--- a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.test.tsx
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.test.tsx
@@ -64,6 +64,10 @@ describe("RuntimeTrajectoryView", () => {
"town-shimmer-text",
);
expect(screen.getByText("green").tagName).toBe("STRONG");
+ // The reply reads as the turn's prose, not a chat bubble among its steps.
+ expect(
+ screen.getByText("green").closest(".room-message-bubble"),
+ ).toBeNull();
fireEvent.click(ran);
expect(ran.closest("details")).not.toHaveAttribute("open");
});
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.tsx
index 3689ef1a..e6c220b4 100644
--- a/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.tsx
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/runtime-trajectory-view.tsx
@@ -77,9 +77,7 @@ export function RuntimeTrajectoryView({
</li>
) : item.kind === "reply" ? (
<li className="py-2" key={item.key}>
- <div className="room-message-bubble text-[15px] leading-[22px] text-app-ink">
- <MessageMarkdown authorKind="agent" body={item.text} />
- </div>
+ <MessageMarkdown authorKind="agent" body={item.text} />
</li>
) : (
<TrajectoryCallRow call={item.call} key={item.key} />
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx
index 398dd3a0..72110b1f 100644
--- a/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-conversation-dialog.tsx
@@ -12,7 +12,6 @@ import { useTeamHubRuntime } from "@/features/teamhub/teamhub-runtime";
import type { TeamHubRunStatus } from "@/features/teamhub/teamhub-types";
import { CancelTaskButton } from "../../chat/cancel-task-button";
-import { MessageMarkdown } from "../../chat/message-markdown";
import { useCancelRoomBackgroundTask } from "../../chat/use-room-background-tasks";
import { createRoomCardDecisionController } from "../../cards/room-card-decision-controller";
import {
@@ -30,6 +29,7 @@ import { useTaskActivityEvents } from "../../runtime-status/use-task-activity-ev
import { PanelLoading } from "../panel-loading";
import { RunningDots } from "../running-dots";
import { RuntimeTrajectoryView } from "./runtime-trajectory-view";
+import { TaskInputBubble } from "./task-input-bubble";
/** Lets the task blocks in an activity log open their Task's conversation. */
export function TaskConversationProvider({
@@ -171,18 +171,11 @@ export function TaskConversationDialog({
{entry.input.body}
</p>
) : (
- <div
- className="room-message-card pl-12"
- data-current-actor="true"
+ <TaskInputBubble
+ authorKind={entry.input.author.kind}
+ body={entry.input.body}
key={entry.key}
- >
- <div className="room-message-bubble max-w-[85%]">
- <MessageMarkdown
- authorKind={entry.input.author.kind}
- body={entry.input.body}
- />
- </div>
- </div>
+ />
)
) : entry.kind === "run" ? (
<TaskConversationRun
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.test.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.test.tsx
new file mode 100644
index 00000000..675c58dc
--- /dev/null
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.test.tsx
@@ -0,0 +1,69 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { TaskInputBubble } from "./task-input-bubble";
+
+const heights = Object.getOwnPropertyDescriptor(
+ HTMLElement.prototype,
+ "scrollHeight",
+);
+
+afterEach(() => {
+ if (heights)
+ Object.defineProperty(HTMLElement.prototype, "scrollHeight", heights);
+ else Reflect.deleteProperty(HTMLElement.prototype, "scrollHeight");
+});
+
+function contentOverflows() {
+ Object.defineProperty(HTMLElement.prototype, "scrollHeight", {
+ configurable: true,
+ get: () => 400,
+ });
+}
+
+describe("TaskInputBubble", () => {
+ it("shows a short input whole, without a fold", () => {
+ render(<TaskInputBubble authorKind="agent" body="Add a closing letter." />);
+
+ expect(screen.getByText("Add a closing letter.")).toBeVisible();
+ expect(screen.queryByRole("button")).not.toBeInTheDocument();
+ });
+
+ it("folds a long input to its first lines and opens it in place", () => {
+ contentOverflows();
+ render(
+ <TaskInputBubble
+ authorKind="agent"
+ body={"Write the report.\n\n1. Opening\n2. Events\n3. Finances"}
+ />,
+ );
+ const content = screen
+ .getByText("Write the report.")
+ .closest(".message-markdown")!.parentElement!;
+
+ const more = screen.getByRole("button", { name: "Show more" });
+ expect(more).toHaveAttribute("aria-expanded", "false");
+ expect(content).toHaveClass("max-h-[110px]", "overflow-hidden");
+
+ fireEvent.click(more);
+
+ const less = screen.getByRole("button", { name: "Show less" });
+ expect(less).toHaveAttribute("aria-expanded", "true");
+ expect(content).not.toHaveClass("max-h-[110px]");
+
+ fireEvent.click(less);
+
+ expect(screen.getByRole("button", { name: "Show more" })).toBeVisible();
+ expect(content).toHaveClass("max-h-[110px]");
+ });
+
+ it("caps the width on a wrapper, since the bubble's own max-width outranks utilities", () => {
+ render(<TaskInputBubble authorKind="human" body="Hi" />);
+ const bubble = screen
+ .getByText("Hi")
+ .closest(".room-message-bubble") as HTMLElement;
+
+ expect(bubble.className).not.toContain("max-w-");
+ expect(bubble.parentElement).toHaveClass("max-w-[85%]");
+ });
+});
diff --git a/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.tsx b/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.tsx
new file mode 100644
index 00000000..05cec041
--- /dev/null
+++ b/apps/web/src/features/rooms/task-sidebar/adapters/task-input-bubble.tsx
@@ -0,0 +1,71 @@
+import { ArrowDown01Icon } from "@hugeicons/core-free-icons";
+import { useLayoutEffect, useRef, useState } from "react";
+
+import { Icon } from "@/components/ui/icon";
+import { cn } from "@/lib/cn";
+
+import { MessageMarkdown } from "../../chat/message-markdown";
+
+/**
+ * A brief or follow-up sent to a Task, on the right like a Room message. A
+ * long one folds to its first few lines so the AlterEgo's work stays in view.
+ */
+export function TaskInputBubble({
+ authorKind,
+ body,
+}: {
+ authorKind: "agent" | "human";
+ body: string;
+}) {
+ const content = useRef<HTMLDivElement>(null);
+ const [expanded, setExpanded] = useState(false);
+ const [clipped, setClipped] = useState(false);
+ useLayoutEffect(() => {
+ const node = content.current;
+ if (!node || expanded) return;
+ const measure = () => setClipped(node.scrollHeight > node.clientHeight + 1);
+ measure();
+ if (typeof ResizeObserver === "undefined") return;
+ const observer = new ResizeObserver(measure);
+ observer.observe(node);
+ return () => observer.disconnect();
+ }, [body, expanded]);
+ return (
+ <div className="flex justify-end">
+ {/* The bubble's own max-width outranks a width utility on it. */}
+ <div className="min-w-0 max-w-[85%]">
+ <div className="room-message-bubble">
+ <div
+ className={cn(
+ !expanded && "max-h-[110px] overflow-hidden",
+ !expanded &&
+ clipped &&
+ "[mask-image:linear-gradient(to_bottom,black_calc(100%-28px),transparent)]",
+ )}
+ ref={content}
+ >
+ <MessageMarkdown authorKind={authorKind} body={body} />
+ </div>
+ {clipped || expanded ? (
+ <button
+ aria-expanded={expanded}
+ className="-mx-1 mt-1 inline-flex items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground transition-colors duration-150 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ onClick={() => setExpanded((value) => !value)}
+ type="button"
+ >
+ {expanded ? "Show less" : "Show more"}
+ <Icon
+ className={cn(
+ "transition-transform duration-150",
+ expanded && "rotate-180",
+ )}
+ icon={ArrowDown01Icon}
+ size={14}
+ />
+ </button>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ );
+}