Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dashboard/e2e/knowledge-builtin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Base {
builtin: true;
counts: { label: string; count: number }[];
updated_at: string | null;
stopped_at?: string | null;
access: { open: boolean; why: string | null };
audience: { roles: string[]; people: string[]; readers: boolean; paused: boolean };
audience_label: string;
Expand Down Expand Up @@ -482,6 +483,24 @@ test.describe("built-in search: switching the base", () => {
await expect(box(page)).toBeFocused();
});

test("Knowledge says when it last synced, and a stopped sync plainly, never the base's old settings date", async ({ page }) => {
const db = await mock(page, true);
const team = db.bases.find((b) => b.key === "team")!;
// The gateway's newest successful sync, 4 minutes ago.
team.updated_at = iso(4);
await page.goto("/knowledge/");
await expect(card(page, "team").getByTestId("builtin-fresh")).toHaveText("Updated 4 min ago");
await expect(card(page, "team").getByTestId("builtin-state")).toHaveCount(0);

// The latest sync stopped: the row says so, the panel keeps what it holds.
team.stopped_at = iso(5);
team.updated_at = iso(35);
await page.reload();
await expect(card(page, "team").getByTestId("builtin-fresh")).toHaveText("Last sync stopped 5 min ago");
await card(page, "team").getByTestId("builtin-open").click();
await expect(page.getByTestId("builtin-panel")).toContainText("Updated 35 min ago. Last sync stopped 5 min ago");
});

test("with nothing typed a tab only narrows; the next search runs there", async ({ page }) => {
const db = await mock(page, true);
await page.goto("/knowledge/");
Expand Down
22 changes: 15 additions & 7 deletions dashboard/src/components/knowledge/builtin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,23 @@ function BaseIcon({ k, size = "md" }: { k: BuiltinKey; size?: "sm" | "md" }) {

function freshness(b: BuiltinBase): { words: string; live: boolean } {
if (b.live) return { words: b.updated_at ? `Live, updated ${timeAgo(b.updated_at)}` : "Live", live: true };
if (b.updated_at) return { words: `Updated ${timeAgo(b.updated_at)}`, live: false };
return { words: "Not read yet", live: false };
const stopped = b.stopped_at ? `Last sync stopped ${timeAgo(b.stopped_at)}` : "";
if (b.updated_at) return { words: `Updated ${timeAgo(b.updated_at)}${stopped ? `. ${stopped}` : ""}`, live: false };
return { words: stopped || "Not read yet", live: false };
}

/** The row's few words: "Live", a stopped sync, or how long ago it changed. */
function rowFreshness(b: BuiltinBase): string {
if (b.live) return "Live";
if (b.stopped_at) return `Last sync stopped ${timeAgo(b.stopped_at)}`;
return b.updated_at ? `Updated ${timeAgo(b.updated_at)}` : "";
}

/** The one state worth a pill on the overview, if any. */
function stateOf(b: BuiltinBase): { tone: "warning" | "neutral"; words: string } | null {
if (!b.access.open) return { tone: "warning", words: "Not open to you" };
if (b.audience.paused) return { tone: "neutral", words: "Paused" };
if (!b.updated_at && !b.live) return { tone: "neutral", words: "Not read yet" };
if (!b.updated_at && !b.live && !b.stopped_at) return { tone: "neutral", words: "Not read yet" };
return null;
}

Expand Down Expand Up @@ -228,15 +236,15 @@ function BaseCard({ b, onOpen }: { b: BuiltinBase; onOpen: (el: HTMLElement) =>
const people = b.audience.people.length;
const who = `${roles.length ? roles.join(", ") : "All roles"}${people ? ` +${people}` : ""}`;
const whoSpoken = `${roles.length ? listWords(roles) : "All roles"}${people ? ` and ${plural(people, "person", "people")}` : ""}`;
// The row says "Live" or how long ago; the panel has both.
const fresh = b.live ? "Live" : b.updated_at ? `Updated ${timeAgo(b.updated_at)}` : "";
// The row says "Live", a stopped sync, or how long ago; the panel has all.
const fresh = rowFreshness(b);
const status = state ? (
<span data-testid="builtin-state" className="min-w-0 max-w-full">
<StatusPill tone={state.tone}>{state.words}</StatusPill>
</span>
) : (
<span className="flex min-w-0 items-center gap-1.5 text-xs text-zinc-400" data-testid="builtin-fresh">
<StatusDot tone={b.live ? "success" : "neutral"} live={false} className="!h-1.5 !w-1.5" />
<StatusDot tone={b.live ? "success" : b.stopped_at ? "waiting" : "neutral"} live={false} className="!h-1.5 !w-1.5" />
<span className="truncate">{fresh}</span>
</span>
);
Expand Down Expand Up @@ -700,7 +708,7 @@ function PanelBody({ b, canManage, readersOn, onChange, onSearch }: { b: Builtin
<span data-testid="builtin-access">{b.access.open ? <StatusPill tone="success">Open to you</StatusPill> : <StatusPill tone="warning">Not open to you</StatusPill>}</span>
{b.audience.paused && <StatusPill tone="neutral">Paused</StatusPill>}
<span className="flex items-center gap-1.5 text-zinc-400">
<StatusDot tone={fresh.live ? "success" : b.updated_at ? "neutral" : "muted"} live={false} className="!h-1.5 !w-1.5" />
<StatusDot tone={fresh.live ? "success" : b.stopped_at ? "waiting" : b.updated_at ? "neutral" : "muted"} live={false} className="!h-1.5 !w-1.5" />
{fresh.words}
</span>
</div>
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/lib/builtin-bases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export interface BuiltinBase {
live?: boolean;
/** When what it holds last changed; null: not read yet. */
updated_at: string | null;
/** When a sync that stopped did (its last sync stopped); null or absent:
* none did. `updated_at` still says what it holds. */
stopped_at?: string | null;
/** Whether the person looking may read it, and why not. */
access: { open: boolean; why: string | null };
audience: BuiltinAudience;
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/concepts/knowledge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: The team's six built-in bases, and documents from your apps, upload

## The team's built-in bases

Every team has six bases with nothing to set up: **Code**, **Work** (tickets, pull requests, runs, reviews and plans), **Infrastructure** (AWS resources, where each is defined and what AWS has pending), **Logs**, **Security** and **Knowledge** (the bases below). The **Knowledge** page shows each with its counts and when it last changed, and admins choose who reads each one.
Every team has six bases with nothing to set up: **Code**, **Work** (tickets, pull requests, runs, reviews and plans), **Infrastructure** (AWS resources, where each is defined and what AWS has pending), **Logs**, **Security** and **Knowledge** (the bases below). The **Knowledge** page shows each with its counts and when it was last refreshed (for **Knowledge**, the newest successful sync or upload across the bases; for **Security**, the newest scan), and admins choose who reads each one. When a source's last sync stopped, the row says **Last sync stopped** and when, and its details still say when it last brought content in.

Chat, the Knowledge page, share links and connected AI tools all read through the same check: your role, the base's readers and, for an AI tool, the scopes it was given. A share link keeps the search, never the results, and searches again as whoever opens it; it lasts 1, 7 or 30 days and the sharer or an admin can end it.

Expand Down
Loading