Skip to content
71 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
The apps you pin to your dock are kept with your account, per workspace and in your order, so the dock is the same on every device: identity keeps them in dock_pins and answers dock_pins and set_dock_pins, the dock reads them with the rest of the page, pins kept only on this device carry over with your first change, this device's copy still draws the dock when identity can't be reached, a pin that can't be saved says so, and they go when you or the workspace do; the workspaces guide says how.4import { APPS, MAX_APP_PINS, appPinFromForm, appsFor, dockCookie, isPinnable, pinsFrom, pinsIn, pinsToShow, readDock, sidebarClosed, sidebarCookie, withPin, writeDock } from "./apps.ts";
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.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
The apps you pin to your dock are kept with your account, per workspace and in your order, so the dock is the same on every device: identity keeps them in dock_pins and answers dock_pins and set_dock_pins, the dock reads them with the rest of the page, pins kept only on this device carry over with your first change, this device's copy still draws the dock when identity can't be reached, a pin that can't be saved says so, and they go when you or the workspace do; the workspaces guide says how.35test("pins kept with the account keep their order and only real apps", () => {
36 assert.deepEqual(pinsFrom(["usage", "projects", "today", "retired-app", "usage", "teams"]), ["usage", "projects", "teams"]);
37 assert.deepEqual(pinsFrom([]), []);
38 assert.ok(pinsFrom(Array.from({ length: 30 }, (_, n) => APPS[8 + (n % 10)]!.key)).length <= MAX_APP_PINS);
39});
40
41test("the account's pins win over the cookie, which is the fallback", () => {
42 const cookie = writeDock(null, "acme", ["projects", "usage"]);
43 // Saved with the account, even with nothing pinned: the account's.
44 assert.deepEqual(pinsToShow(["teams", "audit"], cookie, "acme"), ["teams", "audit"]);
45 assert.deepEqual(pinsToShow([], cookie, "acme"), []);
46 // Never saved, or identity could not be asked: this device's cookie.
47 assert.deepEqual(pinsToShow(null, cookie, "acme"), ["projects", "usage"]);
48 assert.deepEqual(pinsToShow(undefined, null, "acme"), []);
49});
50
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.51test("a pin form pins or unpins one app", () => {
52 const form = (fields: Record<string, string>) => {
53 const data = new FormData();
54 for (const [name, value] of Object.entries(fields)) data.set(name, value);
55 return data;
56 };
57 assert.deepEqual(appPinFromForm(form({ intent: "pin", app: "teams" })), { app: "teams", pinned: true });
58 assert.deepEqual(appPinFromForm(form({ intent: "unpin", app: "teams" })), { app: "teams", pinned: false });
59 assert.equal(appPinFromForm(form({ intent: "pin", app: "chat" })), null);
60 assert.equal(appPinFromForm(form({ intent: "drop", app: "teams" })), null);
61 assert.deepEqual(withPin(["projects", "teams"], "projects", true), ["teams", "projects"]);
62 assert.deepEqual(withPin(["projects", "teams"], "projects", false), ["teams"]);
63});
64
65test("the cookies last a year and are secure when the site is", () => {
66 assert.match(dockCookie("acme:teams", true), /^g1t_dock=acme%3Ateams; Path=\/; Max-Age=31536000; SameSite=Lax; Secure$/);
67 assert.equal(sidebarCookie(true, false), "g1t_sidebar=closed; Path=/; Max-Age=31536000; SameSite=Lax");
68 assert.equal(sidebarClosed("closed"), true);
69 assert.equal(sidebarClosed("open"), false);
70 assert.equal(sidebarClosed(null), false);
71});