diff --git a/.changes/planning/fix-interview-source-text-open-7749-b4e2c7d1.md b/.changes/planning/fix-interview-source-text-open-7749-b4e2c7d1.md new file mode 100644 index 00000000000..7d23c994344 --- /dev/null +++ b/.changes/planning/fix-interview-source-text-open-7749-b4e2c7d1.md @@ -0,0 +1,7 @@ +--- +bump: patch +--- + +### Fixed + +- `/planning:interview` page surface (#7749): a question whose `facts` open with a Source quote shows it open under a "Source text" heading above the recommendation, not collapsed under Details. A stored toggle choice still holds; a question without a leading quote renders as before. diff --git a/plugins/planning/skills/interview/context/surface.md b/plugins/planning/skills/interview/context/surface.md index b6c60703fe8..e9f44c06fa4 100644 --- a/plugins/planning/skills/interview/context/surface.md +++ b/plugins/planning/skills/interview/context/surface.md @@ -31,7 +31,7 @@ The page is the input surface SKILL.md "Question surface: the page" selects. The ``` `--sync-ledger` runs `round.sh sync-ledger --ledger ''` after the write (a missing ledger, or one without exactly one open-question register heading, is refused before anything is written). If the sync fails after the write, the round stays posted and the command exits 1 naming the cause and the `round.sh sync-ledger` command to run once the cause is fixed. It rewrites only the register rows, in id order, from page state, and keeps rows the page never had, the ledger's titles and its round labels, so register row cells need no hand edit; rerun `sync-ledger` after a write the register should show. Each question carries `id` (its `Q`), `short` (the one-line label the page lists), `title` (the full question the card shows), `recommendation` (one line), `basis` (2-3 sentences, shown behind Why), at least two `alternatives` (`{key, text}`), `commits` (what accepting commits the user to, or `[]`), `dependsOn` for its prerequisites, and optionally `stage`. A yes/no question sets `"binary": true` and carries exactly one alternative, the other answer; that alternative may not repeat or contain the recommendation. Send the round's closing constraint probe with a `note-reply` op (no `seq`) so it lands in Notes to Claude, or as a Claude thread line on the round's first question. `add` and `add-round` refuse a question whose `id` already exists (naming the first duplicate and saying nothing was written, so `apply` on a file with one writes none of it), a question that supersedes another and reuses its `short` (give it its own), and a question missing `id`, `short` or `title` (naming the question and the field), without `commits`, or with fewer than two alternatives (one when `binary`). A question with no `stage` takes the newest question's stage and the round that stage is on, and the write warns naming both; set `stage` on every question that opens a new stage. A question whose round is below the newest round when it is added (asked after a later round was posted) records `addedInRound`: the page shows `Added in round N` on it and the register's round cell reads `round (added in round )`, which `import-ledger` reads back. -- **Source.** When a question rests on text the user has not read (a doc, a post, a repo file), open `facts` with a Source block ahead of the recommendation's reasoning: the exact text as a `>` quote (the page sets it apart), a link to its exact section, and one line on why that text makes this a question. The quote lives only on the page. `export-brief` and `export-report` read no `facts`, so the Brief and report carry no quote. +- **Source.** When a question rests on text the user has not read (a doc, a post, a repo file), open `facts` with a Source block ahead of the recommendation's reasoning: the exact text as a leading `>` quote (the page shows it open under "Source text", above the recommendation, and keeps the rest of `facts` under Details), a link to its exact section, and one line on why that text makes this a question. The quote lives only on the page. `export-brief` and `export-report` read no `facts`, so the Brief and report carry no quote. - **Meta.** `meta` takes `title`, `eyebrow`, `stages`, `next` and `repo`. `stages` is an object mapping each stage key to its label, for example `"stages": {"frame": "Frame", "decide": "Decide"}`; a list is refused (`$.meta.stages: expected object, got list`). Set with `add-round`'s `meta` object or the `meta` op; any other key is refused. `meta.next` is what Claude does after wrap-up, shown on the finished screen. `meta.repo` (`owner/repo`) makes the page link a bare `#N` in any markdown field to that repo's issue; `owner/repo#N` always links to its own repo, and `[text](url)` links, `Qn` refs and code spans are left as written. A bare `#N` with `meta.repo` unset stays plain text and `add`, `add-round` and `apply` warn (non-blocking). Keep round numbers out of `meta.eyebrow`: the page derives the round label (`Round N · `) from the questions and shows it beside the eyebrow, so a number in the eyebrow goes stale at the next round. Round numbers are session-wide, one counter across every stage, so `Round 12 · Build 2` follows `Round 10 · Build 2` when round 11 ran in another stage. Label each stage in `meta.stages`; without a label the page splits letters from digits (`build2` shows as `Build 2`), `add` and `add-round` warn on a new stage that has none, and the Rounds view lists unlabeled stages after labeled ones in order of first appearance. Every meta write records the newest round in `meta.setInRound`. `add` and `add-round` warn when they open a round above every existing one while meta was last set in an earlier round, and `round.sh status` prints `meta last set in round N, newest question in round M`; refresh `eyebrow` and `next` then. `meta.title` names the whole interview: `add-round` keeps the existing title and warns when its `meta.title` differs, unless `--replace-title` (op field `replaceTitle`) is passed. - **Visuals** are declared by format (`svg`, `mermaid`, `image`, `markdown`, `html`, `chart`) with a `scope` (`question:`, `group:`, `round::`, `all`) and inline `content` or a data-dir-relative `file`. `label` is its tab name (short; the page falls back to `title`, then `id`). `group`, `order` and `primary` arrange visuals: those sharing a `group` are versions or alternatives of one another, `order` sorts them, and at most one live `primary` is allowed per `group` within a `scope`. Change a visual with `replace-visual` (a full object with the same id) or retire it with `archive-visual`; an archived visual stays in `questions.json` and the page and report never show it. `add-round` refuses an id that already exists. Describe what a visual shows; leave out the tool or skill that made it. An `html` visual runs its scripts on the page, in an opaque-origin sandbox that cannot reach the page, so an interactive prototype or an inlined chart library works; the page CSP still blocks remote content. The exported report runs no scripts: when the decision rests on what a scripted visual shows, attach an `image` of it as well. Two or more `image` visuals on a question also get a Gallery tab (one more per group holding a smaller set) with a thumbnail strip, arrow-key flip and a side-by-side compare, in full screen too. Any visual opens in a new tab from the panel or full screen, still sandboxed. - **Resume.** Resolve the surface again through the SKILL.md start command on every resume, handoff or `/clear`; an absolute `` or `round.sh` path copied from a handoff or an earlier session names whichever install ran then, so never reuse one. Before the first resumed round run `round.sh --dir '' doctor --ledger '//interview-checklist.md'` (the `--dir` may not exist yet). It prints a `missing:` line per element the running version needs and the ledger or page lacks (the `## Constraint ledger` and `## Open-question register` sections, and open questions on the page without a Basis or without a `Checked against:` line in `facts`), and a `note:` when the ledger's `Planning version:` line or `meta.pluginVersion` names another version. It exits 1 on any `missing:` line and writes nothing; retrofit what it names, then continue. Older ledgers still import and grade. It cannot see the mechanism-tripwire question or whether the assumption sweep ran, and says so. `meta.pluginVersion` records the version that first wrote the data dir; the ledger template carries the `Planning version:` line. diff --git a/plugins/planning/surface/index.html b/plugins/planning/surface/index.html index 4ab49f6c0d0..11fff588c2d 100644 --- a/plugins/planning/surface/index.html +++ b/plugins/planning/surface/index.html @@ -203,10 +203,12 @@ .note{border-left:3px solid var(--accent);background:var(--accent-soft);padding:9px 14px;border-radius:0 6px 6px 0;font-size:14px} section.blk{display:grid;gap:8px} section.blk>h4,details.more>summary{font:500 12px/1 var(--mono);letter-spacing:.07em;text-transform:uppercase;color:var(--muted);margin:0} -details.more{display:grid;gap:12px} +details.more,details.src{display:grid;gap:12px} details.more>summary{cursor:pointer;padding:4px 0} details.more[open]>summary{margin-bottom:10px} details.more>section+section{margin-top:12px} +details.src>summary{font:500 12px/1 var(--mono);letter-spacing:.07em;text-transform:uppercase;color:var(--muted);cursor:pointer;padding:4px 0} +details.src[open]>summary{margin-bottom:10px} .md{max-width:72ch} .md p{margin:0 0 .5em}.md p:last-child{margin-bottom:0} .md ul,.md ol{margin:0 0 .5em;padding-left:20px} @@ -226,7 +228,7 @@ .assume{font:500 12.5px var(--mono);color:var(--chg)} .pill code{font-size:12px;background:none;padding:0} /* A grid track sized auto grows to its widest unbreakable child; every single-column grid caps it at the container. */ -nav.rail,.toolbar,.rail-list,.sec,.qlist,.tree,.act-list,.act-list li,main.detail,.dscroll,.dhead,section.blk,details.more,.recbox,.crows,.alts,ol.hist,ol.hist li,section.answer,.choices,.compose,.conflict,aside.fly,.fhead,.fbody,.nthread,.nmsg,.fs,ul.loose{grid-template-columns:minmax(0,1fr)} +nav.rail,.toolbar,.rail-list,.sec,.qlist,.tree,.act-list,.act-list li,main.detail,.dscroll,.dhead,section.blk,details.more,details.src,.recbox,.crows,.alts,ol.hist,ol.hist li,section.answer,.choices,.compose,.conflict,aside.fly,.fhead,.fbody,.nthread,.nmsg,.fs,ul.loose{grid-template-columns:minmax(0,1fr)} .alts{display:grid;gap:8px;max-width:80ch} .alt{display:grid;grid-template-columns:auto minmax(0,1fr);gap:10px;border:1px solid var(--line);border-radius:6px;padding:8px 12px} .alt .k{font:600 13px var(--mono)} @@ -1140,6 +1142,9 @@

