Public: anyone can read this; the crew can change it.

The terminal home's first ask makes a new app and files the ask there, as the page does #11907

opened this

Check · Review · Land · Live — No review yet. Next: reviewer, no review yet.

Ready to land

torque/forge:torque/11406-the-terminal-home-s-first-ask-makes-a-ne → main 2 commits fork

Review

Sign in to review this change.
2 files changed +29 −6
src/tui/screens/dashboard.ts +15 −5
@@ -27,7 +27,7 @@ import { clientAppRows, clientDoings, clientFinished, doingLine, finishedLine }
2727 import { appCrew } from "../../core/app-crew.ts";
2828 import { nextStepsFor } from "../../core/next-steps.ts";
2929 import { askRepos, askStatus, askStatusLine } from "../../core/ask-status.ts";
30 import { keepThought } from "../../actions/thought.ts";
30 import { AUTONOMY_FAILED_WORDS, firstAsk } from "../../actions/first_ask.ts";
3131 import { SAY_SOMETHING_WORDS } from "../../actions/tell_words.ts";
3232 import { crewCanRun, crewFirstText } from "../../web/studio/crew_key.ts";
3333 import { agentsLine } from "../../web/studio/client_home.ts";
@@ -1357,10 +1357,20 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
13571357 hint: "enter sends",
13581358 onSubmit: (said) => {
13591359 if (said.trim() === "") return SAY_SOMETHING_WORDS;
1360 const kept = keepThought(f.app, f.user, said, "composer");
1361 ctx.toast(kept.ok ? "Received." : "That could not be kept.", kept.ok ? "success" : "danger");
1362 if (kept.ok) void loadClientLines().then(reload);
1363 return undefined;
1360 // The page's own first ask: one app made from the sentence, the ask filed on it.
1361 return (async () => {
1362 const first = await firstAsk(f.app, f.user, said, crewCanRun(f.app));
1363 if (!first.ok) {
1364 ctx.toast(first.error.words, "danger");
1365 return;
1366 }
1367 const { repo, autonomyFailed, told } = first.value;
1368 const name = `${repo.ownerName}/${repo.name}`;
1369 if (!told.ok) ctx.toast(`${name} is made, but the ask could not be filed on it.`, "danger");
1370 else ctx.toast(autonomyFailed ? `${name} is made and your ask is filed on it. ${AUTONOMY_FAILED_WORDS}` : `${name} is made and your ask is filed on it.`, "success");
1371 void loadClientLines().then(reload);
1372 ctx.push(repoScreen(f, ctx, local(f, repo)));
1373 })();
13641374 },
13651375 }),
13661376 );
test/tui-first-tell.test.ts +14 −1
@@ -38,10 +38,23 @@ test("before the first tell the home says what to do and offers no everyday acco
3838 expect(h.text()).toContain("included credit.");
3939 expect(h.text()).not.toContain("K keeps using admin");
4040
41 const count = (table: string) => forge.child.db.query<{ n: number }, []>(`SELECT COUNT(*) AS n FROM ${table}`).get()!.n;
42 const repos = count("repo");
43 const issues = count("issue");
44
4145 await h.key("t");
4246 for (const ch of "A weekly menu page") await h.key(ch);
4347 await h.key("enter");
44 expect(forge.child.db.query<{ n: number }, []>("SELECT COUNT(*) AS n FROM thought").get()!.n).toBe(1);
48 // The ask is filed asynchronously: wait for the app's screen, which opens after.
49 for (let i = 0; i < 100 && !h.text().includes("is made and your ask is filed on it"); i++) await settleApp(h.app);
50 // One new app and one issue on it, no thought; the app's screen is open.
51 expect(count("thought")).toBe(0);
52 expect(count("repo")).toBe(repos + 1);
53 expect(count("issue")).toBe(issues + 1);
54 const made = forge.child.db.query<{ name: string }, []>("SELECT name FROM repo ORDER BY rowid DESC LIMIT 1").get()!;
55 const filed = forge.child.db.query<{ n: number }, [string]>("SELECT COUNT(*) AS n FROM issue WHERE repo_id = (SELECT id FROM repo WHERE name = ?)").get(made.name)!.n;
56 expect(filed).toBe(1);
57 expect(h.text()).toContain(made.name);
4558 h.app.stop();
4659
4760 // Once the crew has made an issue of it, the home is the everyday one and offers the account.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs