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
Check · Review · Land · Live — No review yet.
torque/forge:torque/11406-the-terminal-home-s-first-ask-makes-a-ne → main 2 commits fork
2 files
changed +29
−6
src/tui/screens/dashboard.ts +15 −5
| @@ -27,7 +27,7 @@ import { clientAppRows, clientDoings, clientFinished, doingLine, finishedLine } | ||
| 27 | 27 | import { appCrew } from "../../core/app-crew.ts"; |
| 28 | 28 | import { nextStepsFor } from "../../core/next-steps.ts"; |
| 29 | 29 | 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"; | |
| 31 | 31 | import { SAY_SOMETHING_WORDS } from "../../actions/tell_words.ts"; |
| 32 | 32 | import { crewCanRun, crewFirstText } from "../../web/studio/crew_key.ts"; |
| 33 | 33 | import { agentsLine } from "../../web/studio/client_home.ts"; |
| @@ -1357,10 +1357,20 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen { | ||
| 1357 | 1357 | hint: "enter sends", |
| 1358 | 1358 | onSubmit: (said) => { |
| 1359 | 1359 | 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 | })(); | |
| 1364 | 1374 | }, |
| 1365 | 1375 | }), |
| 1366 | 1376 | ); |
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 | ||
| 38 | 38 | expect(h.text()).toContain("included credit."); |
| 39 | 39 | expect(h.text()).not.toContain("K keeps using admin"); |
| 40 | 40 | |
| 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 | ||
| 41 | 45 | await h.key("t"); |
| 42 | 46 | for (const ch of "A weekly menu page") await h.key(ch); |
| 43 | 47 | 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); | |
| 45 | 58 | h.app.stop(); |
| 46 | 59 | |
| 47 | 60 | // Once the crew has made an issue of it, the home is the everyday one and offers the account. |
new above
offline