Interview

if (q.claudeNote) h += '
Claude: ' + inline(q.claudeNote) + "
"; const lc = latestClaude(q); if (lc) h += '
' + esc(whoLabel(lc)) + " · " + esc(fmt(lc.at)) + "" + md(lc.text) + "
"; + let facts = String(q.facts || "").replace(/\r/g, ""); + const sm = facts.match(/^(?:[ \t]*\n)*((?:>[^\n]*(?:\n|$)|[ \t]*\n(?=[ \t]*>))+)/), src = sm ? sm[1].replace(/^>[ \t]?/gm, "").trim() : ""; // a Source block opens facts with the quote: it shows above the recommendation + if (src) { facts = facts.slice(sm[0].length); h += '
Source text" + md(src.replace(/^/gm, "> ")) + "
"; } if (q.recommendation) h += '

' + (withheld(q) ? "Recommendation withheld" : (marks ? "➡️ " : "") + "Recommendation (Rec)") + '

' + md(q.recommendation) + (q.basis ? '
Why' + md(q.basis) + "
" : "") + "
"; if (q.commits && q.commits.length) { @@ -1152,7 +1157,7 @@

Interview

}).join("") + "" + (acc && q.commits.some((c, i) => !cf.has(String(i))) ? '
' : "") + ""; } let more = ""; - if (q.facts) more += '

What we know

' + md(q.facts) + "
"; + if (facts.trim()) more += '

What we know

' + md(facts) + "
"; if (altsOf(q).length) more += '

Alternatives

' + altsOf(q).map(a => '
(' + esc(a.key) + ")" + inline(a.text) + "
").join("") + "
"; if (more) h += '
Details: what we know, alternatives" + more + "
"; @@ -2110,7 +2115,7 @@

Interview

setLocal(k, v); renderFly(); renderAll(); } }); - document.addEventListener("toggle", e => { if (e.target.id === "more") lsSet("moreOpen", e.target.open); }, true); + document.addEventListener("toggle", e => { if (e.target.id === "more") lsSet("moreOpen", e.target.open); else if (e.target.id === "src") lsSet("srcOpen", e.target.open); }, true); document.addEventListener("input", e => { if (e.target.id === "note") { if (S.sel && Q[S.sel]) lsSet("draft:" + S.sel, e.target.value); grow(e.target); renderAnswer(); } else if (e.target.id === "noteText") { lsSet("noteDraft", e.target.value); grow(e.target); } diff --git a/plugins/planning/surface/tests/fixtures/ui_page/round.json b/plugins/planning/surface/tests/fixtures/ui_page/round.json index 2ab60a60b05..3f1f3e6360c 100644 --- a/plugins/planning/surface/tests/fixtures/ui_page/round.json +++ b/plugins/planning/surface/tests/fixtures/ui_page/round.json @@ -1,16 +1,18 @@ { "groups": [ {"id": "g1", "title": "Release"}, - {"id": "g2", "title": "Chain"} + {"id": "g2", "title": "Chain"}, + {"id": "g3", "title": "Sources"} ], "questions": [ - {"id": "Q1", "group": "g1", "stage": "interview", "short": "Ship day", "title": "When should the release ship?", "recommendation": "Ship it on Monday. Watch the error logs for a week after. Roll back on the first new error.", "commits": [], "alternatives": [{"key": "a", "text": "Ship on Friday"}, {"key": "b", "text": "Hold until next month"}]}, + {"id": "Q1", "group": "g1", "stage": "interview", "short": "Ship day", "title": "When should the release ship?", "recommendation": "Ship it on Monday. Watch the error logs for a week after. Roll back on the first new error.", "facts": "> Releases ship on a weekday.\n\n[Release policy](https://example.com/policy#days)\n\nThe policy bars weekend releases.", "commits": [], "alternatives": [{"key": "a", "text": "Ship on Friday"}, {"key": "b", "text": "Hold until next month"}]}, {"id": "Q2", "group": "g2", "stage": "interview", "short": "Runner", "title": "Which runner builds the release?", "recommendation": "The hosted runner.", "commits": [], "alternatives": [{"key": "a", "text": "A self-hosted machine"}, {"key": "b", "text": "Both runners"}]}, {"id": "Q3", "group": "g2", "stage": "interview", "short": "Image", "title": "Which image does the runner use?", "recommendation": "The default image.", "dependsOn": ["Q2"], "commits": [], "alternatives": [{"key": "a", "text": "A pinned image"}, {"key": "b", "text": "A custom image"}]}, {"id": "Q4", "group": "g2", "stage": "interview", "short": "Cache", "title": "Should the image cache tools?", "recommendation": "Cache the tool folder.", "dependsOn": ["Q3"], "commits": [], "alternatives": [{"key": "a", "text": "Cache nothing"}, {"key": "b", "text": "Cache the whole disk"}]}, {"id": "Q5", "group": "g2", "stage": "interview", "short": "Timeout", "title": "How long may a build run?", "recommendation": "Twenty minutes.", "dependsOn": ["Q2"], "commits": [], "alternatives": [{"key": "a", "text": "No limit"}, {"key": "b", "text": "Five minutes"}]}, {"id": "Q6", "group": "g2", "stage": "interview", "short": "Cache key", "title": "What keys the tool cache?", "recommendation": "The lock file hash.", "dependsOn": ["Q4"], "commits": [], "alternatives": [{"key": "a", "text": "The branch name"}, {"key": "b", "text": "The date"}]}, {"id": "Q7", "group": "g2", "stage": "interview", "short": "Sign-off", "title": "Who signs off the build setup?", "recommendation": "The release owner.", "dependsOn": ["Q2", "Q3", "Q4", "Q5", "Q6"], "commits": [], "alternatives": [{"key": "a", "text": "The whole team"}, {"key": "b", "text": "Nobody"}]}, - {"id": "Q8", "group": "g1", "stage": "interview", "short": "Notes", "title": "Should the release notes list every change?", "recommendation": "List the user-facing changes only.", "commits": [], "alternatives": [{"key": "a", "text": "List every commit"}, {"key": "b", "text": "No release notes"}]} + {"id": "Q8", "group": "g1", "stage": "interview", "short": "Notes", "title": "Should the release notes list every change?", "recommendation": "List the user-facing changes only.", "commits": [], "alternatives": [{"key": "a", "text": "List every commit"}, {"key": "b", "text": "No release notes"}]}, + {"id": "Q10", "group": "g3", "stage": "interview", "short": "Quote", "title": "Which quote governs the freeze?", "recommendation": "The first quote.", "facts": "> First paragraph.\n\n> Second paragraph.\n\nRest.", "commits": [], "alternatives": [{"key": "a", "text": "The second quote"}, {"key": "b", "text": "Neither quote"}]} ] } diff --git a/plugins/planning/surface/tests/ui_page.js b/plugins/planning/surface/tests/ui_page.js index 062fffea4b1..d89189e9397 100644 --- a/plugins/planning/surface/tests/ui_page.js +++ b/plugins/planning/surface/tests/ui_page.js @@ -21,6 +21,23 @@ async page => { // the question page itself: choices, chips, banners, header and await page.evaluate(() => localStorage.clear()); await page.reload(); await page.waitForSelector(".qbtn", {state: "attached"}); await page.waitForTimeout(300); + // #7749: the Source text quote shows open and above the recommendation; a question without one renders as before + for (const [w, h] of [[1440, 900], [390, 844]]) { + await page.setViewportSize({width: w, height: h}); await page.waitForTimeout(250); + await pick("Q1"); + const src = await page.evaluate(() => { const s = document.querySelector("#dscroll details.src"), r = document.querySelector("#dscroll .recbox"), m = document.querySelector("#dscroll details.more"); + return {open: !!s && s.open, text: s ? s.textContent.replace(/\s+/g, " ").trim() : "", above: !!s && !!r && !!(s.compareDocumentPosition(r) & Node.DOCUMENT_POSITION_FOLLOWING), moreHasQuote: !!m && /weekday/.test(m.textContent), moreKeepsRest: !!m && /bars weekend/.test(m.textContent)}; }); + ok("Q1's Source text quote is open and above the recommendation at " + w + " px, with the rest of facts under Details", src.open && src.above && /^Source text ?Releases ship on a weekday\.$/.test(src.text) && !src.moreHasQuote && src.moreKeepsRest, JSON.stringify(src)); + await pick("Q2"); + const none = await page.evaluate(() => ({src: document.querySelectorAll("#dscroll details.src").length, more: document.querySelectorAll("#dscroll details.more").length})); + ok("Q2, with no source text, renders no Source text block at " + w + " px", none.src === 0 && none.more === 1, JSON.stringify(none)); + await pick("Q10"); + const two = await page.evaluate(() => { const s = document.querySelector("#dscroll details.src"), m = document.querySelector("#dscroll details.more"); + return {src: s ? s.textContent.replace(/\s+/g, " ").trim() : "", more: m ? m.textContent.replace(/\s+/g, " ").trim() : ""}; }); + ok("Q10's two-paragraph Source quote stays whole, with only the rest under Details at " + w + " px", /^Source text ?First paragraph\. ?Second paragraph\.$/.test(two.src) && /Rest\./.test(two.more) && !/paragraph/.test(two.more), JSON.stringify(two)); + } + await page.setViewportSize({width: 1440, height: 900}); await page.waitForTimeout(250); + // #5815: the Rec choice carries the whole recommendation, not its first sentence await pick("Q1"); const wide = await recRow(); @@ -87,7 +104,7 @@ async page => { // the question page itself: choices, chips, banners, header and await pick("Q7"); const b7 = await text("#dscroll .banner"); ok("#5908: prerequisites first decided after this answer read 'was decided after you answered this'", /Stale: Q3Image was decided after you answered this; Q4Cache was decided after you answered this/.test(b7) && !/changed/.test(b7), b7); - ok("#5908: the meter shows 1 to review and leaves the stale question out of answered", (await text("#revBtn")) === "1 to review" && (await text("#meterText")) === "5 of 8 answered", await text("#meterText") + " / " + await text("#revBtn")); + ok("#5908: the meter shows 1 to review and leaves the stale question out of answered", (await text("#revBtn")) === "1 to review" && (await text("#meterText")) === "5 of 9 answered", await text("#meterText") + " / " + await text("#revBtn")); await pick("Q2"); await page.selectOption("#filter", "open"); await page.waitForTimeout(150); await page.click('#choices .choice:has-text("A self-hosted machine")'); await page.click("[data-save]"); await page.waitForTimeout(1200); const toastT = await text("#toast"); @@ -95,7 +112,7 @@ async page => { // the question page itself: choices, chips, banners, header and ok("#5909: the toast names the newly stale questions and counts what waits on them", /^Saved Q2\. Q3 and Q5 need review; 2 more wait on them\. Now Q3\./.test(toastT), toastT); const b3 = await text("#dscroll .banner"); ok("#5908: a prerequisite whose earlier decision was replaced reads 'changed'", /Stale: Q2Runner changed\. Your decision is kept/.test(b3), b3); - ok("#5908: the meter now shows 3 to review and 3 of 8 answered", (await text("#revBtn")) === "3 to review" && (await text("#meterText")) === "3 of 8 answered", await text("#meterText") + " / " + await text("#revBtn")); + ok("#5908: the meter now shows 3 to review and 3 of 9 answered", (await text("#revBtn")) === "3 to review" && (await text("#meterText")) === "3 of 9 answered", await text("#meterText") + " / " + await text("#revBtn")); await page.click("#qhead"); await page.keyboard.press("n"); await page.waitForTimeout(250); ok("#5909: n goes to the other newly stale dependent next", await sel() === "Q5", await sel()); ok("#5910: a kept accept whose recommendation is unchanged still offers Reconfirm first", /^Reconfirm/.test((await first()).trim()), await first());