Public: anyone can read this; the crew can change it.
On you and Needs you become one list on the home with one count in the top bar, the same rows /live/on-you and MCP count #1937
scout/forge:scout/1826-on-you-and-needs-you-become-one-list-on → main 2 commits fork
12 files
changed +299
−200
scripts/gate.ts +1
| @@ -196,6 +196,7 @@ export const GATE: readonly string[] = [ | ||
| 196 | 196 | "test/review-wait.test.ts", |
| 197 | 197 | "test/asks-bulk.test.ts", |
| 198 | 198 | "test/asks-waiting-for.test.ts", |
| 199 | "test/asks-one-list.test.ts", | |
| 199 | 200 | "test/hand-decider.test.ts", |
| 200 | 201 | "test/decisions-by-doors.test.ts", |
| 201 | 202 | "test/standing-rule.test.ts", |
src/core/waiting_for.ts +1 −1
| @@ -18,7 +18,7 @@ export interface WaitingFor { | ||
| 18 | 18 | |
| 19 | 19 | export interface WaitFacts { |
| 20 | 20 | /** The ask's kind (`DecisionKind`). */ |
| 21 | readonly kind: "stopped" | "look" | "review" | "paused" | "parked" | "declined" | "handover"; | |
| 21 | readonly kind: "stopped" | "look" | "review" | "paused" | "parked" | "declined" | "handover" | "assigned"; | |
| 22 | 22 | /** Files stopping the pull from merging, as the last sweep found it. */ |
| 23 | 23 | readonly conflicts: number; |
| 24 | 24 | /** Whether the pull or issue the ask is about is assigned to the viewer. */ |
src/feed/feed.ts +11 −2
| @@ -33,7 +33,13 @@ export function parseCursor( | ||
| 33 | 33 | export function readFeed( |
| 34 | 34 | db: Database, |
| 35 | 35 | viewer: User, |
| 36 | options: { limit?: number; cursor?: { score: number; id: string }; now?: number } = {}, | |
| 36 | options: { | |
| 37 | limit?: number; | |
| 38 | cursor?: { score: number; id: string }; | |
| 39 | now?: number; | |
| 40 | /** The home pins asks above the feed: they must not fill its page. */ | |
| 41 | withoutAsks?: boolean; | |
| 42 | } = {}, | |
| 37 | 43 | ): { items: FeedItem[]; next_cursor: string | null } { |
| 38 | 44 | const now = options.now ?? Date.now(); |
| 39 | 45 | const limit = Math.min(options.limit ?? FEED_LIMIT_DEFAULT, FEED_LIMIT_MAX); |
| @@ -59,7 +65,10 @@ export function readFeed( | ||
| 59 | 65 | c.kind === "choose" || |
| 60 | 66 | !muted.has(c.repoId)), |
| 61 | 67 | ); |
| 62 | let ranked = rank(candidates, affinityFor(db, viewer, now), now); | |
| 68 | let ranked = rank( | |
| 69 | options.withoutAsks === true ? candidates.filter((c) => c.kind !== "ask") : candidates, affinityFor(db, viewer, now), | |
| 70 | now, | |
| 71 | ); | |
| 63 | 72 | const cursor = options.cursor; |
| 64 | 73 | if (cursor) { |
| 65 | 74 | const at = ranked.findIndex((i) => i.id === cursor.id); |
src/web/pages/site.ts +2 −120
| @@ -9,32 +9,21 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | import { limitValue } from "../../settings/limits.ts"; |
| 12 | import { mayView } from "../../core/sealed.ts"; | |
| 13 | 12 | import { signOutHere } from "../../actions/signins.ts"; |
| 14 | 13 | import { clientAddress } from "../../http/peer.ts"; |
| 15 | 14 | import { verifyEmail } from "../../actions/verify.ts"; |
| 16 | 15 | import { STRANGER_MAX } from "../../http/limits.ts"; |
| 17 | 16 | import { createRepo } from "../../actions/repos.ts"; |
| 18 | 17 | import { HUMAN_CHECK_MESSAGE, signUp } from "../../actions/users.ts"; |
| 19 | import { listAssignedTo, type Issue } from "../../core/issues.ts"; | |
| 20 | import { joinMany } from "../../core/pulls.ts"; | |
| 21 | import { conflictsOf } from "../../crew/stale_asks.ts"; | |
| 22 | 18 | import { accessAllows, listOrgsForUser, orgAccess } from "../../core/orgs.ts"; |
| 23 | 19 | import { listPins } from "../../core/pins.ts"; |
| 24 | import { | |
| 25 | canRead, | |
| 26 | getReposByIds, | |
| 27 | listReposVisibleTo, | |
| 28 | type Repo, | |
| 29 | } from "../../core/repos.ts"; | |
| 20 | import { getReposByIds } from "../../core/repos.ts"; | |
| 30 | 21 | import { createSession } from "../../core/sessions.ts"; |
| 31 | 22 | import { hasAnyUser, verifyPassword, type User } from "../../core/users.ts"; |
| 32 | 23 | import { isThemeName } from "../../design/themes.ts"; |
| 33 | 24 | import { cookieValue, crossOrigin, type Ctx } from "../../http/context.ts"; |
| 34 | 25 | import { studioDoor, studioHome } from "../studio/home.ts"; |
| 35 | import { homeTop, onYouBulk } from "../studio/asks_page.ts"; | |
| 36 | import { latestUndoable } from "../../actions/asks_bulk.ts"; | |
| 37 | import { mutedRepos } from "../../core/interactions.ts"; | |
| 26 | import { homeTop } from "../studio/asks_page.ts"; | |
| 38 | 27 | import { edgeLoginUrl } from "../../http/edge.ts"; |
| 39 | 28 | import { sshCommand } from "../../ssh/command.ts"; |
| 40 | 29 | import { hostOf, pageHead, signInFirst } from "../chrome.ts"; |
| @@ -52,7 +41,6 @@ import { | ||
| 52 | 41 | listCard, |
| 53 | 42 | row, |
| 54 | 43 | selectField, |
| 55 | time, | |
| 56 | 44 | } from "../ui.ts"; |
| 57 | 45 | import { existsSync } from "node:fs"; |
| 58 | 46 | import { join } from "node:path"; |
| @@ -176,112 +164,6 @@ export function downloadsCard(ctx: Ctx, user: User): Html { | ||
| 176 | 164 | ); |
| 177 | 165 | } |
| 178 | 166 | |
| 179 | const threadPath = (repo: Repo, issue: Issue): string => | |
| 180 | `/${repo.ownerName}/${repo.name}/${issue.kind === "pull" ? "pulls" : "issues"}/${issue.number}`; | |
| 181 | ||
| 182 | /** Open issues and pulls assigned to the viewer, anywhere they can see. */ | |
| 183 | export function onYouCard(ctx: Ctx, user: User): Html | undefined { | |
| 184 | const db = ctx.app.db; | |
| 185 | const assigned = listAssignedTo(db, user.id, 20); | |
| 186 | if (assigned.length === 0) return undefined; | |
| 187 | const repos = getReposByIds( | |
| 188 | db, | |
| 189 | assigned.map((issue) => issue.repoId), | |
| 190 | ); | |
| 191 | // `listAssignedTo` has no visibility filter of its own (an assignment can | |
| 192 | // outlive the access that made it), so each repo needs a real `canRead`. | |
| 193 | // Checking it straight would cost one query per row for any repo the | |
| 194 | // viewer does not own outright — `canRead` resolves org ownership from | |
| 195 | // the database. `listReposVisibleTo` answers the common case with one | |
| 196 | // query for the whole page; `canRead` only runs for the rare repo it | |
| 197 | // did not reach (its own cap), so the cost stays flat as rows grow. | |
| 198 | const visible = new Set( | |
| 199 | listReposVisibleTo(db, user, { limit: 200 }).map((repo) => repo.id), | |
| 200 | ); | |
| 201 | const muted = mutedRepos(db, user.id); | |
| 202 | const shown: { issue: Issue; repo: Repo }[] = []; | |
| 203 | // Muted repositories that hold work assigned to the viewer: said, never silent. | |
| 204 | const silenced = new Map<string, Repo>(); | |
| 205 | for (const issue of assigned) { | |
| 206 | const repo = repos.get(issue.repoId); | |
| 207 | if (!repo) continue; | |
| 208 | if (!visible.has(repo.id) && !canRead(db, repo, user)) continue; | |
| 209 | if (!mayView(db, repo, issue, user)) continue; | |
| 210 | if (muted.has(repo.id)) { | |
| 211 | silenced.set(repo.id, repo); | |
| 212 | continue; | |
| 213 | } | |
| 214 | shown.push({ issue, repo }); | |
| 215 | } | |
| 216 | // Two or more can be given one move: a box each, and one form for the set. | |
| 217 | const bulk = shown.length >= 2; | |
| 218 | const heads = new Map( | |
| 219 | joinMany( | |
| 220 | db, | |
| 221 | shown.map((s) => s.issue).filter((i) => i.kind === "pull"), | |
| 222 | ).map((p) => [p.id, p.headOid]), | |
| 223 | ); | |
| 224 | const rows = shown.map(({ issue, repo }) => { | |
| 225 | // A pull the last sweep found unable to merge is never shown as ready. | |
| 226 | const conflicts = conflictsOf(db, issue.id, heads.get(issue.id) ?? ""); | |
| 227 | return row({ | |
| 228 | ...(bulk ? {} : { href: threadPath(repo, issue), nav: true as const }), | |
| 229 | state: "open", | |
| 230 | lead: bulk | |
| 231 | ? html`<input | |
| 232 | type="checkbox" | |
| 233 | class="ask-pick" | |
| 234 | name="item" | |
| 235 | value="issue:${issue.id}" | |
| 236 | form="onyou-bulk" | |
| 237 | data-repo="${repo.id}" | |
| 238 | data-kind="${issue.kind}" | |
| 239 | aria-label="Select ${issue.title}" | |
| 240 | />` | |
| 241 | : icon(issue.kind === "pull" ? "pull" : "issue"), | |
| 242 | title: bulk | |
| 243 | ? html`<a href="${threadPath(repo, issue)}">${issue.title}</a>` | |
| 244 | : issue.title, | |
| 245 | titleAttr: issue.title, | |
| 246 | meta: html`${repo.ownerName}/${repo.name} #${issue.number} · updated | |
| 247 | ${time(issue.updatedAt)}${conflicts > 0 | |
| 248 | ? html` · <span class="conflicts">Conflicts in ${conflicts} | |
| 249 | ${conflicts === 1 ? "file" : "files"}</span>` | |
| 250 | : null}`, | |
| 251 | }); | |
| 252 | }); | |
| 253 | if (rows.length === 0 && silenced.size === 0) return undefined; | |
| 254 | const last = latestUndoable(ctx.app, user); | |
| 255 | const byKind = [...new Set(shown.map((s) => s.issue.kind))].map((k) => ({ | |
| 256 | id: k, | |
| 257 | label: k === "pull" ? "Pulls" : "Issues", | |
| 258 | })); | |
| 259 | const byRepo = [...new Map(shown.map((s) => [s.repo.id, s.repo])).values()].map( | |
| 260 | (r) => ({ id: r.id, label: `${r.ownerName}/${r.name}` }), | |
| 261 | ); | |
| 262 | return listCard(rows, { | |
| 263 | head: html`${icon("user")} | |
| 264 | <h2>On you</h2>`, | |
| 265 | ...(bulk || last !== undefined || silenced.size > 0 | |
| 266 | ? { | |
| 267 | foot: onYouBulk( | |
| 268 | byKind, | |
| 269 | byRepo, | |
| 270 | last === undefined | |
| 271 | ? undefined | |
| 272 | : { | |
| 273 | id: last.id, | |
| 274 | verb: last.verb, | |
| 275 | done: last.rows.filter((r) => r.outcome === "ok").length, | |
| 276 | }, | |
| 277 | bulk, | |
| 278 | [...silenced.values()].map((r) => ({ id: r.id, label: `${r.ownerName}/${r.name}` })), | |
| 279 | ), | |
| 280 | } | |
| 281 | : {}), | |
| 282 | }); | |
| 283 | } | |
| 284 | ||
| 285 | 167 | export function orgsCard(ctx: Ctx, user: User): Html { |
| 286 | 168 | const orgs = listOrgsForUser(ctx.app.db, user.id); |
| 287 | 169 | // A new one is the "+" menu's; with none, there is nothing to show. |
src/web/studio/asks.ts +70 −4
| @@ -27,6 +27,7 @@ import { | ||
| 27 | 27 | listOpenPullsVisibleTo, |
| 28 | 28 | type Issue, |
| 29 | 29 | } from "../../core/issues.ts"; |
| 30 | import { mayView } from "../../core/sealed.ts"; | |
| 30 | 31 | import { looksForApps } from "../../core/looks.ts"; |
| 31 | 32 | import { closesFromBody, getPull, joinMany, type Pull } from "../../core/pulls.ts"; |
| 32 | 33 | import { |
| @@ -102,7 +103,7 @@ export function writableAppsOf(ctx: Ctx, user: User | undefined) { | ||
| 102 | 103 | ); |
| 103 | 104 | } |
| 104 | 105 | |
| 105 | export type DecisionKind = "stopped" | "look" | "review" | "paused" | "parked" | "declined" | "handover"; | |
| 106 | export type DecisionKind = "stopped" | "look" | "review" | "paused" | "parked" | "declined" | "handover" | "assigned"; | |
| 106 | 107 | |
| 107 | 108 | /** Dollars as a person reads them: cents when small, whole when not. */ |
| 108 | 109 | const dollars = (n: number): string => (n < 10 ? n.toFixed(2) : n.toFixed(0)); |
| @@ -170,6 +171,11 @@ export const ASK_WORDS: Readonly<Record<DecisionKind, AskWords>> = { | ||
| 170 | 171 | options: ["Answer the planner"], |
| 171 | 172 | ifNothing: "the planner plans nothing more for this app", |
| 172 | 173 | }, |
| 174 | assigned: { | |
| 175 | decision: "This is assigned to you: act on it?", | |
| 176 | options: ["Open it"], | |
| 177 | ifNothing: "it stays assigned to you", | |
| 178 | }, | |
| 173 | 179 | paused: { |
| 174 | 180 | decision: "Raise today's ceiling?", |
| 175 | 181 | options: ["Raise it in settings"], |
| @@ -197,6 +203,7 @@ export const KIND_TIER: Readonly<Record<DecisionKind, Consequence>> = { | ||
| 197 | 203 | handover: { score: 55, why: "three reviews without an approval: handed to a person" }, |
| 198 | 204 | parked: { score: 40, why: "parked by the crew" }, |
| 199 | 205 | look: { score: 30, why: "green, waiting" }, |
| 206 | assigned: { score: 20, why: "assigned to you" }, | |
| 200 | 207 | }; |
| 201 | 208 | |
| 202 | 209 | /** When a person last spoke on a conversation, or its start. */ |
| @@ -430,6 +437,36 @@ function askCandidatesFor( | ||
| 430 | 437 | who: "the planner", |
| 431 | 438 | decline: { runId: d.runId, words: d.words }, |
| 432 | 439 | }); |
| 440 | // Open work assigned to the viewer that no ask above already covers: a | |
| 441 | // pull that is an ask and assigned to them is one row, the ask's. | |
| 442 | const taken = new Set(out.flatMap((a) => [a.pull?.id, a.issue?.id].filter((i) => i !== undefined))); | |
| 443 | const visible = new Map(allRepos.map((r) => [r.id, r])); | |
| 444 | const mine = listAssignedTo(db, user.id, 50).filter((i) => !taken.has(i.id)); | |
| 445 | const elsewhere = getReposByIds( | |
| 446 | db, | |
| 447 | [...new Set(mine.map((i) => i.repoId))].filter((id) => !visible.has(id)), | |
| 448 | ); | |
| 449 | // An assignment can outlive the access that made it: each repo needs a real read. | |
| 450 | const readable = (repo: Repo | undefined): repo is Repo => | |
| 451 | repo !== undefined && (visible.has(repo.id) || canRead(db, repo, user)); | |
| 452 | const joinedMine = new Map( | |
| 453 | joinMany(db, mine.filter((i) => i.kind === "pull")).map((p) => [p.id, p]), | |
| 454 | ); | |
| 455 | for (const issue of mine) { | |
| 456 | const repo = visible.get(issue.repoId) ?? elsewhere.get(issue.repoId); | |
| 457 | if (!readable(repo) || !mayView(db, repo, issue, user)) continue; | |
| 458 | const pull = joinedMine.get(issue.id); | |
| 459 | if (issue.kind === "pull" && pull === undefined) continue; | |
| 460 | out.push({ | |
| 461 | kind: "assigned", | |
| 462 | id: `assigned:${issue.id}`, | |
| 463 | since: issue.updatedAt, | |
| 464 | repo, | |
| 465 | ...(pull === undefined ? { issue } : { pull }), | |
| 466 | who: issue.authorName, | |
| 467 | authorIsAgent: issue.authorIsAgent, | |
| 468 | }); | |
| 469 | } | |
| 433 | 470 | return out; |
| 434 | 471 | } |
| 435 | 472 | |
| @@ -507,8 +544,9 @@ function consequencesOf( | ||
| 507 | 544 | } |
| 508 | 545 | |
| 509 | 546 | /** The row an ask collapses into: one kind in one repository. */ |
| 510 | const groupId = (a: { kind: DecisionKind; repo: Repo }): string => | |
| 511 | `${a.kind}:${a.repo.id}`; | |
| 547 | const groupId = (a: { kind: DecisionKind; repo: Repo; id: string }): string => | |
| 548 | // Work assigned to you is each its own row: they share no decision. | |
| 549 | a.kind === "assigned" ? a.id : `${a.kind}:${a.repo.id}`; | |
| 512 | 550 | |
| 513 | 551 | /** |
| 514 | 552 | * The asks the viewer has not set aside: a muted repository's asks are all |
| @@ -671,6 +709,10 @@ export function endOf( | ||
| 671 | 709 | if (pull !== undefined && pull.state !== "open") return "acted"; |
| 672 | 710 | return getHold(db, what)?.heldBy === viewerId ? "acted" : "expired"; |
| 673 | 711 | } |
| 712 | if (kind === "assigned") { | |
| 713 | const issue = getIssueById(db, what); | |
| 714 | return issue !== undefined && issue.state !== "open" ? "acted" : "expired"; | |
| 715 | } | |
| 674 | 716 | if (kind === "parked") { |
| 675 | 717 | const issue = getIssueById(db, what); |
| 676 | 718 | if (issue === undefined) return "expired"; |
| @@ -738,6 +780,8 @@ export function recordAskLedger(db: Database, now = new Date()): void { | ||
| 738 | 780 | /** One ask in a line, without its repository's name (the row adds that). */ |
| 739 | 781 | function lineOf(c: AskCandidate): string { |
| 740 | 782 | if (c.kind === "paused") return "is paused at its ceiling"; |
| 783 | if (c.kind === "assigned") | |
| 784 | return `"${c.pull?.title ?? c.issue?.title ?? ""}" is assigned to you`; | |
| 741 | 785 | if (c.kind === "parked") |
| 742 | 786 | return `the crew parked #${c.issue!.number} after three failed runs`; |
| 743 | 787 | if (c.kind === "declined") |
| @@ -771,6 +815,7 @@ export const ROW_PLURAL: Readonly<Record<DecisionKind, (n: number) => string>> = | ||
| 771 | 815 | handover: (n) => `${n} changes had three reviews asking for changes and wait for you`, |
| 772 | 816 | declined: (n) => `the planner declined ${n} times and waits for you`, |
| 773 | 817 | paused: (n) => `${n} pauses at the ceiling`, |
| 818 | assigned: (n) => `${n} things assigned to you`, | |
| 774 | 819 | }; |
| 775 | 820 | |
| 776 | 821 | /** Every kind has its own: a row never says "green changes" of something that is not one. */ |
| @@ -828,7 +873,7 @@ export function askLinesFor( | ||
| 828 | 873 | const line = `${row.repo.name}${only.kind === "paused" ? " " : ": "}${lineOf(only)}`; |
| 829 | 874 | if (only.kind === "paused") |
| 830 | 875 | return { ...about, line, link: `${base}/settings/autonomy` }; |
| 831 | if (only.kind === "parked" || only.kind === "declined") | |
| 876 | if (only.pull === undefined && only.issue !== undefined) | |
| 832 | 877 | return { |
| 833 | 878 | ...about, |
| 834 | 879 | line, |
| @@ -880,6 +925,18 @@ export function decisionsFor( | ||
| 880 | 925 | ); |
| 881 | 926 | }; |
| 882 | 927 | const worded = (c: Scored): Omit<Decision, "consequence" | "waiting"> => { |
| 928 | if (c.kind === "assigned") { | |
| 929 | const thing = c.pull ?? c.issue!; | |
| 930 | return { | |
| 931 | kind: "assigned", | |
| 932 | id: `assigned:${thing.id}`, | |
| 933 | repo: c.repo, | |
| 934 | ...(c.pull === undefined ? { issue: c.issue } : { pull: c.pull }), | |
| 935 | who: c.who, | |
| 936 | says: `"${thing.title}" is assigned to you.`, | |
| 937 | short: `assigned to you · updated ${thing.updatedAt.slice(0, 10)}`, | |
| 938 | }; | |
| 939 | } | |
| 883 | 940 | if (c.kind === "parked" && c.issue) |
| 884 | 941 | return { |
| 885 | 942 | kind: "parked", |
| @@ -1046,6 +1103,15 @@ export function decisionButtons(ctx: Ctx, d: Decision): { primary: Html; others: | ||
| 1046 | 1103 | }), |
| 1047 | 1104 | ], |
| 1048 | 1105 | }; |
| 1106 | if (d.kind === "assigned" && (d.pull ?? d.issue)) | |
| 1107 | return { | |
| 1108 | primary: btn("Open", { | |
| 1109 | href: pull ? changeHref(base, pull.number) : `${base}/issues/${d.issue!.number}`, | |
| 1110 | size: "sm", | |
| 1111 | variant: "primary", | |
| 1112 | }), | |
| 1113 | others: [], | |
| 1114 | }; | |
| 1049 | 1115 | if (d.kind === "declined" && d.issue) |
| 1050 | 1116 | return { |
| 1051 | 1117 | primary: btn("Answer", { |
src/web/studio/asks_page.ts +17 −46
| @@ -11,6 +11,7 @@ import type { WaitingFor } from "../../core/waiting_for.ts"; | ||
| 11 | 11 | import { |
| 12 | 12 | applyAsksBulk, |
| 13 | 13 | BULK_MAX, |
| 14 | latestUndoable, | |
| 14 | 15 | ownAsksOperation, |
| 15 | 16 | undoAsksBulk, |
| 16 | 17 | previewAsksBulk, |
| @@ -60,10 +61,11 @@ const ASK_KIND_WORDS: Readonly<Record<string, string>> = { | ||
| 60 | 61 | review: "Reviews", |
| 61 | 62 | stopped: "Stopped", |
| 62 | 63 | parked: "Parked", |
| 64 | assigned: "Assigned", | |
| 63 | 65 | }; |
| 64 | 66 | |
| 65 | 67 | /** The kinds a bulk action takes: a ceiling and a planner's decline are decided where they live. */ |
| 66 | const BULK_KINDS: ReadonlySet<Decision["kind"]> = new Set(["look", "review", "stopped", "handover", "parked"]); | |
| 68 | const BULK_KINDS: ReadonlySet<Decision["kind"]> = new Set(["look", "review", "stopped", "handover", "parked", "assigned"]); | |
| 67 | 69 | |
| 68 | 70 | /** A row's box for the bulk form, which sits apart (`form="asks-bulk"`): forms do not nest. */ |
| 69 | 71 | const pick = (d: Decision, picked: ReadonlySet<string>): Html | null => |
| @@ -166,6 +168,7 @@ const KIND_LABEL: Readonly<Record<Decision["kind"], string>> = { | ||
| 166 | 168 | parked: "Parked", |
| 167 | 169 | declined: "Declined", |
| 168 | 170 | paused: "Paused", |
| 171 | assigned: "Assigned", | |
| 169 | 172 | }; |
| 170 | 173 | |
| 171 | 174 | /** |
| @@ -374,10 +377,19 @@ export function needsYouSection( | ||
| 374 | 377 | > |
| 375 | 378 | <button type="submit" class="btn btn-sm btn-ghost">Listen again</button> |
| 376 | 379 | </form>`; |
| 380 | const last = latestUndoable(ctx.app, user); | |
| 381 | const undo = | |
| 382 | last === undefined | |
| 383 | ? null | |
| 384 | : html`<form class="bar" method="post" action="/asks/bulk/${last.id}/undo" role="status"> | |
| 385 | <span class="small">${VERB_WORDS[last.verb] ?? last.verb}: ${last.rows.filter((r) => r.outcome === "ok").length} done</span> | |
| 386 | ${btn("Undo", { size: "sm" })} | |
| 387 | <span class="muted small">kept for a day</span> | |
| 388 | </form>`; | |
| 377 | 389 | const count = rows.length + needs.length; |
| 378 | 390 | if (count === 0 && top === undefined) |
| 379 | 391 | return { |
| 380 | body: html`<h2 id="asks-sentence" class="sr-only">${askSentence(0)}</h2>${silencedNote}`, | |
| 392 | body: html`<h2 id="asks-sentence" class="sr-only">${askSentence(0)}</h2>${silencedNote}${undo}`, | |
| 381 | 393 | scriptJs: "", |
| 382 | 394 | }; |
| 383 | 395 | // The forge's own health first, then the few asks that matter most; |
| @@ -428,6 +440,7 @@ export function needsYouSection( | ||
| 428 | 440 | ${reasonInput(top?.reason)} ${btn("Preview", { size: "sm" })} |
| 429 | 441 | <span class="muted small">on the selected asks</span> |
| 430 | 442 | </form>`} |
| 443 | ${silencedNote} ${undo} | |
| 431 | 444 | ${decisions.map((d) => decisionForm(d, ctx.url.pathname))} |
| 432 | 445 | </section>`; |
| 433 | 446 | return { body, scriptJs: SELECT_JS }; |
| @@ -452,11 +465,8 @@ const VERB_WORDS: Readonly<Record<string, string>> = { | ||
| 452 | 465 | replan: "Hand back to the planner", |
| 453 | 466 | }; |
| 454 | 467 | |
| 455 | /** What the asks below can be given in one move; mute is the On you card's. */ | |
| 456 | const ASK_VERBS = ["decline", "ship", "close", "replan"] as const; | |
| 457 | ||
| 458 | /** What the On you card's set can be given. */ | |
| 459 | const CARD_VERBS = ["close", "mute", "ship"] as const; | |
| 468 | /** What the asks below can be given in one move. */ | |
| 469 | const ASK_VERBS = ["decline", "ship", "close", "replan", "mute"] as const; | |
| 460 | 470 | |
| 461 | 471 | /** One reason, written on each pull or issue closed. */ |
| 462 | 472 | const reasonInput = (value = ""): Html => |
| @@ -495,45 +505,6 @@ export function pickControls( | ||
| 495 | 505 | </span>`; |
| 496 | 506 | } |
| 497 | 507 | |
| 498 | /** | |
| 499 | * The On you card's one form: a verb for the set, one reason, one request. | |
| 500 | * `receipt` is the day's undo link for the last set acted on. | |
| 501 | */ | |
| 502 | export function onYouBulk( | |
| 503 | kinds: readonly { id: string; label: string }[], | |
| 504 | repos: readonly { id: string; label: string }[], | |
| 505 | receipt: { id: string; verb: string; done: number } | undefined, | |
| 506 | withForm = true, | |
| 507 | muted: readonly { id: string; label: string }[] = [], | |
| 508 | ): Html { | |
| 509 | return html`${muted.length === 0 | |
| 510 | ? null | |
| 511 | : html`<form class="bar" method="post" action="/asks/listen"> | |
| 512 | ${muted.map((r) => html`<input type="hidden" name="repo" value="${r.id}" />`)} | |
| 513 | <span class="muted small" title="${muted.map((r) => r.label).join(", ")}" | |
| 514 | >${muted.length} ${muted.length === 1 ? "repository" : "repositories"} muted</span | |
| 515 | > | |
| 516 | <button type="submit" class="btn btn-sm btn-ghost">Listen again</button> | |
| 517 | </form>`} | |
| 518 | ${receipt === undefined | |
| 519 | ? null | |
| 520 | : html`<form class="bar" method="post" action="/asks/bulk/${receipt.id}/undo" role="status"> | |
| 521 | <span class="small">${VERB_WORDS[receipt.verb] ?? receipt.verb}: ${receipt.done} done</span> | |
| 522 | ${btn("Undo", { size: "sm" })} | |
| 523 | <span class="muted small">kept for a day</span> | |
| 524 | </form>`} | |
| 525 | ${withForm | |
| 526 | ? html`<form id="onyou-bulk" method="post" action="/asks/bulk" class="bar" data-bulk> | |
| 527 | <input type="hidden" name="apply" value="1" /> | |
| 528 | ${pickControls("onyou-bulk", kinds, repos)} | |
| 529 | <select name="action" class="input" aria-label="What to do with the selected"> | |
| 530 | ${CARD_VERBS.map((v) => html`<option value="${v}">${VERB_WORDS[v]}</option>`)} | |
| 531 | </select> | |
| 532 | ${reasonInput()} ${btn("Do it", { size: "sm" })} | |
| 533 | </form>` | |
| 534 | : null}`; | |
| 535 | } | |
| 536 | ||
| 537 | 508 | const shown = (v: FleetValue): string => |
| 538 | 509 | v === null ? "nobody" : Array.isArray(v) ? v.join(", ") : String(v); |
| 539 | 510 |
src/web/studio/feed.ts +1 −3
| @@ -204,9 +204,7 @@ export function feedNote(): Html { | ||
| 204 | 204 | export function feedRegion(user: User, ctx: Ctx): Html { |
| 205 | 205 | // What needs you is pinned above the timeline (`needsYouSection`), so an |
| 206 | 206 | // ask is never a second time a post below it; the feed API keeps them. |
| 207 | const items = readFeed(ctx.app.db, user, { limit: FEED_FIRST_PAGE }).items.filter( | |
| 208 | (item) => item.kind !== "ask", | |
| 209 | ); | |
| 207 | const items = readFeed(ctx.app.db, user, { limit: FEED_FIRST_PAGE, withoutAsks: true }).items; | |
| 210 | 208 | const thoughts = recentThoughts(ctx.app.db, user.id, THOUGHTS_SHOWN, new Date(Date.now() - THOUGHT_AGE_MS).toISOString()); |
| 211 | 209 | const placed = placementsOf(ctx.app.db, thoughts.map((t) => t.id)); |
| 212 | 210 | // Who each poster is, asked once for the page (`core/marks.ts`). |
src/web/studio/home.ts +8 −5
| @@ -40,7 +40,6 @@ import { | ||
| 40 | 40 | } from "../ui.ts"; |
| 41 | 41 | import { |
| 42 | 42 | downloadsCard, |
| 43 | onYouCard, | |
| 44 | 43 | orgsCard, |
| 45 | 44 | terminalCard, |
| 46 | 45 | } from "../pages/site.ts"; |
| @@ -125,14 +124,19 @@ const appsRegion = (ctx: Ctx, user: User): Html => | ||
| 125 | 124 | ${yourApps(ctx, user)} |
| 126 | 125 | </div>`; |
| 127 | 126 | |
| 128 | const onYouRegion = (ctx: Ctx, user: User, note?: string): Html => | |
| 127 | const onYouRegion = ( | |
| 128 | ctx: Ctx, | |
| 129 | user: User, | |
| 130 | note?: string, | |
| 131 | section: Html = needsYouSection(ctx, user).body, | |
| 132 | ): Html => | |
| 129 | 133 | html`<div |
| 130 | 134 | id="live-on-you" |
| 131 | 135 | data-live="${ON_YOU_LIVE}" |
| 132 | 136 | data-live-src="/live/on-you" |
| 133 | 137 | > |
| 134 | 138 | ${note === undefined ? null : html`<p class="small" role="status">${note}</p>`} |
| 135 | ${onYouCard(ctx, user) ?? null} | |
| 139 | ${section} | |
| 136 | 140 | </div>`; |
| 137 | 141 | |
| 138 | 142 | // GET /live/apps — your apps alone, for the region that shows them. |
| @@ -191,7 +195,7 @@ export async function studioHome( | ||
| 191 | 195 | ${homeTabs("feed")} |
| 192 | 196 | <div class="dash"> |
| 193 | 197 | <div class="dash-main stack"> |
| 194 | ${needsYou.body} ${composer(ctx, user)} | |
| 198 | ${onYouRegion(ctx, user, undefined, needsYou.body)} ${composer(ctx, user)} | |
| 195 | 199 | <div class="bar feed-head"> |
| 196 | 200 | <span class="spacer"></span> |
| 197 | 201 | <a class="small muted" href="/asked">What you asked for</a> |
| @@ -207,7 +211,6 @@ export async function studioHome( | ||
| 207 | 211 | user.isAdmin || appRepos.length > 0 ? crewKeyNote(ctx) : null |
| 208 | 212 | } |
| 209 | 213 | ${appsRegion(ctx, user)} |
| 210 | ${onYouRegion(ctx, user)} | |
| 211 | 214 | ${terminalCard(ctx)} ${downloadsCard(ctx, user)} |
| 212 | 215 | ${orgsCard(ctx, user)} |
| 213 | 216 | </aside> |
test/asks-bulk.test.ts +13 −10
| @@ -21,7 +21,7 @@ import { getAgentByName, setCrewRole } from "../src/core/agents.ts"; | ||
| 21 | 21 | import { getIssueById, listComments, type Issue } from "../src/core/issues.ts"; |
| 22 | 22 | import { assignIssue } from "../src/actions/issues.ts"; |
| 23 | 23 | import { mutedRepos, recordInteraction, removeMutes } from "../src/core/interactions.ts"; |
| 24 | import { onYouCard } from "../src/web/pages/site.ts"; | |
| 24 | import { needsYouSection } from "../src/web/studio/asks_page.ts"; | |
| 25 | 25 | import { getPull, type Pull } from "../src/core/pulls.ts"; |
| 26 | 26 | import type { Repo } from "../src/core/repos.ts"; |
| 27 | 27 | import { claimRun, createRun, finishRun } from "../src/core/runs.ts"; |
| @@ -634,12 +634,14 @@ describe("acting on many asks at once", () => { | ||
| 634 | 634 | const issue = getIssueById(app.db, pull.id)!; |
| 635 | 635 | expect(assignIssue(app, alice, open, issue, alice).ok).toBe(true); |
| 636 | 636 | } |
| 637 | const ctx = (user: User) => ({ app, auth: { user } }) as never; | |
| 638 | const card = (user: User) => onYouCard(ctx(user), user)?.text ?? ""; | |
| 637 | const ctx = (user: User) => ({ app, auth: { user }, url: new URL("http://x/") }) as never; | |
| 638 | const card = (user: User) => needsYouSection(ctx(user), user).body.text; | |
| 639 | 639 | expect(card(alice)).toContain("On you one"); |
| 640 | // The card offers the set: a box each, the kinds, one form. | |
| 641 | expect(card(alice)).toContain('form="onyou-bulk"'); | |
| 642 | expect(card(alice)).toContain('value="issue:' + a.id + '"'); | |
| 640 | // The list offers the set: a box each, the kinds, one form. | |
| 641 | expect(card(alice)).toContain('form="asks-bulk"'); | |
| 642 | // A green pull assigned to alice is an ask: one row, under the ask's id. | |
| 643 | expect(card(alice)).toContain('value="look:' + a.id + '"'); | |
| 644 | expect(card(alice)).not.toContain('value="assigned:' + a.id + '"'); | |
| 643 | 645 | expect(card(alice)).toContain("data-pick"); |
| 644 | 646 | const done = await api(aliceRw, "/api/v1/asks/bulk", { |
| 645 | 647 | action: "mute", |
| @@ -713,8 +715,9 @@ describe("acting on many asks at once", () => { | ||
| 713 | 715 | const b = await greenPull(open, "Muted two"); |
| 714 | 716 | for (const pull of [a, b]) |
| 715 | 717 | expect(assignIssue(app, alice, open, getIssueById(app.db, pull.id)!, alice).ok).toBe(true); |
| 716 | const card = () => onYouCard({ app, auth: { user: alice } } as never, alice)?.text ?? ""; | |
| 717 | expect(card()).not.toContain("muted"); | |
| 718 | const card = () => | |
| 719 | needsYouSection({ app, auth: { user: alice }, url: new URL("http://x/") } as never, alice).body.text; | |
| 720 | expect(card()).not.toContain("muted repositor"); | |
| 718 | 721 | const done = await api(aliceRw, "/api/v1/asks/bulk", { |
| 719 | 722 | action: "mute", |
| 720 | 723 | items: [`issue:${a.id}`, `issue:${b.id}`], |
| @@ -722,7 +725,7 @@ describe("acting on many asks at once", () => { | ||
| 722 | 725 | }); |
| 723 | 726 | expect(done.status).toBe(201); |
| 724 | 727 | // Past the day's undo, the card still says it, and offers the way back. |
| 725 | expect(card()).toContain("1 repository muted"); | |
| 728 | expect(card()).toContain("1 muted repository still asks"); | |
| 726 | 729 | expect(card()).toContain('action="/asks/listen"'); |
| 727 | 730 | const headers = { cookie: `${aliceCookie}; forge_mode=studio`, origin: servers.url }; |
| 728 | 731 | const res = await fetch(`${servers.url}/asks/listen`, { |
| @@ -734,7 +737,7 @@ describe("acting on many asks at once", () => { | ||
| 734 | 737 | expect(res.status).toBe(303); |
| 735 | 738 | expect(mutedRepos(app.db, alice.id).has(open.id)).toBe(false); |
| 736 | 739 | expect(card()).toContain("Muted one"); |
| 737 | expect(card()).not.toContain("repository muted"); | |
| 740 | expect(card()).not.toContain("muted repository still asks"); | |
| 738 | 741 | }); |
| 739 | 742 | test("on the card, a refusal answers 422 with its message, and a partial set says what was not done", async () => { |
| 740 | 743 | const a = await greenPull(open, "Refuse one"); |
test/asks-expiry.test.ts +4 −2
| @@ -247,15 +247,17 @@ describe("asks that expire, hold and collapse", () => { | ||
| 247 | 247 | ), |
| 248 | 248 | ).toBe(false); |
| 249 | 249 | expect(JSON.stringify(asksAnswer({ app, auth: { user: aliceUser } } as never, aliceUser))).not.toContain("is green"); |
| 250 | // Assigned to alice, the home's On you says it conflicts, never ready. | |
| 250 | // Assigned to alice, the home's one list says it conflicts, never ready. | |
| 251 | 251 | setAssignee(app.db, plums.id, aliceUser.id); |
| 252 | 252 | const home = await get("/"); |
| 253 | expect(home).toContain("Conflicts in 1 file"); | |
| 253 | expect(home).toContain("conflicts with main"); | |
| 254 | expect(askLinesFor(app.db, aliceUser).map((l) => l.waitingFor.word)).toEqual(["conflicts with main"]); | |
| 254 | 255 | // Its own page still says why it cannot ship. |
| 255 | 256 | const change = await get( |
| 256 | 257 | `/${repo.ownerName}/${repo.name}/pulls/${plums.number}`, |
| 257 | 258 | ); |
| 258 | 259 | expect(change).toContain("README.md"); |
| 260 | setAssignee(app.db, plums.id, null); | |
| 259 | 261 | }); |
| 260 | 262 | test("a row dismissed while a pull conflicted asks again when it merges again, with no new check", async () => { |
| 261 | 263 | await tick(); |
test/asks-one-list.test.ts added +163
| @@ -0,0 +1,163 @@ | ||
| 1 | /** | |
| 2 | * What is assigned to you and what asks you are one list (#1826): one row | |
| 3 | * source, so the home, the count and the MCP's `asks` count the same rows, | |
| 4 | * and a pull that is both is one row. | |
| 5 | */ | |
| 6 | ||
| 7 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 8 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 9 | import { tmpdir } from "node:os"; | |
| 10 | import { join } from "node:path"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { openIssue } from "../src/actions/issues.ts"; | |
| 13 | import { openPull } from "../src/actions/pulls.ts"; | |
| 14 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | |
| 15 | import { recordInteraction, removeMutes } from "../src/core/interactions.ts"; | |
| 16 | import { setAssignee } from "../src/core/issues.ts"; | |
| 17 | import type { Repo } from "../src/core/repos.ts"; | |
| 18 | import { claimRun, createRun, finishRun } from "../src/core/runs.ts"; | |
| 19 | import { createToken } from "../src/core/tokens.ts"; | |
| 20 | import { createUser, type User } from "../src/core/users.ts"; | |
| 21 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 22 | import { askCountFor, askLinesFor } from "../src/web/studio/asks.ts"; | |
| 23 | import { quietLogs } from "./helpers/globals.ts"; | |
| 24 | ||
| 25 | quietLogs(); | |
| 26 | ||
| 27 | describe("one list", () => { | |
| 28 | let dataDir = ""; | |
| 29 | let app: App; | |
| 30 | let servers: Servers; | |
| 31 | let alice: User; | |
| 32 | let repo: Repo; | |
| 33 | let cookie = ""; | |
| 34 | let token = ""; | |
| 35 | ||
| 36 | beforeAll(async () => { | |
| 37 | dataDir = await mkdtemp(join(tmpdir(), "forge-asks-one-list-")); | |
| 38 | app = createApp({ dataDir, port: 0 }); | |
| 39 | servers = await serve(app); | |
| 40 | const made = await createUser(app.db, { | |
| 41 | trusted: true, | |
| 42 | username: "alice", | |
| 43 | email: "[email protected]", | |
| 44 | password: "a-long-one-list-passphrase", | |
| 45 | adminIfFirst: true, | |
| 46 | }); | |
| 47 | if (!made.ok) throw new Error(made.error); | |
| 48 | alice = made.value; | |
| 49 | const res = await fetch(`${servers.url}/signin`, { | |
| 50 | method: "POST", | |
| 51 | body: new URLSearchParams({ username: "alice", password: "a-long-one-list-passphrase" }), | |
| 52 | redirect: "manual", | |
| 53 | }); | |
| 54 | cookie = `${(res.headers.get("set-cookie") ?? "").split(";")[0]!}; forge_mode=studio`; | |
| 55 | token = createToken(app.db, alice.id, "ro", "ro").token; | |
| 56 | const made2 = await createRepo(app, alice, { name: "one", visibility: "public" }); | |
| 57 | if (!made2.ok) throw new Error(String(made2.error)); | |
| 58 | repo = made2.value; | |
| 59 | await commitToBranch(app, alice, repo, { | |
| 60 | message: "seed", | |
| 61 | files: [{ path: "README.md", content: "# one\n" }], | |
| 62 | }); | |
| 63 | }, 30_000); | |
| 64 | ||
| 65 | afterAll(async () => { | |
| 66 | await servers.stop(); | |
| 67 | await rm(dataDir, { recursive: true, force: true }); | |
| 68 | }); | |
| 69 | ||
| 70 | /** The three doors' counts of the same rows. */ | |
| 71 | const counts = async () => { | |
| 72 | const mcp = await fetch(`${servers.url}/mcp`, { | |
| 73 | method: "POST", | |
| 74 | headers: { | |
| 75 | authorization: `Bearer ${token}`, | |
| 76 | "content-type": "application/json", | |
| 77 | accept: "application/json, text/event-stream", | |
| 78 | }, | |
| 79 | body: JSON.stringify({ | |
| 80 | jsonrpc: "2.0", | |
| 81 | id: 1, | |
| 82 | method: "tools/call", | |
| 83 | params: { name: "asks", arguments: {} }, | |
| 84 | }), | |
| 85 | }); | |
| 86 | const body = JSON.parse(await mcp.text().then((t) => t.slice(t.indexOf("{")))) as { | |
| 87 | result: { content: { text: string }[] }; | |
| 88 | }; | |
| 89 | const answer = JSON.parse(body.result.content[0]!.text) as { rows: unknown[]; forge: unknown[] }; | |
| 90 | const home = await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie } })).text(); | |
| 91 | const said = /(\d+) things? needs? you/.exec(home); | |
| 92 | return { | |
| 93 | header: askCountFor({ app, auth: { user: alice } } as never, alice), | |
| 94 | mcp: answer.rows.length + answer.forge.length, | |
| 95 | home: said === null ? 0 : Number(said[1]), | |
| 96 | html: home, | |
| 97 | }; | |
| 98 | }; | |
| 99 | ||
| 100 | test("an issue assigned to you is a row that says so, and every door counts it", async () => { | |
| 101 | const made = openIssue(app, alice, repo, { title: "Sweep <the> path", body: "" }); | |
| 102 | if (!made.ok) throw new Error(String(made.error)); | |
| 103 | const before = await counts(); | |
| 104 | setAssignee(app.db, made.value.id, alice.id); | |
| 105 | const after = await counts(); | |
| 106 | expect(after.header).toBe(before.header + 1); | |
| 107 | expect(after.mcp).toBe(after.header); | |
| 108 | expect(after.home).toBe(after.header); | |
| 109 | expect(after.html).toContain('data-waiting="assigned to you"'); | |
| 110 | expect(after.html).toContain("Sweep <the> path"); | |
| 111 | const row = askLinesFor(app.db, alice).find((l) => l.id === `assigned:${made.value.id}`); | |
| 112 | expect(row?.waitingFor).toEqual({ word: "assigned to you", on: "you" }); | |
| 113 | // Mute silences it for this person; listening again brings it back. | |
| 114 | recordInteraction(app.db, { | |
| 115 | viewerId: alice.id, | |
| 116 | itemId: `repo:${repo.id}`, | |
| 117 | kind: "muted", | |
| 118 | repoId: repo.id, | |
| 119 | actorId: null, | |
| 120 | }); | |
| 121 | expect(askLinesFor(app.db, alice).some((l) => l.id === `assigned:${made.value.id}`)).toBe(false); | |
| 122 | expect((await counts()).header).toBe(before.header); | |
| 123 | removeMutes(app.db, alice.id, [`repo:${repo.id}`]); | |
| 124 | expect((await counts()).header).toBe(after.header); | |
| 125 | setAssignee(app.db, made.value.id, null); | |
| 126 | }); | |
| 127 | ||
| 128 | test("a green pull that is an ask and assigned to you counts once", async () => { | |
| 129 | await commitToBranch(app, alice, repo, { | |
| 130 | branch: "feat", | |
| 131 | base: "main", | |
| 132 | message: "Feature", | |
| 133 | files: [{ path: "F.md", content: "f\n" }], | |
| 134 | }); | |
| 135 | const pull = await openPull(app, alice, repo, { | |
| 136 | title: "Feature", | |
| 137 | body: "", | |
| 138 | baseBranch: "main", | |
| 139 | headBranch: "feat", | |
| 140 | }); | |
| 141 | if (!pull.ok) throw new Error(String(pull.error)); | |
| 142 | const run = createRun(app.db, { | |
| 143 | repoId: repo.id, | |
| 144 | kind: "check", | |
| 145 | issueId: pull.value.id, | |
| 146 | env: `pull-${pull.value.number}`, | |
| 147 | commitOid: pull.value.headOid, | |
| 148 | reason: "pull", | |
| 149 | }); | |
| 150 | claimRun(app.db, run.id); | |
| 151 | finishRun(app.db, run.id, { state: "ok", summary: "green" }); | |
| 152 | const unassigned = await counts(); | |
| 153 | setAssignee(app.db, pull.value.id, alice.id); | |
| 154 | const assigned = await counts(); | |
| 155 | expect(assigned.header).toBe(unassigned.header); | |
| 156 | expect(assigned.mcp).toBe(assigned.header); | |
| 157 | expect(assigned.home).toBe(assigned.header); | |
| 158 | const ids = askLinesFor(app.db, alice).flatMap((l) => l.items); | |
| 159 | expect(ids.filter((i) => i.endsWith(pull.value.id))).toEqual([`look:${pull.value.id}`]); | |
| 160 | expect(assigned.html).toContain('data-waiting="ready to land"'); | |
| 161 | expect(assigned.html).not.toContain('data-waiting="assigned to you"'); | |
| 162 | }); | |
| 163 | }); |
test/home-feed.test.ts +8 −7
| @@ -362,7 +362,7 @@ describe("home is the feed", () => { | ||
| 362 | 362 | expect(second.items.map((i: any) => i.id)).toEqual(whole.slice(2, 4)); |
| 363 | 363 | }); |
| 364 | 364 | |
| 365 | test("On you can be cleared in one move: a box each, select all, by kind and by repository, one form", async () => { | |
| 365 | test("The one list can be cleared in one move: a box each, select all, by kind and by repository, one form", async () => { | |
| 366 | 366 | const one = openIssue(app, alice, garden, { title: "Sweep the path" }); |
| 367 | 367 | const two = openIssue(app, alice, vault, { title: "Oil the hinges" }); |
| 368 | 368 | if (!one.ok || !two.ok) throw new Error("issues"); |
| @@ -370,14 +370,15 @@ describe("home is the feed", () => { | ||
| 370 | 370 | expect(assignIssue(app, alice, repo, issue, alice).ok).toBe(true); |
| 371 | 371 | const text = await (await get("/", aliceCookie)).text(); |
| 372 | 372 | const card = text.slice(text.indexOf('id="live-on-you"')).replace(/\s+/g, " "); |
| 373 | expect(card).toContain("On you"); | |
| 374 | expect(card).toContain(`value="issue:${one.value.id}"`); | |
| 375 | expect(card).toContain(`value="issue:${two.value.id}"`); | |
| 376 | expect((card.match(/form="onyou-bulk"/g) ?? []).length).toBeGreaterThanOrEqual(2); | |
| 373 | expect(card).toContain("things need you"); | |
| 374 | expect(card).toContain("assigned to you"); | |
| 375 | expect(card).toContain(`value="assigned:${one.value.id}"`); | |
| 376 | expect(card).toContain(`value="assigned:${two.value.id}"`); | |
| 377 | expect((card.match(/form="asks-bulk"/g) ?? []).length).toBeGreaterThanOrEqual(2); | |
| 377 | 378 | expect(card).toContain('data-pick="all"'); |
| 378 | 379 | expect(card).toContain("data-pick-repo"); |
| 379 | 380 | expect(card).toContain('<option value="' + garden.id + '">alice/garden</option>'); |
| 380 | expect(card).toContain('id="onyou-bulk"'); | |
| 381 | expect(card).toContain('id="asks-bulk"'); | |
| 381 | 382 | expect(card).toContain('action="/asks/bulk"'); |
| 382 | 383 | expect(card).toContain('name="reason"'); |
| 383 | 384 | expect(card).toContain(">Mute repository<"); |
| @@ -386,6 +387,6 @@ describe("home is the feed", () => { | ||
| 386 | 387 | expect(text).toContain("data-pick"); |
| 387 | 388 | // Alone, a single row stays a plain link. |
| 388 | 389 | const bobCard = await (await get("/", bobCookie)).text(); |
| 389 | expect(bobCard).not.toContain('id="onyou-bulk"'); | |
| 390 | expect(bobCard).not.toContain('id="asks-bulk"'); | |
| 390 | 391 | }); |
| 391 | 392 | }); |
new above
offline