Public: anyone can read this; the crew can change it.
Home is the feed: signed in, `/` is a composer above one timeline, and your apps move one step away #676
scout/forge:scout/599-home-is-the-feed-signed-in-is-a-composer → main 1 commit fork
13 files
changed +297
−146
docs/FEED.md +16 −12
| @@ -5,7 +5,7 @@ one sentence saying why it is there. | ||
| 5 | 5 | |
| 6 | 6 | `GET /api/v1/feed?limit=&cursor=` → `{ items, next_cursor }`, for the signed-in |
| 7 | 7 | viewer only. An item is `{ id, kind, app, actor, at, link, reason, score }`; |
| 8 | `kind` is `run | ask | pull | decision | map | cost`. Strings are plain text, | |
| 8 | `kind` is `run | ask | pull | decision | map | cost | tell | reply | look`; `what` is the post's own words and `reason` is why it is there. Strings are plain text, | |
| 9 | 9 | not HTML: whatever renders them escapes them. |
| 10 | 10 | |
| 11 | 11 | `POST /api/v1/feed/interactions` `{ item, kind, app? }` records what the viewer |
| @@ -16,10 +16,10 @@ Anything the viewer cannot read is a 404. | ||
| 16 | 16 | |
| 17 | 17 | ## Where items come from (`src/feed/items.ts`) |
| 18 | 18 | |
| 19 | - Events through `listEventsVisibleTo` then `audienceFilter`: `run.finished` | |
| 19 | - Events through `listEventsVisibleTo` then `audienceFilter`: `issue.opened` (a `tell`, titled), `issue.commented|pull.commented` (a `reply`, under its thing), `run.finished` | |
| 20 | 20 | (a deploy, check or agent run; a costly agent run is a `cost` item, shown |
| 21 | 21 | only to those who may see owner facts), `pull.opened|merged|reviewed`, |
| 22 | `look.taken` (new: a full set of preview pictures), `app.serving`, | |
| 22 | `look.taken` (a `look`: a full set of preview pictures), `app.serving`, | |
| 23 | 23 | `issue.blocked|unblocked` (map changes). |
| 24 | 24 | - Pending asks (`askLinesFor`), only for what the viewer may decide. |
| 25 | 25 | - Decision-ledger outcomes, only for repositories the viewer may write. |
| @@ -42,16 +42,20 @@ muted away. Dismissing hides one item. The cursor is `score|id` of the last | ||
| 42 | 42 | item; the feed is recomputed per request and resumes by id (or by score if |
| 43 | 43 | that item has gone). |
| 44 | 44 | |
| 45 | ## The page (`src/web/studio/feed.ts`) | |
| 45 | ## The page (`src/web/studio/feed.ts`, `home.ts`) | |
| 46 | 46 | |
| 47 | `/` for a signed-in viewer renders the first 20 items as cards above the shelf, | |
| 48 | server-side, and `/live/feed` answers the same region for the live-regions | |
| 49 | client (etag, 304). A card: the reason as a link into the thing, Steer (run | |
| 50 | cards, posts to the run's `steer`) or Tell the crew (everything else, posts to | |
| 51 | the app's `tell`), Dismiss and Mute app (the interactions API, same-origin). | |
| 52 | Keys: `j`/`k`/Enter are the shell's, `x` dismisses the focused card. | |
| 53 | Not yet: the `choose` deck card (nothing in the feed produces one), stop from | |
| 54 | a card, and paging past the first 20. | |
| 47 | `/` for a signed-in viewer is one timeline: a composer (an app's tell, sent | |
| 48 | through the outbox to `POST /api/v1/feed/tells`), then the first 20 items as | |
| 49 | posts, server-side, with the actor's name and face. A post's words link in one | |
| 50 | tap to its thing (issue, change, run, look). `/live/feed` answers the same | |
| 51 | region for the live-regions client (etag, 304). A post also has Steer (runs) or | |
| 52 | Tell the crew, Dismiss and Mute app. Keys: `j`/`k`/Enter are the shell's, `x` | |
| 53 | dismisses the focused post. "Your apps" is a narrow column on a desk and a tab | |
| 54 | on a phone, linking to `/apps`, where the shelf rows and the day's cost line | |
| 55 | now live. The MCP tool `feed { limit, cursor }` returns the same | |
| 56 | `{ items, next_cursor }`. | |
| 57 | Not yet: the `choose` deck card, stop from a card, and paging past the first 20 | |
| 58 | on the page. | |
| 55 | 59 | |
| 56 | 60 | ## Offline (`src/web/sw.ts`, `outbox.ts`) |
| 57 | 61 |
src/feed/items.ts +32 −4
| @@ -10,6 +10,7 @@ import type { Database } from "bun:sqlite"; | ||
| 10 | 10 | import { listDecidedIn } from "../core/decisions.ts"; |
| 11 | 11 | import { audienceFilter } from "../core/event_audience.ts"; |
| 12 | 12 | import { listEventsVisibleTo, type ForgeEvent } from "../core/events.ts"; |
| 13 | import { getIssue } from "../core/issues.ts"; | |
| 13 | 14 | import { getPull, toldBy } from "../core/pulls.ts"; |
| 14 | 15 | import { |
| 15 | 16 | canSeeOwnerFacts, |
| @@ -20,7 +21,16 @@ import { | ||
| 20 | 21 | import { getUserById, type User } from "../core/users.ts"; |
| 21 | 22 | import { askLinesFor } from "../web/studio/asks.ts"; |
| 22 | 23 | |
| 23 | export type FeedKind = "run" | "ask" | "pull" | "decision" | "map" | "cost"; | |
| 24 | export type FeedKind = | |
| 25 | | "run" | |
| 26 | | "ask" | |
| 27 | | "pull" | |
| 28 | | "decision" | |
| 29 | | "map" | |
| 30 | | "cost" | |
| 31 | | "tell" | |
| 32 | | "reply" | |
| 33 | | "look"; | |
| 24 | 34 | |
| 25 | 35 | /** What a candidate is, before it is ranked and worded. */ |
| 26 | 36 | export interface Candidate { |
| @@ -186,13 +196,31 @@ function fromEvent( | ||
| 186 | 196 | case "pull.reviewed": |
| 187 | 197 | return { ...common, kind: "pull", link: change, what: `a change was reviewed${title ? `: ${clip(title)}` : ""}` }; |
| 188 | 198 | case "look.taken": |
| 199 | return { ...common, kind: "look", link: base(repo), what: "a new preview picture is ready" }; | |
| 189 | 200 | case "app.serving": |
| 201 | return { ...common, kind: "pull", link: base(repo), what: "a new version is serving" }; | |
| 202 | case "issue.opened": { | |
| 203 | if (number === undefined) return undefined; | |
| 204 | const title = getIssue(db, repo.id, number)?.title ?? ""; | |
| 190 | 205 | return { |
| 191 | 206 | ...common, |
| 192 | kind: "pull", | |
| 193 | link: base(repo), | |
| 194 | what: e.kind === "look.taken" ? "a new preview picture is ready" : "a new version is serving", | |
| 207 | kind: "tell", | |
| 208 | link: `${base(repo)}/issues/${number}`, | |
| 209 | what: title === "" ? `#${number} was told` : clip(title), | |
| 195 | 210 | }; |
| 211 | } | |
| 212 | case "issue.commented": | |
| 213 | case "pull.commented": { | |
| 214 | if (number === undefined) return undefined; | |
| 215 | const noun = e.kind === "issue.commented" ? "issues" : "changes"; | |
| 216 | const said = typeof p["body"] === "string" ? p["body"].trim() : ""; | |
| 217 | return { | |
| 218 | ...common, | |
| 219 | kind: "reply", | |
| 220 | link: `${base(repo)}/${noun}/${number}`, | |
| 221 | what: said === "" ? `a reply on #${number}` : `replied on #${number}: ${clip(said)}`, | |
| 222 | }; | |
| 223 | } | |
| 196 | 224 | case "issue.blocked": |
| 197 | 225 | case "issue.unblocked": |
| 198 | 226 | return { |
src/feed/rank.ts +3
| @@ -17,6 +17,8 @@ export interface FeedItem { | ||
| 17 | 17 | readonly actor: string | null; |
| 18 | 18 | readonly at: string; |
| 19 | 19 | readonly link: string; |
| 20 | /** What happened, in the post's own words. */ | |
| 21 | readonly what: string; | |
| 20 | 22 | /** One sentence: why this, and why here. */ |
| 21 | 23 | readonly reason: string; |
| 22 | 24 | readonly score: number; |
| @@ -135,6 +137,7 @@ export function rank( | ||
| 135 | 137 | actor: s!.c.actor, |
| 136 | 138 | at: s!.c.at, |
| 137 | 139 | link: s!.c.link, |
| 140 | what: s!.c.what, | |
| 138 | 141 | reason: s!.reason, |
| 139 | 142 | score: Math.round(bestScore * 1e6) / 1e6, |
| 140 | 143 | }); |
src/http/mcp.ts +26
| @@ -35,6 +35,7 @@ import { | ||
| 35 | 35 | USAGE_DAYS_MAX, |
| 36 | 36 | } from "../actions/usage.ts"; |
| 37 | 37 | import { ITEM_ID } from "../core/interactions.ts"; |
| 38 | import { FEED_LIMIT_DEFAULT, FEED_LIMIT_MAX, parseCursor, readFeed } from "../feed/feed.ts"; | |
| 38 | 39 | import { share } from "../feed/share.ts"; |
| 39 | 40 | import { parseTargets } from "./feed.ts"; |
| 40 | 41 | import { appsRuntime } from "../apps/runtime.ts"; |
| @@ -187,6 +188,31 @@ const TOOLS: readonly Tool[] = [ | ||
| 187 | 188 | }); |
| 188 | 189 | }, |
| 189 | 190 | }, |
| 191 | { | |
| 192 | name: "feed", | |
| 193 | description: | |
| 194 | "The home timeline, as the signed-in person sees it: tells, replies, runs, changes and looks, ranked, each with the sentence for why it is there and a link to its thing. Pass the cursor from one answer to get the next page.", | |
| 195 | inputSchema: { | |
| 196 | type: "object", | |
| 197 | properties: { | |
| 198 | limit: { type: "integer", minimum: 1, maximum: FEED_LIMIT_MAX }, | |
| 199 | cursor: { type: "string", description: "next_cursor from the last answer" }, | |
| 200 | }, | |
| 201 | }, | |
| 202 | writes: false, | |
| 203 | run(ctx, user, args) { | |
| 204 | const limit = args["limit"] === undefined ? FEED_LIMIT_DEFAULT : Number(args["limit"]); | |
| 205 | if (!Number.isInteger(limit) || limit < 1 || limit > FEED_LIMIT_MAX) | |
| 206 | return bad("invalid", `limit is 1 to ${FEED_LIMIT_MAX}`); | |
| 207 | const raw = args["cursor"]; | |
| 208 | const cursor = raw === undefined ? undefined : parseCursor(str(raw)); | |
| 209 | if (raw !== undefined && cursor === undefined) | |
| 210 | return bad("invalid", "that cursor was not issued here"); | |
| 211 | return good( | |
| 212 | readFeed(ctx.app.db, user, { limit, ...(cursor === undefined ? {} : { cursor }) }), | |
| 213 | ); | |
| 214 | }, | |
| 215 | }, | |
| 190 | 216 | { |
| 191 | 217 | name: "share", |
| 192 | 218 | description: |
src/web/pages/apps.ts +2 −1
| @@ -48,6 +48,7 @@ import { | ||
| 48 | 48 | import { field, readForm } from "../form.ts"; |
| 49 | 49 | import { html, when, type Html } from "../html.ts"; |
| 50 | 50 | import { flashTo, page, redirect } from "../layout.ts"; |
| 51 | import { costLine } from "../studio/cost_line.ts"; | |
| 51 | 52 | import { shelfRows } from "../studio/shelf.ts"; |
| 52 | 53 | import { |
| 53 | 54 | badge, |
| @@ -261,7 +262,7 @@ async function studioAppsList(ctx: Ctx): Promise<Response> { | ||
| 261 | 262 | shown.map((e) => e.repo), |
| 262 | 263 | ); |
| 263 | 264 | const body = html`${pageHead("Apps", { actions: create })} |
| 264 | ${filters} | |
| 265 | ${ctx.auth.user ? costLine(ctx, ctx.auth.user) : null} ${filters} | |
| 265 | 266 | ${shown.length === 0 |
| 266 | 267 | ? empty({ |
| 267 | 268 | icon: "rocket", |
src/web/pages/site.ts +1 −1
| @@ -582,7 +582,7 @@ export async function home(ctx: Ctx): Promise<Response> { | ||
| 582 | 582 | // the default: apps, the crew, what asks you; `?mode=dev` on the home is |
| 583 | 583 | // the escape hatch to the repositories, resolved once for `ctx.mode`. |
| 584 | 584 | if (user === undefined) return studioDoor(ctx); |
| 585 | if (ctx.mode === "studio") return await studioHome(ctx, user); | |
| 585 | if (ctx.mode === "studio") return studioHome(ctx, user); | |
| 586 | 586 | return page({ |
| 587 | 587 | ctx, |
| 588 | 588 | title: "forge", |
src/web/studio/cost_line.ts added +29
| @@ -0,0 +1,29 @@ | ||
| 1 | /** | |
| 2 | * The owner's first question, on the page of apps: what the crew cost today | |
| 3 | * across the apps they can write, and how many are paused at their ceiling. | |
| 4 | * One bounded read each (`spentTodayForRepos`, `crewForRepos`), never a query | |
| 5 | * per app. Every app counted is one the viewer can write, so the money is | |
| 6 | * only ever the owner's own. | |
| 7 | */ | |
| 8 | ||
| 9 | import { crewForRepos } from "../../core/agents.ts"; | |
| 10 | import type { User } from "../../core/users.ts"; | |
| 11 | import { isPausedAtCeiling, spentTodayForRepos } from "../../crew/autonomy.ts"; | |
| 12 | import type { Ctx } from "../../http/context.ts"; | |
| 13 | import { html, type Html } from "../html.ts"; | |
| 14 | import { writableAppsOf } from "./asks.ts"; | |
| 15 | ||
| 16 | export function costLine(ctx: Ctx, user: User): Html | null { | |
| 17 | const { repos } = writableAppsOf(ctx, user); | |
| 18 | if (repos.length === 0) return null; | |
| 19 | const ids = repos.map((r) => r.id); | |
| 20 | const spentToday = spentTodayForRepos(ctx.app.db, ids); | |
| 21 | const crew = crewForRepos(ctx.app.db, ids); | |
| 22 | const spentUsd = repos.reduce((sum, r) => sum + (spentToday.get(r.id) ?? 0), 0); | |
| 23 | const paused = repos.filter((r) => isPausedAtCeiling(r, crew, spentToday)).length; | |
| 24 | const noun = `app${repos.length === 1 ? "" : "s"}`; | |
| 25 | const sentence = `$${spentUsd.toFixed(2)} spent today across ${repos.length} ${noun} you can write`; | |
| 26 | return html`<p class="small muted studio-cost"> | |
| 27 | ${sentence} · ${paused} paused at <a href="/map">their ceiling</a> | |
| 28 | </p>`; | |
| 29 | } |
src/web/studio/feed.ts +43 −3
| @@ -14,11 +14,12 @@ import type { FeedItem } from "../../feed/rank.ts"; | ||
| 14 | 14 | import { html, type Html } from "../html.ts"; |
| 15 | 15 | import { fragment } from "../layout.ts"; |
| 16 | 16 | import { outboxJs } from "../outbox.ts"; |
| 17 | import { btn, empty } from "../ui.ts"; | |
| 17 | import { avatar, btn, empty } from "../ui.ts"; | |
| 18 | import { writableAppsOf } from "./asks.ts"; | |
| 18 | 19 | |
| 19 | 20 | /** Events that can change what the feed says. */ |
| 20 | 21 | export const FEED_LIVE = |
| 21 | "run.finished,pull.opened,pull.merged,pull.reviewed,pull.closed,look.taken,app.serving,issue.blocked,issue.unblocked,decision.*"; | |
| 22 | "run.finished,issue.opened,issue.commented,pull.commented,pull.opened,pull.merged,pull.reviewed,pull.closed,look.taken,app.serving,issue.blocked,issue.unblocked,decision.*"; | |
| 22 | 23 | |
| 23 | 24 | export const FEED_FIRST_PAGE = 20; |
| 24 | 25 | |
| @@ -31,6 +32,9 @@ const KIND_LABEL: Record<FeedItem["kind"], string> = { | ||
| 31 | 32 | decision: "Decision", |
| 32 | 33 | map: "Map", |
| 33 | 34 | cost: "Cost", |
| 35 | tell: "Told", | |
| 36 | reply: "Reply", | |
| 37 | look: "Look", | |
| 34 | 38 | }; |
| 35 | 39 | |
| 36 | 40 | /** One card. A run's card steers the run; every card can tell its app. */ |
| @@ -46,13 +50,16 @@ export function feedCard(item: FeedItem): Html { | ||
| 46 | 50 | data-kind="${item.kind}" |
| 47 | 51 | > |
| 48 | 52 | <div class="fcard-head"> |
| 53 | ${avatar(item.actor ?? item.app)} | |
| 54 | <strong class="fcard-who">${item.actor ?? item.app}</strong> | |
| 49 | 55 | <span class="badge">${KIND_LABEL[item.kind]}</span> |
| 50 | 56 | <span class="fcard-app muted small">${item.app}</span> |
| 51 | 57 | <span class="spacer"></span> |
| 52 | 58 | <button type="button" class="btn btn-sm btn-ghost" data-feed="dismissed" title="Dismiss (x)">Dismiss</button> |
| 53 | 59 | <button type="button" class="btn btn-sm btn-ghost" data-feed="muted" title="Mute ${item.app}">Mute app</button> |
| 54 | 60 | </div> |
| 55 | <p class="fcard-reason"><a href="${item.link}" data-feed-open>${item.reason}</a></p> | |
| 61 | <p class="fcard-reason"><a href="${item.link}" data-feed-open>${item.what}</a></p> | |
| 62 | <p class="fcard-why small muted">${item.reason}</p> | |
| 56 | 63 | <details class="fcard-say"> |
| 57 | 64 | <summary class="small">${target ? "Steer" : "Tell the crew"}</summary> |
| 58 | 65 | <form method="post" action="${target ?? `/${item.app}/tell`}" class="fcard-form"> |
| @@ -63,6 +70,27 @@ export function feedCard(item: FeedItem): Html { | ||
| 63 | 70 | </article>`; |
| 64 | 71 | } |
| 65 | 72 | |
| 73 | /** | |
| 74 | * The composer: say it to an app's crew, which opens a tell. The one primary | |
| 75 | * action on the home. With no app to say it to, the way to make one instead. | |
| 76 | * The script sends it through the outbox to `POST /api/v1/feed/tells`. | |
| 77 | */ | |
| 78 | export function composer(ctx: Ctx, user: User): Html { | |
| 79 | const { repos } = writableAppsOf(ctx, user); | |
| 80 | if (repos.length === 0) return html``; | |
| 81 | const slug = (r: { ownerName: string; name: string }) => `${r.ownerName}/${r.name}`; | |
| 82 | return html`<form id="composer" class="composer" method="post" action="/${slug(repos[0]!)}/tell"> | |
| 83 | <textarea name="text" rows="2" maxlength="2000" required placeholder="Tell the crew what should change" aria-label="Tell the crew"></textarea> | |
| 84 | <div class="composer-bar"> | |
| 85 | ${repos.length === 1 | |
| 86 | ? html`<input type="hidden" name="app" value="${slug(repos[0]!)}" /><span class="muted small">${slug(repos[0]!)}</span>` | |
| 87 | : html`<select name="app" aria-label="App">${repos.map((r) => html`<option value="${slug(r)}">${slug(r)}</option>`)}</select>`} | |
| 88 | <span class="spacer"></span> | |
| 89 | ${btn("Post", { variant: "primary" })} | |
| 90 | </div> | |
| 91 | </form>`; | |
| 92 | } | |
| 93 | ||
| 66 | 94 | /** |
| 67 | 95 | * One line above the feed, empty unless there is something to say: the feed |
| 68 | 96 | * on screen is old (the service worker served it with no network), or acts |
| @@ -180,6 +208,18 @@ ${outboxJs} | ||
| 180 | 208 | var d = form.closest('details'); |
| 181 | 209 | if (d) d.open = false; |
| 182 | 210 | }); |
| 211 | // The composer is a tell: kept and sent like the card's, the box clears at once. | |
| 212 | var composer = document.getElementById('composer'); | |
| 213 | if (composer) composer.addEventListener('submit', function (e) { | |
| 214 | var box = composer.elements.text; | |
| 215 | var app = composer.elements.app; | |
| 216 | var text = box.value.trim(); | |
| 217 | if (!text || !app) return; | |
| 218 | if (!queue('/api/v1/feed/tells', { app: app.value, text: text })) return; | |
| 219 | e.preventDefault(); | |
| 220 | box.value = ''; | |
| 221 | box.focus(); | |
| 222 | }); | |
| 183 | 223 | document.addEventListener('keydown', function (e) { |
| 184 | 224 | if (e.key !== 'x' || e.metaKey || e.ctrlKey || e.altKey) return; |
| 185 | 225 | var a = document.activeElement; |
src/web/studio/feed_style.ts +15
| @@ -6,10 +6,25 @@ export const feedCss = /* css */ ` | ||
| 6 | 6 | .fcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } |
| 7 | 7 | .fcard[hidden] { display: none; } |
| 8 | 8 | .fcard-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } |
| 9 | .fcard-who { font-weight: 600; } | |
| 10 | .composer { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; } | |
| 11 | .composer textarea { width: 100%; min-height: 64px; resize: vertical; } | |
| 12 | .composer-bar { display: flex; align-items: center; gap: 8px; } | |
| 13 | .home-tabs { display: none; } | |
| 14 | .home-apps { display: grid; gap: 6px; } | |
| 15 | .home-app { padding: 4px 0; } | |
| 16 | .fcard[data-kind="reply"] { margin-left: 16px; } | |
| 17 | .fcard-why { margin: 0 0 4px; } | |
| 9 | 18 | .fcard-reason { margin: 8px 0 4px; font-size: 1.05em; overflow-wrap: anywhere; } |
| 10 | 19 | .fcard-say summary { cursor: pointer; color: var(--muted-fg, inherit); padding: 4px 0; } |
| 11 | 20 | .fcard-form { display: grid; gap: 8px; margin-top: 6px; } |
| 12 | 21 | .fcard-form textarea { width: 100%; min-height: 56px; resize: vertical; } |
| 22 | @media (max-width: 700px) { | |
| 23 | .home-tabs { display: flex; gap: 16px; margin-bottom: 12px; } | |
| 24 | .home-tabs a { padding: 10px 0; border-bottom: 2px solid transparent; } | |
| 25 | .home-tabs a[aria-current] { border-color: var(--accent); font-weight: 600; } | |
| 26 | #live-apps { display: none; } | |
| 27 | } | |
| 13 | 28 | @media (max-width: 600px) { |
| 14 | 29 | .fcard { padding: 12px; } |
| 15 | 30 | .fcard-head .btn { padding: 8px 10px; } |
src/web/studio/home.ts +53 −108
| @@ -1,19 +1,15 @@ | ||
| 1 | 1 | /** |
| 2 | * The home in the studio: every app as a shelf | |
| 3 | * row (`shelf.ts` draws those — the row is not this page's to decide), and | |
| 4 | * beside it what is happening right now across all of them, and what a | |
| 5 | * person put on you. Built from the same rows and cards as the rest of the | |
| 6 | * forge, from grouped reads only, so the page does not get slower as the | |
| 7 | * apps grow. A stranger gets the door instead: the public apps, live first. | |
| 2 | * The home in the studio: one timeline (`feed.ts`) with a composer on top, | |
| 3 | * a narrow column of your apps beside it, and what a person put on you. | |
| 4 | * Grouped reads only, so the page does not get slower as the apps grow. A | |
| 5 | * stranger gets the door instead: the public apps, live first. | |
| 8 | 6 | */ |
| 9 | 7 | |
| 10 | 8 | import { appsRuntime, type EnvState } from "../../apps/runtime.ts"; |
| 11 | import { crewForRepos } from "../../core/agents.ts"; | |
| 12 | 9 | import { listPublicApps } from "../../core/apps.ts"; |
| 13 | 10 | import { DEFAULT_PAGE, LOOK_SIZES, looksForApps } from "../../core/looks.ts"; |
| 14 | import { getReposByIds, type Repo } from "../../core/repos.ts"; | |
| 11 | import { getReposByIds } from "../../core/repos.ts"; | |
| 15 | 12 | import { type User } from "../../core/users.ts"; |
| 16 | import { isPausedAtCeiling, spentTodayForRepos } from "../../crew/autonomy.ts"; | |
| 17 | 13 | import type { Ctx } from "../../http/context.ts"; |
| 18 | 14 | import { edgeLoginUrl } from "../../http/edge.ts"; |
| 19 | 15 | import { sshCommand } from "../../ssh/command.ts"; |
| @@ -22,74 +18,51 @@ import { liveRegionsJs } from "../client.ts"; | ||
| 22 | 18 | import { html, when, type Html } from "../html.ts"; |
| 23 | 19 | import { fragment, page } from "../layout.ts"; |
| 24 | 20 | import { liveClientJs } from "../live.ts"; |
| 25 | import { btn, empty, envStateBadge, icon, listCard } from "../ui.ts"; | |
| 21 | import { btn, empty, envStateBadge, icon } from "../ui.ts"; | |
| 26 | 22 | import { onYouCard } from "../pages/site.ts"; |
| 27 | 23 | import { lookUrl, pictured } from "../pages/looks.ts"; |
| 28 | 24 | import { writableAppsOf } from "./asks.ts"; |
| 29 | import { productionFactsForRepos, shelfRows } from "./shelf.ts"; | |
| 30 | import { servingHistory } from "./words.ts"; | |
| 31 | import { feedJs, feedNote, feedRegion } from "./feed.ts"; | |
| 25 | import { composer, feedJs, feedNote, feedRegion } from "./feed.ts"; | |
| 32 | 26 | |
| 33 | /** The events that can change a row on the shelf. */ | |
| 34 | const APPS_LIVE = | |
| 35 | "app.serving,app.stopped,run.queued,run.started,run.finished,pull.opened,pull.closed,pull.merged"; | |
| 27 | const APPS_SHOWN = 12; | |
| 28 | ||
| 29 | /** The events that can change the column of your apps. */ | |
| 30 | const APPS_LIVE = "app.serving,app.stopped,pull.merged"; | |
| 36 | 31 | /** The events that can change what is on you. */ |
| 37 | 32 | const ON_YOU_LIVE = |
| 38 | 33 | "issue.assigned,pull.assigned,issue.closed,pull.closed,issue.reopened,pull.reopened,pull.merged"; |
| 39 | 34 | |
| 40 | 35 | /** |
| 41 | * The shelf: every app the viewer can write, one row each. The front door | |
| 42 | * leads with what the viewer can write — their own apps and their | |
| 43 | * organisations' — never widened by a stranger's public app | |
| 44 | * (`writableAppsOf`, not the visibility every reader gets from `appsOf`). | |
| 36 | * "Your apps": one link each, a step away from the timeline — the apps the | |
| 37 | * viewer can write, never widened by a stranger's public app | |
| 38 | * (`writableAppsOf`). The page of apps itself is `/apps`. | |
| 45 | 39 | */ |
| 46 | async function shelf( | |
| 47 | ctx: Ctx, | |
| 48 | user: User, | |
| 49 | ): Promise<{ appRepos: readonly Repo[]; apps: Html }> { | |
| 50 | const { repos: appRepos } = writableAppsOf(ctx, user); | |
| 51 | // Read once, shown twice again: a shipped or failed deploy is a row's own | |
| 52 | // word, and — when nothing is running and no change waits — the rail's. | |
| 53 | const productionFacts = productionFactsForRepos(ctx, appRepos); | |
| 54 | // One memo of production's history for every word on this page: the | |
| 55 | // shelf's rows ask it once per repository. | |
| 56 | const history = servingHistory(); | |
| 57 | const appRows = await shelfRows(ctx, appRepos, { | |
| 58 | productionFacts, | |
| 59 | history, | |
| 60 | }); | |
| 61 | const apps = | |
| 62 | appRows.length === 0 | |
| 63 | ? empty({ | |
| 64 | icon: "rocket", | |
| 65 | title: "No apps yet", | |
| 66 | note: "Make one, tell the crew what it is, and watch it come up.", | |
| 67 | action: html`${btn("New app", { | |
| 68 | href: "/apps/new", | |
| 69 | variant: "primary", | |
| 70 | })} | |
| 71 | ${btn("Repositories", { href: "/?mode=dev" })}`, | |
| 72 | }) | |
| 73 | : listCard(appRows, { | |
| 74 | head: html`${icon("rocket")} | |
| 75 | <h2>Your apps</h2> | |
| 76 | <span class="spacer"></span> | |
| 77 | ${btn("Map", { href: "/map", size: "sm", icon: "map" })} | |
| 78 | ${btn("Audit", { href: "/audit", size: "sm", icon: "shield" })} | |
| 79 | ${btn("Board", { href: "/board", size: "sm", icon: "activity" })} | |
| 80 | ${btn("New app", { href: "/apps/new", size: "sm", icon: "plus" })}`, | |
| 81 | }); | |
| 82 | return { appRepos, apps }; | |
| 40 | function appsColumn(ctx: Ctx, user: User): Html { | |
| 41 | const { repos } = writableAppsOf(ctx, user); | |
| 42 | return repos.length === 0 | |
| 43 | ? empty({ | |
| 44 | icon: "rocket", | |
| 45 | title: "No apps yet", | |
| 46 | note: "Make one, tell the crew what it is, and watch it come up.", | |
| 47 | action: html`${btn("New app", { href: "/apps/new", variant: "primary" })} | |
| 48 | ${btn("Repositories", { href: "/?mode=dev" })}`, | |
| 49 | }) | |
| 50 | : html`<nav class="home-apps" aria-label="Your apps"> | |
| 51 | <h2 class="small muted">Your apps</h2> | |
| 52 | ${repos.slice(0, APPS_SHOWN).map( | |
| 53 | (r) => | |
| 54 | html`<a class="home-app truncate" href="${repoBase(r)}" | |
| 55 | >${r.name}</a | |
| 56 | >`, | |
| 57 | )} | |
| 58 | <a class="small" href="/apps">All apps</a> | |
| 59 | </nav>`; | |
| 83 | 60 | } |
| 84 | 61 | |
| 85 | /** | |
| 86 | * Each live region on the home has an address of its own (`data-live-src`), | |
| 87 | * so an event fetches that region — the shelf, or what is on you — and not | |
| 88 | * the page; the fragment answers with the same element, id and all. | |
| 89 | */ | |
| 90 | const appsRegion = (apps: Html): Html => | |
| 62 | /** Each live region has an address of its own (`data-live-src`). */ | |
| 63 | const appsRegion = (ctx: Ctx, user: User): Html => | |
| 91 | 64 | html`<div id="live-apps" data-live="${APPS_LIVE}" data-live-src="/live/apps"> |
| 92 | ${apps} | |
| 65 | ${appsColumn(ctx, user)} | |
| 93 | 66 | </div>`; |
| 94 | 67 | |
| 95 | 68 | const onYouRegion = (ctx: Ctx, user: User): Html => |
| @@ -101,12 +74,11 @@ const onYouRegion = (ctx: Ctx, user: User): Html => | ||
| 101 | 74 | ${onYouCard(ctx, user) ?? null} |
| 102 | 75 | </div>`; |
| 103 | 76 | |
| 104 | // GET /live/apps — the shelf alone, for the region that shows it. | |
| 105 | export async function liveAppsFragment(ctx: Ctx): Promise<Response> { | |
| 77 | // GET /live/apps — the column alone, for the region that shows it. | |
| 78 | export function liveAppsFragment(ctx: Ctx): Response { | |
| 106 | 79 | const user = ctx.auth.user; |
| 107 | 80 | if (!user) return fragment(html``, { status: 404 }); |
| 108 | const { apps } = await shelf(ctx, user); | |
| 109 | return fragment(appsRegion(apps), { request: ctx.request }); | |
| 81 | return fragment(appsRegion(ctx, user), { request: ctx.request }); | |
| 110 | 82 | } |
| 111 | 83 | |
| 112 | 84 | // GET /live/on-you — what is on the viewer, alone. |
| @@ -116,54 +88,27 @@ export function liveOnYouFragment(ctx: Ctx): Response { | ||
| 116 | 88 | return fragment(onYouRegion(ctx, user), { request: ctx.request }); |
| 117 | 89 | } |
| 118 | 90 | |
| 119 | export async function studioHome(ctx: Ctx, user: User): Promise<Response> { | |
| 120 | const db = ctx.app.db; | |
| 121 | const { appRepos, apps } = await shelf(ctx, user); | |
| 122 | ||
| 123 | // What the crew cost today across every app on the shelf, and how many | |
| 124 | // are paused at their ceiling right now — the owner's first question at | |
| 125 | // the front door, in one bounded read each (`spentTodayForRepos`, | |
| 126 | // `crewForRepos`), never a query or an `autonomyStatus` call per app. | |
| 127 | // Every app here is already one the viewer can write, so no further | |
| 128 | // filter is needed to keep the money to the owner's own. | |
| 129 | const costLine = when(appRepos.length > 0, () => { | |
| 130 | const spentToday = spentTodayForRepos( | |
| 131 | db, | |
| 132 | appRepos.map((r) => r.id), | |
| 133 | ); | |
| 134 | const crew = crewForRepos( | |
| 135 | db, | |
| 136 | appRepos.map((r) => r.id), | |
| 137 | ); | |
| 138 | const spentUsd = appRepos.reduce( | |
| 139 | (sum, r) => sum + (spentToday.get(r.id) ?? 0), | |
| 140 | 0, | |
| 141 | ); | |
| 142 | const paused = appRepos.filter((r) => | |
| 143 | isPausedAtCeiling(r, crew, spentToday), | |
| 144 | ).length; | |
| 145 | const noun = `app${appRepos.length === 1 ? "" : "s"}`; | |
| 146 | const sentence = `$${spentUsd.toFixed(2)} spent today across ${appRepos.length} ${noun} you can write`; | |
| 147 | return html`<p class="small muted studio-cost"> | |
| 148 | ${sentence} · ${paused} paused at <a href="/map">their ceiling</a> | |
| 149 | </p>`; | |
| 150 | }); | |
| 151 | ||
| 152 | const body = html`<h1 class="sr-only">Studio</h1> | |
| 153 | ${costLine} | |
| 91 | /** | |
| 92 | * Signed in, home is the timeline: the composer, then the feed. Your apps | |
| 93 | * are a narrow column on a desk and a tab on a phone, one step away. | |
| 94 | */ | |
| 95 | export function studioHome(ctx: Ctx, user: User): Response { | |
| 96 | const body = html`<h1 class="sr-only">Home</h1> | |
| 97 | <nav class="home-tabs" aria-label="Home"> | |
| 98 | <a href="/" aria-current="page">Feed</a> | |
| 99 | <a href="/apps">Your apps</a> | |
| 100 | </nav> | |
| 154 | 101 | <div class="dash"> |
| 155 | 102 | <div class="dash-main stack"> |
| 156 | ${feedNote()} | |
| 157 | ${feedRegion(user, ctx)} | |
| 158 | ${appsRegion(apps)} | |
| 103 | ${composer(ctx, user)} ${feedNote()} ${feedRegion(user, ctx)} | |
| 159 | 104 | </div> |
| 160 | 105 | <aside class="dash-rail stack"> |
| 161 | ${onYouRegion(ctx, user)} | |
| 106 | ${appsRegion(ctx, user)} ${onYouRegion(ctx, user)} | |
| 162 | 107 | </aside> |
| 163 | 108 | </div>`; |
| 164 | 109 | return page({ |
| 165 | 110 | ctx, |
| 166 | title: "Studio", | |
| 111 | title: "Home", | |
| 167 | 112 | body, |
| 168 | 113 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${feedJs}`, |
| 169 | 114 | }); |
test/feed-page.test.ts +36
| @@ -13,6 +13,8 @@ import { createSession } from "../src/core/sessions.ts"; | ||
| 13 | 13 | import type { Repo } from "../src/core/repos.ts"; |
| 14 | 14 | import { createUser, type User } from "../src/core/users.ts"; |
| 15 | 15 | import { serve, type Servers } from "../src/http/server.ts"; |
| 16 | import { openIssue, addCommentThrough } from "../src/actions/issues.ts"; | |
| 17 | import { createApp as insertApp } from "../src/core/apps.ts"; | |
| 16 | 18 | import { readFeed } from "../src/feed/feed.ts"; |
| 17 | 19 | import { feedCard } from "../src/web/studio/feed.ts"; |
| 18 | 20 | |
| @@ -105,11 +107,13 @@ describe("the feed on the home page", () => { | ||
| 105 | 107 | actor: null, |
| 106 | 108 | at: new Date().toISOString(), |
| 107 | 109 | link: "/a/b/runs/r", |
| 110 | what: "<i>y</i>", | |
| 108 | 111 | reason: "<b>x</b>", |
| 109 | 112 | score: 1, |
| 110 | 113 | }).text; |
| 111 | 114 | expect(card).not.toContain("<img"); |
| 112 | 115 | expect(card).not.toContain("<b>x</b>"); |
| 116 | expect(card).not.toContain("<i>y</i>"); | |
| 113 | 117 | }); |
| 114 | 118 | |
| 115 | 119 | test("a viewer sees only their own feed: no leak from a private app", async () => { |
| @@ -149,4 +153,36 @@ describe("the feed on the home page", () => { | ||
| 149 | 153 | expect(text).toContain("data-nav"); |
| 150 | 154 | expect(text).toContain("/api/v1/feed/interactions"); |
| 151 | 155 | }); |
| 156 | ||
| 157 | test("home is a composer above the timeline of tells and replies, apps one step away", async () => { | |
| 158 | const rec = insertApp(app.db, { repoId: open.id, slug: "open", access: "public" }); | |
| 159 | if (!rec.ok) throw new Error(rec.error); | |
| 160 | const made = openIssue(app, alice, open, { title: "Add dark mode" }); | |
| 161 | if (!made.ok) throw new Error(made.error); | |
| 162 | const said = await addCommentThrough(app, alice, open, made.value, "I think blue"); | |
| 163 | if (!said.ok) throw new Error(JSON.stringify(said.error)); | |
| 164 | ||
| 165 | const text = await (await get("/", aliceCookie)).text(); | |
| 166 | expect(text).toContain('id="composer"'); | |
| 167 | expect(text.indexOf('id="composer"')).toBeLessThan(text.indexOf('id="live-feed"')); | |
| 168 | expect(text).toContain('href="/alice/open/issues/1"'); | |
| 169 | expect(text).toContain("Add dark mode"); | |
| 170 | expect(text).toContain("replied on #1: I think blue"); | |
| 171 | expect(text).toContain('data-kind="tell"'); | |
| 172 | expect(text).toContain('data-kind="reply"'); | |
| 173 | expect(text).toContain('href="/apps"'); | |
| 174 | expect(text).toContain("Your apps"); | |
| 175 | ||
| 176 | // Someone with no app has no composer to say anything with. | |
| 177 | expect(await (await get("/", bobCookie)).text()).not.toContain('id="composer"'); | |
| 178 | }); | |
| 179 | ||
| 180 | test("the composer's tell goes through the feed API and opens an issue", async () => { | |
| 181 | const res = await fetch(`${servers.url}/api/v1/feed/tells`, { | |
| 182 | method: "POST", | |
| 183 | headers: { cookie: aliceCookie, origin: servers.url, "content-type": "application/json" }, | |
| 184 | body: JSON.stringify({ app: "alice/open", text: "Make the logo bigger" }), | |
| 185 | }); | |
| 186 | expect(res.status).toBe(201); | |
| 187 | }); | |
| 152 | 188 | }); |
test/mcp.test.ts +18
| @@ -8,6 +8,7 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | ||
| 8 | 8 | import { mkdtemp, rm } from "node:fs/promises"; |
| 9 | 9 | import { tmpdir } from "node:os"; |
| 10 | 10 | import { join } from "node:path"; |
| 11 | import { readFeed } from "../src/feed/feed.ts"; | |
| 11 | 12 | import { createApp, type App } from "../src/app.ts"; |
| 12 | 13 | import { addToCrew, createAgent } from "../src/actions/crew.ts"; |
| 13 | 14 | import { commitToBranch, createRepo, forkRepo } from "../src/actions/repos.ts"; |
| @@ -156,6 +157,7 @@ describe("the forge over MCP", () => { | ||
| 156 | 157 | expect(names).toEqual([ |
| 157 | 158 | "apps", |
| 158 | 159 | "tell", |
| 160 | "feed", | |
| 159 | 161 | "share", |
| 160 | 162 | "say", |
| 161 | 163 | "now", |
| @@ -184,6 +186,22 @@ describe("the forge over MCP", () => { | ||
| 184 | 186 | ).toBe(-32602); |
| 185 | 187 | }); |
| 186 | 188 | |
| 189 | test("feed returns the posts the home shows, a page at a time", async () => { | |
| 190 | app.bus.append({ kind: "run.finished", repoId: game.id, actorId: alice.id, payload: { kind: "check", state: "ok", runId: "r1" } }); | |
| 191 | app.bus.append({ kind: "run.finished", repoId: game.id, actorId: alice.id, payload: { kind: "check", state: "ok", runId: "r2" } }); | |
| 192 | const all = await tool(ro, "feed"); | |
| 193 | expect(all.value.items.map((i: { id: string }) => i.id)).toEqual(readFeed(app.db, alice).items.map((i) => i.id)); | |
| 194 | expect(all.value.items.length).toBeGreaterThan(1); | |
| 195 | const first = await tool(ro, "feed", { limit: 1 }); | |
| 196 | expect(first.value.items).toHaveLength(1); | |
| 197 | expect(first.value.next_cursor).not.toBeNull(); | |
| 198 | const second = await tool(ro, "feed", { limit: 1, cursor: first.value.next_cursor }); | |
| 199 | expect(second.value.items[0].id).toBe(all.value.items[1].id); | |
| 200 | expect((await tool(ro, "feed", { limit: 0 })).error).toBeDefined(); | |
| 201 | expect((await tool(ro, "feed", { cursor: "nope" })).error).toBeDefined(); | |
| 202 | expect((await tool(bobRw, "feed")).value.items).toEqual([]); | |
| 203 | }); | |
| 204 | ||
| 187 | 205 | test("apps and now read what the studio reads", async () => { |
| 188 | 206 | const apps = await tool(ro, "apps"); |
| 189 | 207 | expect(apps.value).toHaveLength(1); |
test/studio.test.ts +23 −17
| @@ -211,7 +211,7 @@ describe("the studio", () => { | ||
| 211 | 211 | * move the page. |
| 212 | 212 | */ |
| 213 | 213 | test("an app is one row on the shelf: a dot, its name and line, what the crew last did, the way in", async () => { |
| 214 | const home = await (await get("/")).text(); | |
| 214 | const home = await (await get("/apps")).text(); | |
| 215 | 215 | const at = home.indexOf('href="/alice/notes"'); |
| 216 | 216 | expect(at).toBeGreaterThan(-1); |
| 217 | 217 | const start = home.lastIndexOf("<li>", at); |
| @@ -228,7 +228,7 @@ describe("the studio", () => { | ||
| 228 | 228 | expect(long.length).toBeGreaterThanOrEqual(399); |
| 229 | 229 | app.db.run("UPDATE repo SET description = ?1 WHERE id = ?2", [long, repo.id]); |
| 230 | 230 | try { |
| 231 | const home = await (await get("/")).text(); | |
| 231 | const home = await (await get("/apps")).text(); | |
| 232 | 232 | const at = home.indexOf('href="/alice/notes"'); |
| 233 | 233 | const shelfRow = home.slice(home.lastIndexOf("<li>", at), home.indexOf("</li>", at)); |
| 234 | 234 | expect(shelfRow).toContain(`title="${long}"`); |
| @@ -2272,15 +2272,21 @@ describe("the studio home keeps itself current", () => { | ||
| 2272 | 2272 | expect(home).not.toContain("Write the README"); |
| 2273 | 2273 | }); |
| 2274 | 2274 | |
| 2275 | // On you alone: the timeline names the issue too, as the tell it was. | |
| 2276 | const onYou = () => | |
| 2277 | fetch(`${base}/live/on-you`, { | |
| 2278 | headers: { cookie: `${cookie}; forge_mode=studio` }, | |
| 2279 | }); | |
| 2280 | ||
| 2275 | 2281 | test("a card leaves On you once its issue closes", async () => { |
| 2276 | const before = await (await get()).text(); | |
| 2282 | const before = await (await onYou()).text(); | |
| 2277 | 2283 | expect(before).toContain("Write the README"); |
| 2278 | 2284 | |
| 2279 | 2285 | const merged = await mergePull(app, alice, repo, pull, "squash"); |
| 2280 | 2286 | expect(merged.ok).toBe(true); |
| 2281 | 2287 | expect(setIssueState(app, alice, repo, readme, "closed").ok).toBe(true); |
| 2282 | 2288 | |
| 2283 | const after = await (await get()).text(); | |
| 2289 | const after = await (await onYou()).text(); | |
| 2284 | 2290 | expect(after).not.toContain("Write the README"); |
| 2285 | 2291 | }); |
| 2286 | 2292 | }); |
| @@ -2310,7 +2316,7 @@ describe("the studio head says why the app is not up", () => { | ||
| 2310 | 2316 | /** The home's own shelf row for this app — the badge issue #201 is about. */ |
| 2311 | 2317 | const shelfBadge = async (cookie: string): Promise<string> => { |
| 2312 | 2318 | const home = await ( |
| 2313 | await fetch(`${base}/`, { | |
| 2319 | await fetch(`${base}/apps`, { | |
| 2314 | 2320 | headers: { cookie: `${cookie}; forge_mode=studio` }, |
| 2315 | 2321 | redirect: "manual", |
| 2316 | 2322 | }) |
| @@ -4693,7 +4699,7 @@ describe('a tell nobody on the crew can take is not "quiet"', () => { | ||
| 4693 | 4699 | }); |
| 4694 | 4700 | |
| 4695 | 4701 | test('the shelf row for that app is not "quiet"', async () => { |
| 4696 | const home = await (await get("/")).text(); | |
| 4702 | const home = await (await get("/apps")).text(); | |
| 4697 | 4703 | const at = home.indexOf('href="/alice/pad"'); |
| 4698 | 4704 | expect(at).toBeGreaterThan(-1); |
| 4699 | 4705 | const start = home.lastIndexOf("<li>", at); |
| @@ -4957,7 +4963,7 @@ describe("an open change is never quiet on the front door", () => { | ||
| 4957 | 4963 | }); |
| 4958 | 4964 | |
| 4959 | 4965 | test("the shelf row carries the change's own word, its badge and dot kept", async () => { |
| 4960 | const home = await (await get("/")).text(); | |
| 4966 | const home = await (await get("/apps")).text(); | |
| 4961 | 4967 | const at = home.indexOf('href="/alice/pad"'); |
| 4962 | 4968 | expect(at).toBeGreaterThan(-1); |
| 4963 | 4969 | const start = home.lastIndexOf("<li>", at); |
| @@ -4969,7 +4975,7 @@ describe("an open change is never quiet on the front door", () => { | ||
| 4969 | 4975 | }); |
| 4970 | 4976 | |
| 4971 | 4977 | test("an app with nothing open still reads quiet", async () => { |
| 4972 | const home = await (await get("/")).text(); | |
| 4978 | const home = await (await get("/apps")).text(); | |
| 4973 | 4979 | const at = home.indexOf('href="/alice/quiet"'); |
| 4974 | 4980 | expect(at).toBeGreaterThan(-1); |
| 4975 | 4981 | const start = home.lastIndexOf("<li>", at); |
| @@ -5137,7 +5143,7 @@ describe("a deploy that just landed is news on the front door", () => { | ||
| 5137 | 5143 | }); |
| 5138 | 5144 | |
| 5139 | 5145 | test("the shelf row reads shipped, with who and when, not quiet", async () => { |
| 5140 | const home = await (await get("/")).text(); | |
| 5146 | const home = await (await get("/apps")).text(); | |
| 5141 | 5147 | const shelfRow = shelfRowFor(home, "/alice/sap"); |
| 5142 | 5148 | expect(shelfRow).not.toContain("quiet — tell the crew something"); |
| 5143 | 5149 | expect(shelfRow).toContain('data-word="shipped"'); |
| @@ -5145,7 +5151,7 @@ describe("a deploy that just landed is news on the front door", () => { | ||
| 5145 | 5151 | }); |
| 5146 | 5152 | |
| 5147 | 5153 | test("an app with no recent deploy still reads quiet", async () => { |
| 5148 | const home = await (await get("/")).text(); | |
| 5154 | const home = await (await get("/apps")).text(); | |
| 5149 | 5155 | const shelfRow = shelfRowFor(home, `/alice/${quietRepo.name}`); |
| 5150 | 5156 | expect(shelfRow).toContain("quiet — tell the crew something"); |
| 5151 | 5157 | }); |
| @@ -5164,7 +5170,7 @@ describe("a deploy that just landed is news on the front door", () => { | ||
| 5164 | 5170 | manifest: { tty: null }, |
| 5165 | 5171 | }, |
| 5166 | 5172 | }); |
| 5167 | const home = await (await get("/")).text(); | |
| 5173 | const home = await (await get("/apps")).text(); | |
| 5168 | 5174 | const shelfRow = shelfRowFor(home, "/alice/sap"); |
| 5169 | 5175 | expect(shelfRow).not.toContain('data-word="shipped"'); |
| 5170 | 5176 | expect(shelfRow).toContain("quiet — tell the crew something"); |
| @@ -5183,7 +5189,7 @@ describe("a deploy that just landed is news on the front door", () => { | ||
| 5183 | 5189 | manifest: { tty: null }, |
| 5184 | 5190 | }, |
| 5185 | 5191 | }); |
| 5186 | const home = await (await get("/")).text(); | |
| 5192 | const home = await (await get("/apps")).text(); | |
| 5187 | 5193 | const shelfRow = shelfRowFor(home, "/alice/sap"); |
| 5188 | 5194 | expect(shelfRow).not.toContain('data-word="shipped"'); |
| 5189 | 5195 | expect(shelfRow).toContain("quiet — tell the crew something"); |
| @@ -5452,10 +5458,10 @@ describe("a stranger sees the app, not the owner's books", () => { | ||
| 5452 | 5458 | }); |
| 5453 | 5459 | |
| 5454 | 5460 | test("the studio home names the crew for the owner, but only 'the crew' for a signed-in reader of the same public app", async () => { |
| 5455 | const asStranger = await (await get("/", strangerCookie)).text(); | |
| 5461 | const asStranger = await (await get("/apps", strangerCookie)).text(); | |
| 5456 | 5462 | expect(asStranger).not.toContain("keeper"); |
| 5457 | 5463 | expect(asStranger).toContain("beacon"); |
| 5458 | const asOwner = await (await get("/", ownerCookie)).text(); | |
| 5464 | const asOwner = await (await get("/apps", ownerCookie)).text(); | |
| 5459 | 5465 | expect(asOwner).toContain("keeper"); |
| 5460 | 5466 | expect(asOwner).toContain("beacon"); |
| 5461 | 5467 | }); |
| @@ -7427,7 +7433,7 @@ describe("the studio home says what the crew cost you today", () => { | ||
| 7427 | 7433 | ).split(";")[0]!; |
| 7428 | 7434 | |
| 7429 | 7435 | const home = (cookie: string) => |
| 7430 | fetch(`${base}/`, { | |
| 7436 | fetch(`${base}/apps`, { | |
| 7431 | 7437 | headers: { cookie: `${cookie}; forge_mode=studio` }, |
| 7432 | 7438 | redirect: "manual", |
| 7433 | 7439 | }).then((r) => r.text()); |
| @@ -7673,7 +7679,7 @@ describe("every studio page's headings form one outline", () => { | ||
| 7673 | 7679 | const outline = headingOutline(html); |
| 7674 | 7680 | expect(outline.levels.filter((l) => l === 1).length).toBe(1); |
| 7675 | 7681 | expect(outline.ok).toBe(true); |
| 7676 | expect(html).toMatch(/<h1 class="sr-only">Studio<\/h1>/); | |
| 7682 | expect(html).toMatch(/<h1 class="sr-only">Home<\/h1>/); | |
| 7677 | 7683 | }); |
| 7678 | 7684 | |
| 7679 | 7685 | test("the app page, the three lists, a tell, a change and a run each have one outline with no skipped level", async () => { |
| @@ -8462,7 +8468,7 @@ describe("the studio can change what an app says it is (#230)", () => { | ||
| 8462 | 8468 | const appHead = await (await get("/alice/lamp/app", ownerCookie)).text(); |
| 8463 | 8469 | expect(appHead).toContain("Private"); |
| 8464 | 8470 | |
| 8465 | const shelf = await (await get("/", ownerCookie)).text(); | |
| 8471 | const shelf = await (await get("/apps", ownerCookie)).text(); | |
| 8466 | 8472 | expect(shelf).toContain("a lamp that stays lit all night"); |
| 8467 | 8473 | |
| 8468 | 8474 | const list = await (await get("/apps", ownerCookie)).text(); |
new above
offline