git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-27T11:03:26Z
feat(web): pick a project on Goals, to grow a tree for each The Goals page drew every goal of every project, and its menu offered them all, so starting a tree for a second project (pinnacle) meant making a goal among cartopolis's and picking its project by hand. The page now takes the project picker Sessions has, the same choice: it shows the goals whose projects name the one picked (or that name none yet), an empty project offers its first goal, and a new goal or a scout's first look starts on that project. A theme still reads its goal's projects.
docs/hub.md | 5 ++++-
web/src/app.css | 4 ++++
web/src/components/research.tsx | 40 +++++++++++++++++++++++++++++++++-------
web/src/lib/projects.tsx | 4 ++--
4 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/docs/hub.md b/docs/hub.md
index bb7079d..6a3cdd1 100644
--- a/docs/hub.md
+++ b/docs/hub.md
@@ -774,7 +774,10 @@ what the person asks it to look at, in their words, which the scout reads
first. The page never names the moves: the goal and its
themes are one bar above the tree (a block with a menu of the other goals and
the goal's tools, then a tab per theme with how far it is; ← → step through
-them), the tree is drawn in lanes by theme, and the scout is docked in it with
+them, and before it the project picker Sessions has, one choice for both: a
+project shown keeps the goals that name it or none, an empty one offers its
+first goal, and a new goal or a scout's first look is about it until the
+person picks otherwise), the tree is drawn in lanes by theme, and the scout is docked in it with
one button, **Research further**, and a line for what to look at. That asks
for a **look** (`op: look`): Map, Harvest, Group and Sketch as rounds of one
look, each waiting for the one before (`after`), Group and Sketch skipped when
diff --git a/web/src/app.css b/web/src/app.css
index 9053403..e77f31c 100644
--- a/web/src/app.css
+++ b/web/src/app.css
@@ -8467,6 +8467,10 @@ button.way-stop {
gap: 8px;
align-items: stretch;
}
+.tree-bar__row > .pselect {
+ max-width: 10em;
+ align-self: center;
+}
.tree-bar__row--under {
align-items: center;
}
diff --git a/web/src/components/research.tsx b/web/src/components/research.tsx
index 8c02843..67a56c2 100644
--- a/web/src/components/research.tsx
+++ b/web/src/components/research.tsx
@@ -10,7 +10,7 @@ import {api} from '@/lib/api'
import type {Direction, DirectionNext, Goal, Insight, LiveLine, Round, Tech, TechState, TreeState} from '@/lib/api'
import {age, ahead, shortName} from '@/lib/format'
import {hooks as talkHooks, talking} from '@/lib/discuss'
-import {askProjects, projectName, projects} from '@/lib/projects'
+import {askProjects, projectName, projectSelect, projects, shown} from '@/lib/projects'
import {bind, local} from '@/lib/reactive'
import {go, here} from '@/lib/route'
import {$s, steers} from '@/lib/store'
@@ -246,9 +246,26 @@ function iconOf(t: {icon?: string | null; name: string}, cls = 'tree-icon'): m.C
return t.icon ? <span class={cls}>{m.trust(t.icon)}</span> : <span class={`${cls} ${cls}--letter`}>{t.name.slice(0, 1).toUpperCase()}</span>
}
+/**
+ * Whether a goal is in the project shown (projects.tsx `shown`, the same choice as Sessions'): its projects, or those
+ * of the goal it is under, name it. A goal that names none yet is in every view, so it is never lost to one.
+ */
+function goalInView(d: TreeState, g: Goal): boolean {
+ const p = shown()
+ if (!p) return true
+ const r = repos_(d, g)
+ return !r.length || r.includes(p)
+}
+
function pickedGoal(d: TreeState): Goal | undefined {
const want = state.goal || d.last_goal || ''
- return d.goals.find((g) => g.id === want) ?? d.goals.find((g) => !g.parent) ?? d.goals[0]
+ const seen = d.goals.filter((g) => goalInView(d, g))
+ return seen.find((g) => g.id === want) ?? seen.find((g) => !g.parent) ?? seen[0]
+}
+
+/** The project picker on the Goals page, each project with how many goals of its own. */
+function goalProjects(d: TreeState): m.Children {
+ return projectSelect((repo) => d.goals.filter((g) => !g.parent && repos_(d, g).includes(repo)).length, "show one project's goals")
}
/** The goal at the top of `g`'s line: the one its themes are under. */
@@ -285,7 +302,7 @@ function show(id: string) {
*/
function goalBar(d: TreeState, g: Goal): m.Children {
const root = rootOf(d, g)
- const tops = d.goals.filter((x) => !x.parent && x.id !== root.id)
+ const tops = d.goals.filter((x) => !x.parent && x.id !== root.id && goalInView(d, x))
const p = progress(techsOf(d, root.id))
const all = p.known + p.fog
const line: Goal[] = []
@@ -328,6 +345,7 @@ function goalBar(d: TreeState, g: Goal): m.Children {
return (
<nav class="tree-bar" aria-label="Goals and themes">
<div class="tree-bar__row">
+ {goalProjects(d)}
<div class={`tree-goalpick${g.id === root.id ? ' tree-goalpick--on' : ''}`}>
<button type="button" class="tree-goalpick__main" title={root.statement || root.name} onclick={() => show(root.id)}>
<span class="tree-head__flag">{GOAL_FLAG}</span>
@@ -724,7 +742,9 @@ function scoutStart(d: TreeState, g: Goal): m.Children {
askProjects()
if (state.startFor !== g.id) {
state.startFor = g.id
- state.startRepos = projects.list.length === 1 ? {[projects.list[0].repo]: true} : {}
+ // The project shown is the one it is about, until the person says otherwise.
+ const one = shown() || (projects.list.length === 1 ? projects.list[0].repo : '')
+ state.startRepos = one ? {[one]: true} : {}
}
const picked = projects.list.filter((p) => state.startRepos[p.repo]).map((p) => p.repo)
const send = async () => {
@@ -1964,8 +1984,9 @@ function editPage(d: TreeState, id: string, parent: string): m.Children {
picked: false, more: !!(g?.who || g?.signs || g?.never.length),
})
}
- // A new goal in a workspace of one project is about that one, until the person says otherwise.
- if (!g && !editing.picked && !Object.keys(editing.repos).length && projects.list.length === 1) editing.repos = {[projects.list[0].repo]: true}
+ // A new goal is about the project shown, or the workspace's one project, until the person says otherwise; a theme reads its goal's.
+ const one = shown() || (projects.list.length === 1 ? projects.list[0].repo : '')
+ if (!g && !editing.parent && !editing.picked && !Object.keys(editing.repos).length && one) editing.repos = {[one]: true}
const repos = projects.list.filter((p) => editing.repos[p.repo]).map((p) => p.repo)
// Saving sends the scout when it gives the scout its first projects to read (docs/mockups/scout 7-start).
const scouts = repos.length > 0 && (!g || !repos_(d, g).length)
@@ -2090,9 +2111,14 @@ export class ResearchPage extends MithrilComponent {
if (edit) return editPage(d, edit[1] === 'new' ? '' : edit[1]!, edit[2] ?? '')
const g = pickedGoal(d)
if (!g) {
+ const p = projectName(shown())
return (
<div class="stack">
- <Card title="Research" subtitle="A tree of what the work is for, as in Civilization: your goals at the end, the techs on the way, built at the top.">
+ <div class="tree-bar__row">{goalProjects(d)}</div>
+ <Card
+ title={p ? `Research · ${p}` : 'Research'}
+ subtitle={p ? `${p} has no goal yet.` : 'A tree of what the work is for, as in Civilization: your goals at the end, the techs on the way, built at the top.'}
+ >
<p>
Start with a goal: a sentence of yours, as abstract as you like (“an open metaverse for communities”). The scout then reads its projects and fills
in what is built, what it needs next and what earlier sessions left open.
diff --git a/web/src/lib/projects.tsx b/web/src/lib/projects.tsx
index eee0d12..0c28edc 100644
--- a/web/src/lib/projects.tsx
+++ b/web/src/lib/projects.tsx
@@ -110,11 +110,11 @@ export function projectFilter(count: (repo: string) => number): m.Children {
* The same choice as one small dropdown, for the nav and Sessions: there the
* groups do the sorting, and a row of tabs took a line for a choice made rarely.
*/
-export function projectSelect(count: (repo: string) => number): m.Children {
+export function projectSelect(count: (repo: string) => number, title = "show one project's sessions"): m.Children {
if (!several()) return null
const now = shown()
return (
- <select class="pselect" aria-label="project" title="show one project's sessions" value={now} onchange={(e: Event) => show((e.target as HTMLSelectElement).value)}>
+ <select class="pselect" aria-label="project" title={title} value={now} onchange={(e: Event) => show((e.target as HTMLSelectElement).value)}>
<option value="">all projects</option>
{projects.list.map((p) => (
<option value={p.repo} selected={now === p.repo}>