Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-6004 fix(issues): bound inline chips so long titles stop breaking prose (#6744)

Bohan Jiang59021eb8a674
diff --git a/packages/views/issues/components/issue-chip.test.tsx b/packages/views/issues/components/issue-chip.test.tsx
index 2176f3a611..25fb25bee9 100644
--- a/packages/views/issues/components/issue-chip.test.tsx
+++ b/packages/views/issues/components/issue-chip.test.tsx
@@ -45,11 +45,15 @@ describe("IssueChip", () => {
});
});
- it("caps the chip to its parent container and truncates the title", () => {
+ it("caps the chip against both its content and its container, and truncates the title", () => {
render(<IssueChip issueId="issue-1" />);
const chip = screen.getByText("MUL-3405").closest(".issue-mention");
- expect(chip).toHaveClass("min-w-0", "max-w-full");
+ // 18rem bounds the chip against a long title so it cannot dominate a line
+ // of prose (#6732); 100% keeps it inside a narrow parent such as a chat
+ // bubble. ProjectChip carries the identical cap — see its own test.
+ expect(chip).toHaveClass("min-w-0");
+ expect(chip).toHaveClass("max-w-[min(18rem,100%)]");
expect(screen.getByText("A very long issue title that should stay inside a narrow chat bubble"))
.toHaveClass("min-w-0", "truncate");
});
diff --git a/packages/views/issues/components/issue-chip.tsx b/packages/views/issues/components/issue-chip.tsx
index c0a2ed54dc..5907581514 100644
--- a/packages/views/issues/components/issue-chip.tsx
+++ b/packages/views/issues/components/issue-chip.tsx
@@ -7,13 +7,23 @@ import { StatusIcon } from "./status-icon";
/**
* Compact, presentation-only representation of an issue —
- * `<StatusIcon> <identifier> <title>`, bordered, capped at the container width
- * (`max-w-full`) with the title truncating to an ellipsis. As an atomic inline
- * box it wraps to the next line as a unit when it doesn't fit at the current
- * position; the ellipsis only kicks in once a whole line can't hold it. The cap
- * lives here (single source of truth) — wrappers must NOT add their own flex
- * container around it, or a percentage cap gets dropped during the wrapper's
- * intrinsic sizing and the clickable box diverges from the truncated chip.
+ * `<StatusIcon> <identifier> <title>`, bordered, with the title truncating to
+ * an ellipsis once the chip hits its width cap.
+ *
+ * The cap is `min(18rem, 100%)` — two limits doing two different jobs:
+ * - `18rem` bounds the chip against the *content*, so a long title can never
+ * grow the chip wide enough to dominate a line of prose. Without it a chip
+ * is an atomic inline box that wraps to the next line as a unit whenever it
+ * doesn't fit at the current position, leaving a ragged gap on the line
+ * above — the reference-dense-prose problem from #6732.
+ * - `100%` bounds it against the *container*, keeping the chip inside narrow
+ * parents such as a chat bubble.
+ * `ProjectChip` carries the identical cap; the two must not drift.
+ *
+ * The cap lives here (single source of truth) — wrappers must NOT add their own
+ * flex container around it, or a percentage cap gets dropped during the
+ * wrapper's intrinsic sizing and the clickable box diverges from the truncated
+ * chip.
*
* This is the single source of truth for the "issue-mention card" look.
* It is intentionally **not** a link or button: callers wrap it in whatever
@@ -34,7 +44,7 @@ export interface IssueChipProps {
}
const BASE_CLASS =
- "issue-mention inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border mx-0.5 px-2 py-0.5 text-caption";
+ "issue-mention inline-flex min-w-0 max-w-[min(18rem,100%)] items-center gap-1.5 rounded-md border mx-0.5 px-2 py-0.5 text-caption";
export function IssueChip({ issueId, fallbackLabel, className }: IssueChipProps) {
const wsId = useWorkspaceId();
diff --git a/packages/views/projects/components/project-chip.test.tsx b/packages/views/projects/components/project-chip.test.tsx
new file mode 100644
index 0000000000..5a3091512b
--- /dev/null
+++ b/packages/views/projects/components/project-chip.test.tsx
@@ -0,0 +1,66 @@
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { useQuery } from "@tanstack/react-query";
+import { ProjectChip } from "./project-chip";
+
+vi.mock("@tanstack/react-query", () => ({
+ useQuery: vi.fn(),
+}));
+
+vi.mock("@multica/core/hooks", () => ({
+ useWorkspaceId: () => "workspace-1",
+}));
+
+vi.mock("@multica/core/projects/queries", () => ({
+ projectListOptions: () => ({ queryKey: ["projects"] }),
+ projectDetailOptions: (_workspaceId: string, projectId: string) => ({
+ queryKey: ["project", projectId],
+ }),
+}));
+
+vi.mock("./project-icon", () => ({
+ ProjectIcon: ({ className }: { className?: string }) => (
+ <span data-testid="project-icon" className={className} />
+ ),
+}));
+
+vi.mock("../../i18n", () => ({
+ useT: () => ({ t: () => "Unknown project" }),
+}));
+
+const mockUseQuery = vi.mocked(useQuery);
+
+const LONG_TITLE =
+ "A very long project title that should stay inside a narrow chat bubble";
+
+describe("ProjectChip", () => {
+ beforeEach(() => {
+ mockUseQuery.mockImplementation((options: { queryKey?: readonly unknown[] }) => {
+ if (options.queryKey?.[0] === "projects") {
+ return {
+ data: [{ id: "project-1", title: LONG_TITLE, emoji: "🚀" }],
+ } as ReturnType<typeof useQuery>;
+ }
+ return { data: undefined } as ReturnType<typeof useQuery>;
+ });
+ });
+
+ // ProjectChip and IssueChip render the same inline-chip shape in the same
+ // prose. If only one of them bounds its width, reference-dense content breaks
+ // for that one — which is how #6732 happened. Locking the cap in both tests
+ // is what keeps them from drifting apart again.
+ it("carries the same width cap as IssueChip and truncates the title", () => {
+ render(<ProjectChip projectId="project-1" />);
+
+ const chip = screen.getByText(LONG_TITLE).closest(".project-chip");
+ expect(chip).toHaveClass("min-w-0");
+ expect(chip).toHaveClass("max-w-[min(18rem,100%)]");
+ expect(screen.getByText(LONG_TITLE)).toHaveClass("min-w-0", "truncate");
+ });
+
+ it("truncates the fallback label inside the chip width", () => {
+ render(<ProjectChip projectId="missing-project" fallbackLabel={LONG_TITLE} />);
+
+ expect(screen.getByText(LONG_TITLE)).toHaveClass("min-w-0", "truncate");
+ });
+});
diff --git a/packages/views/projects/components/project-chip.tsx b/packages/views/projects/components/project-chip.tsx
index 2f50f5717e..7d33216832 100644
--- a/packages/views/projects/components/project-chip.tsx
+++ b/packages/views/projects/components/project-chip.tsx
@@ -8,7 +8,10 @@ import { useT } from "../../i18n";
/**
* Compact presentational representation of a project —
- * `<emoji> <title>`, bordered, truncating to max-w-72. Mirror of IssueChip.
+ * `<emoji> <title>`, bordered, truncating once it hits its width cap. Mirror of
+ * IssueChip, including the `min(18rem, 100%)` cap — see that file for why the
+ * content limit and the container limit are both needed. The two chips share
+ * one rendering contract and must not drift.
*
* Not a link / button: callers wrap it in whatever interactive shell they
* need. Pure UI — data is queried internally so callers can pass just an id.
@@ -22,7 +25,7 @@ export interface ProjectChipProps {
}
const BASE_CLASS =
- "project-chip inline-flex items-center gap-1.5 rounded-md border mx-0.5 px-2 py-0.5 text-caption max-w-72";
+ "project-chip inline-flex min-w-0 max-w-[min(18rem,100%)] items-center gap-1.5 rounded-md border mx-0.5 px-2 py-0.5 text-caption";
export function ProjectChip({
projectId,
@@ -46,7 +49,7 @@ export function ProjectChip({
return (
<span className={cls}>
<ProjectIcon size="md" />
- <span className="text-muted-foreground truncate">
+ <span className="min-w-0 truncate text-muted-foreground">
{fallbackLabel ?? t(($) => $.chip.fallback_label)}
</span>
</span>
@@ -56,7 +59,7 @@ export function ProjectChip({
return (
<span className={cls}>
<ProjectIcon project={project} size="md" />
- <span className="text-foreground truncate">{project.title}</span>
+ <span className="min-w-0 truncate text-foreground">{project.title}</span>
</span>
);
}