mirror of
https://github.com/multica-ai/multica.git
synced 2026-08-13 03:15:34 +02:00
tokens.css defined colours, radii and font families but not a single --text-* step, so font sizes had no baseline to align to and grew wherever they were needed: 51 distinct sizes across web + desktop, 370 written as arbitrary values, six at half a pixel (10.5 / 11.5 / 12.5 / 13.5 / 14.5 / 15.5px). text-xs and text-sm carried nearly all UI text while the range between them — 11, 13, 15px — could only be reached with arbitrary values. Hierarchy does not come from having more sizes; past a handful, each extra size makes the hierarchy blurrier. Add ten role-named steps, each with its own line-height so leading cannot fragment the way size did, and move every product-UI call site onto them. Steps are named for what the text is for, not for a t-shirt size, because that is what keeps the scale from drifting again. Six steps deliberately keep the exact size/line-height pairs of the Tailwind defaults they replace, so the ~1,900-call-site rename moves nothing on screen. The visible changes are confined to former arbitrary values snapping to a step: 8/9/10px -> micro (11px) on badges and overlines; 17 -> 18; 22 -> 24; 30 (text-3xl) -> 36 on headings and stat numbers; 12.8px -> label (13px) on small buttons and toggles. Half-pixel sizes are gone. This supersedes #6108, which was reverted by #6116 because the sidebar group labels rendered at the inherited 16px. The cause was not the scale but cn(): `text-<x>` is ambiguous in Tailwind, and tailwind-merge resolves it against a table listing only the default sizes, so it filed every role step under text-colour and dropped whichever of `text-caption` / `text-sidebar-foreground/70` came first. Registering the steps as a font-size class group restores the real conflict groups — size beats size, colour beats colour, the two coexist — and a test pins the list against the scale, since the failure is silent in source. Hand-written CSS is covered too. The transcript kept a 12.5px body long after every Tailwind call site was on the scale, so the "no half-pixel sizes" claim was true of the classes and false of the product; the editor's prose, code and mermaid ramps had the same blind spot, and seven of their eight values already equalled a step exactly. All now reference var(--text-*). The guard test reads raw `font-size:` declarations as well as class names, exempting only the 16px iOS input-zoom workaround in base.css and the landing pages' marketing ramp. apps/mobile (own NativeWind config) and apps/docs (fumadocs' own type system) keep Tailwind's default scale and are untouched. Landing display type (rem/clamp, 2.2-6.4rem) stays on its separate ramp, as do four decorative emoji / serif-hero sizes. Verified on a running local stack: pinned sidebar rows and group labels measure 12px/16px, nav items 14px/20px — identical to pre-migration. An audit of every rendered font size across the product surfaces finds nothing off the scale; the only exceptions are avatar initials and emoji, which actor-avatar.tsx sizes proportionally to the avatar diameter by design. Co-authored-by: Lambda <lambda@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
140 lines
5.1 KiB
TypeScript
140 lines
5.1 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { Card, CardContent } from "@multica/ui/components/ui/card";
|
|
import { Button } from "@multica/ui/components/ui/button";
|
|
import { api } from "@multica/core/api";
|
|
import { useAuthStore } from "@multica/core/auth";
|
|
import { useNavigation } from "../navigation";
|
|
import { useT } from "../i18n";
|
|
|
|
type RedeemState =
|
|
| { kind: "idle" }
|
|
| { kind: "redeeming" }
|
|
| { kind: "done"; workspaceId: string; installationId: string }
|
|
| { kind: "needs-auth" }
|
|
| { kind: "error"; reason: string };
|
|
|
|
// SlackBindPage is the destination the bot's "link your account" prompt points
|
|
// at (MUL-3666). The user lands here logged out OR logged in; we require auth
|
|
// before redeeming because the redeemer's Multica identity is taken from the
|
|
// session (the token alone never proves who is binding — see
|
|
// slack.BindingTokenService.RedeemAndBind).
|
|
//
|
|
// The token comes in via `?token=<raw>`. We POST it to /api/slack/binding/redeem;
|
|
// the backend returns 410 (invalid/expired), 409 (already bound to another
|
|
// user), 403 (not a workspace member) or 200 with the bound installation. Each
|
|
// maps to distinct copy via slack_bind in common.json.
|
|
export function SlackBindPage({ token }: { token: string | null }) {
|
|
const { t } = useT("common");
|
|
const user = useAuthStore((s) => s.user);
|
|
const isAuthLoading = useAuthStore((s) => s.isLoading);
|
|
const navigation = useNavigation();
|
|
const [state, setState] = useState<RedeemState>({ kind: "idle" });
|
|
|
|
useEffect(() => {
|
|
if (!token) {
|
|
setState({ kind: "error", reason: "missing_token" });
|
|
return;
|
|
}
|
|
if (isAuthLoading) return;
|
|
if (!user) {
|
|
setState({ kind: "needs-auth" });
|
|
return;
|
|
}
|
|
if (state.kind !== "idle" && state.kind !== "needs-auth") return;
|
|
setState({ kind: "redeeming" });
|
|
(async () => {
|
|
try {
|
|
const resp = await api.redeemSlackBindingToken(token);
|
|
setState({
|
|
kind: "done",
|
|
workspaceId: resp.workspace_id,
|
|
installationId: resp.installation_id,
|
|
});
|
|
} catch (e) {
|
|
setState({
|
|
kind: "error",
|
|
reason: redemptionFailureReason(e),
|
|
});
|
|
}
|
|
})();
|
|
}, [token, user, isAuthLoading, state.kind]);
|
|
|
|
return (
|
|
<div className="mx-auto flex min-h-screen max-w-md flex-col items-center justify-center p-6">
|
|
<Card className="w-full">
|
|
<CardContent className="space-y-4">
|
|
<h1 className="text-title font-semibold">{t(($) => $.slack_bind.page_title)}</h1>
|
|
{state.kind === "idle" || state.kind === "redeeming" ? (
|
|
<p className="text-body text-muted-foreground">{t(($) => $.slack_bind.redeeming)}</p>
|
|
) : state.kind === "needs-auth" ? (
|
|
<>
|
|
<p className="text-body text-muted-foreground">
|
|
{t(($) => $.slack_bind.needs_auth_description)}
|
|
</p>
|
|
<Button
|
|
size="sm"
|
|
onClick={() =>
|
|
navigation.push(
|
|
`/login?next=${encodeURIComponent(
|
|
`/slack/bind?token=${encodeURIComponent(token ?? "")}`,
|
|
)}`,
|
|
)
|
|
}
|
|
>
|
|
{t(($) => $.slack_bind.sign_in)}
|
|
</Button>
|
|
</>
|
|
) : state.kind === "done" ? (
|
|
<>
|
|
<p className="text-body font-medium">{t(($) => $.slack_bind.done_title)}</p>
|
|
<p className="text-caption text-muted-foreground">
|
|
{t(($) => $.slack_bind.done_description)}
|
|
</p>
|
|
</>
|
|
) : (
|
|
<>
|
|
<p className="text-body font-medium">{t(($) => $.slack_bind.error_title)}</p>
|
|
<p className="text-caption text-muted-foreground">
|
|
{(() => {
|
|
switch (state.reason) {
|
|
case "missing_token":
|
|
return t(($) => $.slack_bind.error_missing_token);
|
|
case "expired":
|
|
return t(($) => $.slack_bind.error_expired);
|
|
case "already_bound":
|
|
return t(($) => $.slack_bind.error_already_bound);
|
|
case "not_member":
|
|
return t(($) => $.slack_bind.error_not_member);
|
|
default:
|
|
return t(($) => $.slack_bind.error_unknown);
|
|
}
|
|
})()}
|
|
</p>
|
|
<p className="text-micro text-muted-foreground">
|
|
{t(($) => $.slack_bind.error_admin_hint)}
|
|
</p>
|
|
</>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function redemptionFailureReason(err: unknown): string {
|
|
const msg = err instanceof Error ? err.message : "";
|
|
const lower = msg.toLowerCase();
|
|
if (lower.includes("invalid") || lower.includes("expired") || lower.includes("410")) {
|
|
return "expired";
|
|
}
|
|
if (lower.includes("already bound") || lower.includes("409")) {
|
|
return "already_bound";
|
|
}
|
|
if (lower.includes("workspace member") || lower.includes("403")) {
|
|
return "not_member";
|
|
}
|
|
return "unknown";
|
|
}
|