Skip to content
55 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

g1t is described as the product it is in alpha, and its shell takes the new shape: the README, the docs home and docs/PLAN.md label every feature Live, Preview or Coming; a floating dock with the g1t mark, Today, Chat, Notifications, Agents, Code, Artifacts, your pinned apps and the Apps launcher, with People, Workspace and the account menu (now holding help) at its foot; the workspace's logo and switcher heading a flat sidebar that folds away with Ctrl B, or leading the header's breadcrumbs where there is none; the page in a rounded panel with a full-width header; Today as the front page, with first-time acceptance of agents' pull requests, what needs you and what's at stake, spend today and one item to start with, every number from a service; Notifications in place of the Inbox at /notifications; a bottom bar and More sheet on phones; and sign-in, sign-up, two-factor, reset, invites and choosing a workspace on standalone pages with no app around them.1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { APPS, MAX_APP_PINS, appPinFromForm, appsFor, dockCookie, isPinnable, pinsIn, readDock, sidebarClosed, sidebarCookie, withPin, writeDock } from "./apps.ts";
5
6test("built-in apps are never pinned; the rest are", () => {
7 for (const app of APPS) assert.equal(isPinnable(app.key), !app.builtin, app.key);
8 assert.equal(isPinnable("nonsense"), false);
9});
10
11test("Code's apps are only for members with Code access", () => {
12 const without = appsFor(false).map((app) => app.key);
13 for (const key of ["code", "projects", "packages", "security", "context", "memory"]) assert.ok(!without.includes(key as never), key);
14 for (const key of ["today", "chat", "notifications", "agents", "artifacts", "people", "workspace", "teams", "usage"]) assert.ok(without.includes(key as never), key);
15 assert.equal(appsFor(true).length, APPS.length);
16});
17
18test("pins are kept per workspace, in the order they were pinned", () => {
19 const value = writeDock(writeDock(null, "acme", ["projects", "usage"]), "Beta", ["teams"]);
20 assert.equal(value, "beta:teams,acme:projects.usage");
21 assert.deepEqual(pinsIn(value, "acme"), ["projects", "usage"]);
22 assert.deepEqual(pinsIn(value, "BETA"), ["teams"]);
23 assert.deepEqual(pinsIn(value, "other"), []);
24 // Unpinning everything keeps the workspace, with no pins.
25 assert.deepEqual(pinsIn(writeDock(value, "acme", []), "acme"), []);
26});
27
28test("a cookie someone wrote by hand reads as far as it makes sense", () => {
29 assert.deepEqual(readDock("acme:projects.today.nonsense.projects,BAD SLUG:usage,beta"), { acme: ["projects"] });
30 assert.deepEqual(readDock(""), {});
31 const many = Array.from({ length: 30 }, () => "usage").join(".");
32 assert.ok(pinsIn(`acme:${many}`, "acme").length <= MAX_APP_PINS);
33});
34
35test("a pin form pins or unpins one app", () => {
36 const form = (fields: Record<string, string>) => {
37 const data = new FormData();
38 for (const [name, value] of Object.entries(fields)) data.set(name, value);
39 return data;
40 };
41 assert.deepEqual(appPinFromForm(form({ intent: "pin", app: "teams" })), { app: "teams", pinned: true });
42 assert.deepEqual(appPinFromForm(form({ intent: "unpin", app: "teams" })), { app: "teams", pinned: false });
43 assert.equal(appPinFromForm(form({ intent: "pin", app: "chat" })), null);
44 assert.equal(appPinFromForm(form({ intent: "drop", app: "teams" })), null);
45 assert.deepEqual(withPin(["projects", "teams"], "projects", true), ["teams", "projects"]);
46 assert.deepEqual(withPin(["projects", "teams"], "projects", false), ["teams"]);
47});
48
49test("the cookies last a year and are secure when the site is", () => {
50 assert.match(dockCookie("acme:teams", true), /^g1t_dock=acme%3Ateams; Path=\/; Max-Age=31536000; SameSite=Lax; Secure$/);
51 assert.equal(sidebarCookie(true, false), "g1t_sidebar=closed; Path=/; Max-Age=31536000; SameSite=Lax");
52 assert.equal(sidebarClosed("closed"), true);
53 assert.equal(sidebarClosed("open"), false);
54 assert.equal(sidebarClosed(null), false);
55});