Skip to content

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

Go

feat(web): make the mobile web app installable (MUL-6237) (#7025)

Jiayuan Zhang6ec162bd338c
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 1762d3e3a7..1d45aa9d1b 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -83,6 +83,22 @@ export const metadata: Metadata = {
icons: {
icon: [{ url: "/favicon.svg", type: "image/svg+xml" }],
shortcut: ["/favicon.svg"],
+ // iOS never reads the manifest's icons for the home screen; it needs its
+ // own opaque, full-bleed square and rounds the corners itself.
+ apple: [{ url: "/icons/apple-touch-icon.png", sizes: "180x180" }],
+ },
+ // Home-screen behaviour: launch without browser chrome, and label the icon
+ // "Multica" rather than the long SEO <title>. `capable` renders the
+ // standardised `mobile-web-app-capable` tag — Next 16 no longer emits the
+ // deprecated apple-prefixed spelling, so iOS standalone rides on the
+ // manifest's `display` instead (honoured since iOS 16.4).
+ appleWebApp: {
+ capable: true,
+ title: "Multica",
+ // `default` keeps the web view below the status bar. Going edge-to-edge
+ // (`black-translucent` + viewport-fit=cover) needs env(safe-area-inset-*)
+ // padding, which no surface in the app has yet.
+ statusBarStyle: "default",
},
openGraph: {
type: "website",
diff --git a/apps/web/app/manifest.test.ts b/apps/web/app/manifest.test.ts
new file mode 100644
index 0000000000..910bc88330
--- /dev/null
+++ b/apps/web/app/manifest.test.ts
@@ -0,0 +1,93 @@
+import { describe, expect, it } from "vitest";
+import { NextRequest } from "next/server";
+import { proxy } from "../proxy";
+import manifest, { PWA_START_URL } from "./manifest";
+
+function launch(cookies: Record<string, string>, host = "www.multica.ai") {
+ const cookieHeader = Object.entries(cookies)
+ .map(([key, value]) => `${key}=${value}`)
+ .join("; ");
+
+ return proxy(
+ new NextRequest(`https://${host}${PWA_START_URL}`, {
+ headers: cookieHeader ? { cookie: cookieHeader } : undefined,
+ }),
+ ).headers.get("location");
+}
+
+describe("web app manifest", () => {
+ it("declares the fields a browser needs to offer installation", () => {
+ const m = manifest();
+
+ expect(m.display).toBe("standalone");
+ expect(m.scope).toBe("/");
+ expect(m.name).toBeTruthy();
+ expect(m.short_name).toBeTruthy();
+ });
+
+ it("ships both icon sizes Chrome requires, plus a maskable one", () => {
+ const icons = manifest().icons ?? [];
+ const sizesFor = (purpose: string) =>
+ icons.filter((icon) => icon.purpose === purpose).map((icon) => icon.sizes);
+
+ expect(sizesFor("any")).toEqual(
+ expect.arrayContaining(["192x192", "512x512"]),
+ );
+ // Without a maskable icon Android pads the `any` icon into a white blob
+ // instead of cropping it to the launcher shape.
+ expect(sizesFor("maskable")).toContain("512x512");
+ for (const icon of icons) expect(icon.src.startsWith("/icons/")).toBe(true);
+ });
+
+ it("does not launch at the root path", () => {
+ // The official marketing hosts keep "/" on the public site even for a
+ // signed-in session, so an installed app pointed there opens the landing
+ // page instead of the product.
+ expect(manifest().start_url).not.toBe("/");
+ });
+
+ it("launches into the last workspace for a signed-in session", () => {
+ expect(
+ launch({ multica_logged_in: "1", last_workspace_slug: "acme" }),
+ ).toContain("/acme/inbox");
+ });
+
+ it("launches into login when there is no session", () => {
+ expect(launch({})).toContain("/login");
+ });
+
+ it("never launches onto the marketing site for a session with no known workspace", () => {
+ // Reachable whenever `multica_logged_in` outlives `last_workspace_slug`:
+ // a member who signed up but has not opened a workspace yet, or cleared
+ // cookies. The proxy used to bounce this state to "/", which the official
+ // marketing hosts keep on the public site — so the installed app opened
+ // the landing page with no URL bar to escape it.
+ const target = launch({ multica_logged_in: "1" });
+
+ expect(target).toContain("/login");
+ expect(new URL(target ?? "", "https://www.multica.ai").pathname).not.toBe(
+ "/",
+ );
+ });
+
+ it("points every shortcut at a path that resolves the same way", () => {
+ const shortcuts = manifest().shortcuts ?? [];
+
+ expect(shortcuts.length).toBeGreaterThan(0);
+ for (const shortcut of shortcuts) {
+ const resolve = (cookie: string) =>
+ proxy(
+ new NextRequest(`https://www.multica.ai${shortcut.url}`, {
+ headers: { cookie },
+ }),
+ ).headers.get("location");
+
+ expect(
+ resolve("multica_logged_in=1; last_workspace_slug=acme"),
+ ).toContain(`/acme${shortcut.url}`);
+ // Same three states as start_url — a shortcut is a launcher entry too.
+ expect(resolve("multica_logged_in=1")).toContain("/login");
+ expect(resolve("")).toContain("/login");
+ }
+ });
+});
diff --git a/apps/web/app/manifest.ts b/apps/web/app/manifest.ts
new file mode 100644
index 0000000000..873108e06b
--- /dev/null
+++ b/apps/web/app/manifest.ts
@@ -0,0 +1,77 @@
+import type { MetadataRoute } from "next";
+
+/**
+ * Web app manifest — what makes the mobile web app installable and lets it run
+ * in its own window instead of a browser tab.
+ *
+ * `start_url` is deliberately NOT "/". The official marketing hosts keep the
+ * root path on the public site even for a signed-in session (see
+ * `isOfficialMarketingHost` in proxy.ts), so an installed app pointed at "/"
+ * would open the landing page. "/inbox" is one of `LEGACY_ROUTE_SEGMENTS`,
+ * which proxy.ts resolves per session: signed in with a known workspace it
+ * lands on that workspace's inbox, signed in without one it lands on /login
+ * (which resolves against the workspace list), and signed out it lands on
+ * /login too. All three are pinned in manifest.test.ts, because a launcher
+ * icon has no URL bar to recover from a wrong destination.
+ *
+ * The icons under /icons are generated, not hand-drawn. To regenerate after a
+ * brand change, edit public/icons/icon.svg and run from public/icons:
+ *
+ * sips -s format png --resampleHeightWidth 512 512 icon.svg --out icon-maskable-512.png
+ * sips -s format png --resampleHeightWidth 180 180 icon.svg --out apple-touch-icon.png
+ * sips -s format png --resampleHeightWidth 512 512 ../../../desktop/build/icon.png --out icon-512.png
+ * sips -s format png --resampleHeightWidth 192 192 ../../../desktop/build/icon.png --out icon-192.png
+ *
+ * The two `any` icons come from the desktop app icon so an installed web app
+ * and an installed desktop app show the same artwork; the maskable one is
+ * full-bleed because Android crops it to the launcher's shape.
+ */
+
+/** Launch path. Exported so manifest.test.ts can run it through the proxy. */
+export const PWA_START_URL = "/inbox";
+
+export default function manifest(): MetadataRoute.Manifest {
+ return {
+ id: "/",
+ name: "Multica",
+ short_name: "Multica",
+ description:
+ "Assign tasks to coding agents, track progress, and keep your team's work in one place.",
+ start_url: PWA_START_URL,
+ scope: "/",
+ display: "standalone",
+ // Splash-screen colours. The runtime status bar is driven by the
+ // per-scheme `<meta name="theme-color">` pair in app/layout.tsx, which the
+ // manifest cannot express — these are the pre-launch fallback only.
+ background_color: "#ffffff",
+ theme_color: "#ffffff",
+ categories: ["productivity"],
+ icons: [
+ {
+ src: "/icons/icon-192.png",
+ sizes: "192x192",
+ type: "image/png",
+ purpose: "any",
+ },
+ {
+ src: "/icons/icon-512.png",
+ sizes: "512x512",
+ type: "image/png",
+ purpose: "any",
+ },
+ {
+ src: "/icons/icon-maskable-512.png",
+ sizes: "512x512",
+ type: "image/png",
+ purpose: "maskable",
+ },
+ ],
+ // Long-press actions on the installed launcher icon. Both are legacy
+ // segments, so they resolve to the last workspace the same way start_url
+ // does instead of needing a slug the manifest cannot know.
+ shortcuts: [
+ { name: "Inbox", url: "/inbox" },
+ { name: "My Issues", url: "/my-issues" },
+ ],
+ };
+}
diff --git a/apps/web/proxy.test.ts b/apps/web/proxy.test.ts
index cc537c134f..52383335e0 100644
--- a/apps/web/proxy.test.ts
+++ b/apps/web/proxy.test.ts
@@ -89,12 +89,26 @@ describe("proxy legacy workspace route redirects", () => {
);
});
- it("sends logged-in legacy URLs without a last workspace cookie to root", () => {
+ it("sends logged-in legacy URLs without a last workspace cookie to login", () => {
+ // Not root: the root-path rule below leaves "/" on the public site for the
+ // official marketing hosts even with a session, so bouncing there would
+ // dead-end on the landing page. /login resolves against the workspace list
+ // instead. The deep-link query is dropped because feeding a legacy path
+ // back through `next` would return here and loop.
expect(
- redirectLocation("/squads", { multica_logged_in: "1" }),
- ).toBe("https://app.multica.test/");
+ redirectLocation("/squads?view=members", { multica_logged_in: "1" }),
+ ).toBe("https://app.multica.test/login");
});
+ it.each(["multica.ai", "www.multica.ai"])(
+ "resolves a slugless session off the marketing host %s instead of stranding it",
+ (host) => {
+ expect(
+ redirectLocation("/inbox", { multica_logged_in: "1" }, host),
+ ).toBe(`https://${host}/login`);
+ },
+ );
+
it("does not redirect workspace-scoped URLs whose first segment is already a slug", () => {
expect(redirectLocation("/acme/squads", sessionCookies)).toBeNull();
});
diff --git a/apps/web/proxy.ts b/apps/web/proxy.ts
index 997ef73707..7469c04eab 100644
--- a/apps/web/proxy.ts
+++ b/apps/web/proxy.ts
@@ -76,10 +76,17 @@ export function proxy(req: NextRequest) {
return NextResponse.redirect(url);
}
- // Logged-in but no cookie yet (first login since slug migration, or
- // cookie cleared). Bounce to root; the root-path logic below picks a
- // workspace and writes the cookie, then future hits short-circuit here.
- url.pathname = "/";
+ // Logged-in but no cookie yet (never opened a workspace, or the cookie was
+ // cleared). Root is the wrong destination: the root-path rule below leaves
+ // `/` on the public site for the official marketing hosts even with a
+ // session, so bouncing there dead-ends on the landing page instead of
+ // reaching the app. /login already resolves an authenticated visitor
+ // against their workspace list — including pending invitations and the
+ // no-workspace-yet case — and replaces to the right destination. Deep-link
+ // path and query are dropped rather than passed as `next`: they are legacy
+ // segments themselves, so feeding one back would land here again.
+ url.pathname = "/login";
+ url.search = "";
return NextResponse.redirect(url);
}
diff --git a/apps/web/public/icons/apple-touch-icon.png b/apps/web/public/icons/apple-touch-icon.png
new file mode 100644
index 0000000000..4d4015607b
Binary files /dev/null and b/apps/web/public/icons/apple-touch-icon.png differ
diff --git a/apps/web/public/icons/icon-192.png b/apps/web/public/icons/icon-192.png
new file mode 100644
index 0000000000..c3a72ef440
Binary files /dev/null and b/apps/web/public/icons/icon-192.png differ
diff --git a/apps/web/public/icons/icon-512.png b/apps/web/public/icons/icon-512.png
new file mode 100644
index 0000000000..b769317427
Binary files /dev/null and b/apps/web/public/icons/icon-512.png differ
diff --git a/apps/web/public/icons/icon-maskable-512.png b/apps/web/public/icons/icon-maskable-512.png
new file mode 100644
index 0000000000..d4df39be1a
Binary files /dev/null and b/apps/web/public/icons/icon-maskable-512.png differ
diff --git a/apps/web/public/icons/icon.svg b/apps/web/public/icons/icon.svg
new file mode 100644
index 0000000000..4e0567d72b
--- /dev/null
+++ b/apps/web/public/icons/icon.svg
@@ -0,0 +1,17 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="Multica">
+ <!--
+ Full-bleed source for the generated home-screen icons (apple-touch-icon.png,
+ icon-maskable-512.png). Full-bleed because both surfaces mask the artwork
+ themselves: iOS rounds the corners, Android crops to the launcher shape.
+ The mark is /favicon.svg's polygon, inverted to the dark app-icon treatment
+ the desktop and mobile builds already ship, and held at 52% of the canvas so
+ it stays inside the maskable safe zone (the centre circle of 80% diameter).
+ See app/manifest.ts for the regeneration commands.
+ -->
+ <rect width="512" height="512" fill="#111827"/>
+ <polygon
+ fill="#ffffff"
+ transform="translate(122.88 122.88) scale(2.6624)"
+ points="45,62.1 45,100 55,100 55,62.1 81.8,88.9 88.9,81.8 62.1,55 100,55 100,45 62.1,45 88.9,18.2 81.8,11.1 55,37.9 55,0 45,0 45,37.9 18.2,11.1 11.1,18.2 37.9,45 0,45 0,55 37.9,55 11.1,81.8 18.2,88.9"
+ />
+</svg>