From f1d9f4e9f8ceb75595387284e76355b773282639 Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Thu, 19 Nov 2026 21:20:12 -0800 Subject: [PATCH 1/2] Simplify checkpoint onboarding and agreement --- docs/REFERENCE.md | 41 +-- internal/controlplane/checkpoint.html | 320 ++++++++++++------ .../controlplane/checkpoint_openui_test.go | 8 +- internal/controlplane/checkpoint_ui_test.go | 2 +- .../views_confirmed_build_first_test.go | 2 +- .../controlplane/views_page_script_gen.go | 2 +- internal/controlplane/views_page_test.go | 32 +- internal/controlplane/views_proposal_test.go | 2 +- internal/controlplane/views_story_test.go | 14 +- internal/controlplane/views_team_test.go | 48 ++- internal/controlplane/views_title_test.go | 8 +- internal/project/views_browser_test.go | 86 ++++- internal/project/views_page_test.go | 2 +- ui/checkpoint/src/app.tsx | 254 +++++++++----- ui/checkpoint/src/components/build.tsx | 7 +- ui/checkpoint/src/components/c4-graph.tsx | 2 +- ui/checkpoint/src/components/change-list.tsx | 52 ++- ui/checkpoint/src/components/cp1-editor.tsx | 203 +++++------ ui/checkpoint/src/components/proposal.tsx | 64 ++-- ui/checkpoint/src/components/session.tsx | 4 +- ui/checkpoint/src/components/shadcn.tsx | 85 ++++- ui/checkpoint/src/components/story.tsx | 15 +- ui/checkpoint/src/components/team.tsx | 56 +-- .../src/components/workspace-frame.tsx | 88 +++-- ui/checkpoint/src/openui/library.tsx | 156 ++++----- ui/checkpoint/src/styles.css | 186 +++++++--- ui/checkpoint/testing/browser_harness.cjs | 100 +++++- 27 files changed, 1200 insertions(+), 639 deletions(-) diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index dde28e40..89390e1f 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -2427,9 +2427,9 @@ name, such as `Confirm change: shop`, from the facts the page last read; after a failed read of the changes or the team, a lost update connection or an ended session, it names the recovery instead, such as `Reconnecting: shop`. Before the exchange succeeds, the title is `Surla`. -Reloading or closing the tab ends the session. Ask the guide to call -[`open_views`](#open_views), or use **Open Surla Window** in the Herdr companion, to -open a fresh session. Bare `surla` remains an operator fallback. +Reloading or closing the tab ends the session. Ask your coding agent to +[reopen Surla](#open_views) or choose **Open Surla Window** in the Herdr companion +to open a fresh session. Bare `surla` remains an operator fallback. Opening a fresh link in the same tab reloads the page through the normal link exchange. If there are unsaved CP1 edits, unadopted proposal answers, Model-form edits, or a pending edit request, the page removes the link from the address @@ -2440,33 +2440,36 @@ The link still expires two minutes after it was printed, not after it was pasted. Obtain another link if it expires while you finish editing. A used or expired link is reported as such. When the server answers `401`, as it does after a restart, the page keeps everything typed visible and -copyable and explains how to ask the guide to reopen the page. Leaving with unsaved edits asks the +copyable and explains how to ask your coding agent to reopen the page. Leaving with unsaved edits asks the browser to confirm, including for unadopted proposal answers and Model-form edits. -**Every view.** The frame previews at most two lines of the confirmed -agreement's summary. **Read full summary** opens Agree, expands **Agreement -details**, and focuses the complete saved summary without submitting or -discarding unsaved edits. The action is absent before confirmation. On -Describe with no change open for editing, the frame says **No confirmed -agreement opened** and offers no **Read full summary**; a change kept open -there because its edits are unsaved, failed or still saving keeps both. - -One line per role that needs the user (for example -`Builder needs you: permission`), with a **Show builder pane** action. This +**Every view.** Open **Inspect** to reach Team, Story, Live target, +Architecture, or Diagnostics. The label names the current inspection, and +Escape closes the disclosure and returns focus to it. On an empty project with +a connected coding agent and no outstanding issue, the frame leaves room for +the welcome card. When a confirmed agreement is open, the frame previews at +most two lines of its summary. **Read full summary** expands **Agreement +details** in Agree and focuses the saved summary while retaining unsaved edits. +That preview remains available if you open another view while editing the card. + +Each role that needs your help has a notice, for example +`Builder needs you: permission`, and a **Show builder pane** action when +Herdr can show it. This polite live region follows the current role facts; a recovered role's line disappears without leaving a copied attention message in operation status. The page keeps one `wait_for_changes` read open and reads again only what -changed. When the server does not answer, the status line says so, every -edit is kept, and the page retries after 5 seconds, doubling up to 30. +changed. The operation status announces progress to assistive technology. +When the server does not answer, a visible notice explains that updates are +unavailable, every edit is kept, and the page retries after 5 seconds, doubling up to 30. Hiding the tab pauses this. A failed read keeps the last facts with a last-read label. An incoming revision never replaces typed edits: the page holds it beside them (**Switch to Incoming Card**). | View | What it shows and does | | --- | --- | -| **Describe** | The project's changes ([`list_changes`](#list_changes)), opening directly on the only one. With none: `This project has no changes yet. Ask the guide to propose a change; it appears here by itself.` A change with a waiting proposed revision is marked **New revision proposed**. Each change shows its latest saved run, such as **Latest saved run: passed**, or **No saved runs**, and under a run what `inputs_current` says: `Matches the agreed revision and selected tests.` or `Earlier inputs or no current test selection. Ask the builder for a check of the agreed revision and selected tests.` | -| **Team** | Each registered role's state, its Chorus watcher, and its assignment status (**No assignments** for the guide, and **Assignment unread**, **No unread assignment**, **No work now** or **Assignment status unknown** for a worker role), with a **Show … pane** action per role, such as **Show guide pane**, and **Start workers**, which requests missing workers and shows the outcome and time. Refresh reads the cached team facts. | -| **Story** | The Story saved with the shown revision, one row of step cards per flow: a finished flow is marked **will be tested end to end**, others **draft: not tested** with the reasons. Below it, the current Story evaluation ([`get_story_refresh`](#get_story_refresh)): none, running, failed, or succeeded, and how it differs from the change's Story; a draft is not part of the change until the guide revises the change with it and the user confirms. | +| **Describe / Changes** | The welcome card directs you to your coding agent. The first proposed Change Card opens automatically while the empty view is displayed. A project with one existing change also opens directly to its card. **Changes** lists more work via [`list_changes`](#list_changes). It marks a pending revision **New revision proposed** and shows the latest saved test result and whether its inputs match the agreed revision and selected tests. | +| **Team** | Each registered role has a state, watcher, and any worker assignment. The project coding agent may be attached in its own session outside Herdr. **Show coding agent pane** appears for an attached Herdr pane; eligible workers have their own **Show … pane** actions. **Start workers** requests missing workers and reports the outcome and time. **Refresh team** reads the cached facts. | +| **Story** | The Story saved with the shown revision, one row of step cards per flow. A finished flow is marked **will be tested end to end**. Other flows are marked **draft: not tested** with the reasons. Below it, see the current Story evaluation ([`get_story_refresh`](#get_story_refresh)) and how it differs from the change's Story. A draft joins the change when your coding agent proposes it and you confirm the new revision. | | **Live target** | Whether a live target is starting, running, ended unexpectedly or not confirmed stopped. A running target shows its commit, address, accepted prompt versions (never the text), and **Stop live target**, which asks first. An ended target shows its commit, launch and observed-end times, and the builder's recovery step. Below it, the model live targets started afterwards use and a form whose **Apply** sends [`configure_model`](#configure_model); a refusal names a missing key's variable. | | **Agree** | The Change Card: questions to answer, examples, preserved behaviors, and **Confirm Intent & Lock Examples** (on an agreed card, **Refine Confirmed Answers & Examples**). A proposed revision appears above the agreed one with everything adopting it would confirm (changed request and summary, questions and examples marked **New**, **Edited**, **Kept** or **Removed**, Story and design changes), **Adopt this revision** and **Decline**. A stale submission offers **Load Latest Card**. On a confirmed card the **Build** section comes first, with the saved agreement below it under **Agreed:** and the request. **Agreement details** and **Refine agreed answers and examples** remain available for review and refinement; an active edit stays open. **Previous Saved Revision** keeps the earlier snapshot: questions not yet answered in that proposal are labeled as historical, and a note distinguishes an unconfirmed proposal from the current confirmed agreement. **Review saved approval** opens the record in Approve. **Build** opens the same saved build section directly. | | **Architecture** | [`preview_architecture`](#preview_architecture) for the revision shown. | diff --git a/internal/controlplane/checkpoint.html b/internal/controlplane/checkpoint.html index 46870399..6560248f 100644 --- a/internal/controlplane/checkpoint.html +++ b/internal/controlplane/checkpoint.html @@ -219,7 +219,8 @@ h2 { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 0.4rem 0; } h3 { font-size: 0.9rem; font-weight: 600; letter-spacing: -0.01em; margin: 0.85rem 0 0.35rem 0; } h4 { font-size: 0.85rem; font-weight: 600; margin: 0.6rem 0 0.25rem 0; } -p { margin: 0.25rem 0; max-inline-size: 75ch; } +h1, h2, h3, h4 { text-wrap: balance; } +p { margin: 0.25rem 0; max-inline-size: 75ch; text-wrap: pretty; } #surla-checkpoint-status { font-size: 0.82rem; color: var(--muted-foreground); @@ -450,6 +451,7 @@ .shadcn-badge-success { border-color: var(--success); background: var(--success-soft); } .shadcn-badge-warning { border-color: var(--warning); background: var(--warning-soft); } .shadcn-badge-destructive { border-color: var(--destructive); background: var(--destructive-soft); } +.shadcn-badge-outline { border-color: var(--border); background: transparent; } .shadcn-btn, .surla-pill, .surla-btn { -webkit-appearance: none; @@ -481,12 +483,59 @@ opacity: 0.55; cursor: not-allowed; } -.surla-pill[aria-pressed="true"], .surla-pill[aria-current="page"], .surla-btn-primary, .shadcn-btn-primary { +.surla-pill[aria-pressed="true"], .surla-pill[aria-current="page"] { border-color: var(--accent); background-color: var(--accent-soft); color: var(--foreground); font-weight: 600; } +.shadcn-btn-primary, .surla-btn-primary { + background-color: var(--primary); + color: var(--primary-foreground); + border-color: var(--primary); + font-weight: 600; +} +.shadcn-btn-primary:hover:not(:disabled), .surla-btn-primary:hover:not(:disabled) { + background-color: color-mix(in srgb, var(--primary) 88%, var(--primary-foreground)); +} +.shadcn-btn-secondary { background: var(--muted); } +.shadcn-btn-ghost { background: transparent; border-color: transparent; } +.shadcn-choice-group { display: grid; gap: 0.4rem; } +.shadcn-choice-option { + align-items: baseline; + justify-content: flex-start; + gap: 0.65rem; + min-inline-size: 0; + margin: 0; + padding: 0.55rem 0.75rem; + text-align: start; + overflow-wrap: anywhere; +} +.shadcn-choice-indicator { + flex: 0 0 0.9rem; + block-size: 0.9rem; + align-self: flex-start; + margin-block-start: 0.11rem; + border: 1px solid var(--muted-foreground); + border-radius: 50%; +} +.shadcn-choice-option[aria-pressed="true"] .shadcn-choice-indicator { + border-color: var(--accent); + background: var(--accent); + box-shadow: inset 0 0 0 2px var(--card); +} +.shadcn-card-footer { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.5rem; + margin-block-start: 1rem; +} +.shadcn-separator { + margin-block: 1.25rem; + border: 0; + border-block-start: 1px solid var(--border); +} #surla-cp4-run-list { display: flex; flex-wrap: wrap; @@ -531,6 +580,41 @@ border: 1px solid var(--border); border-radius: calc(var(--radius) - 3px); } +.surla-question-list, .surla-examples-list, .surla-decision-grid { + display: grid; + gap: 1rem; +} +.surla-question h4 { margin-block: 0 0.55rem; } +.surla-example-card .shadcn-label { min-inline-size: 0; } +.surla-example-card .shadcn-textarea { line-height: 1.4; } +.surla-example-header { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 0.35rem; + margin-block-end: 0.65rem; +} +.surla-example-header h4 { margin: 0; } +.surla-example-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 0.6rem; + margin-block-start: 0.6rem; +} +.surla-welcome-card { + max-inline-size: 42rem; + margin: clamp(1.5rem, 5vw, 3rem) auto 0; + padding: clamp(1rem, 3vw, 1.75rem); +} +.surla-welcome-card h2 { font-size: 1.45rem; line-height: 1.25; margin-block-end: 0.75rem; } +.surla-welcome-steps { + padding-inline-start: 1.3rem; + margin-block: 1.15rem 0; + color: var(--muted-foreground); +} +.surla-welcome-steps li + li { margin-block-start: 0.55rem; } +.surla-welcome-steps strong { display: block; color: var(--foreground); } .shadcn-alert { border: 1px solid var(--border); @@ -596,16 +680,22 @@ .shadcn-table, .shadcn-table thead, .shadcn-table tbody, .shadcn-table tr, .shadcn-table th, .shadcn-table td { display: block; } - .shadcn-table thead { display: none; } + .shadcn-table thead { + position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); + } .shadcn-table tr { border-bottom: 1px solid var(--border); padding: 0.35rem 0; } .shadcn-table td[data-label]::before { - content: attr(data-label) ": "; + content: attr(data-label); + display: block; font-weight: 600; color: var(--muted-foreground); } } -.shadcn-cell-active { background: var(--accent-soft); font-weight: 600; } +.shadcn-table thead .shadcn-cell-active, .shadcn-cell-active { + background: var(--accent-soft); + font-weight: 600; +} .shadcn-timeline, .surla-timeline { display: flex; flex-direction: column; @@ -646,7 +736,7 @@ scrolls inside the stage, so long flows never widen the page. */ .surla-story-stage h5 { font-size: 0.84rem; font-weight: 600; margin: 0; overflow-wrap: anywhere; } /* Read by assistive technology, not shown. */ -.surla-visually-hidden { +.surla-visually-hidden, #surla-checkpoint-status:not([data-connection-warning]) { position: absolute; inline-size: 1px; block-size: 1px; @@ -740,7 +830,7 @@ .surla-build-merge pre code { padding: 0; background: transparent; white-space: pre; overflow-wrap: normal; word-break: normal; } .surla-build-merge li p { font-size: 0.875rem; color: var(--muted-foreground); } -/* Layout B: the fixed Surla surface owns orientation and the deciding action. */ +/* The fixed Surla surface owns orientation and the deciding action. */ :root { --surla-space-1: 4px; --surla-space-2: 8px; @@ -761,14 +851,14 @@ border: 0; border-block-end: 1px solid var(--border); border-radius: 0; background: var(--card); } -.surla-fixed-frame { font-size: 13px; line-height: 18px; } +.surla-fixed-frame { font-size: 0.8125rem; line-height: 1.4; } .surla-frame-where { - display: grid; grid-template-columns: minmax(110px, 1fr) auto auto; + display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) auto; gap: 8px 16px; align-items: center; padding: 8px 12px; } .surla-frame-project { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; - min-inline-size: 0; margin: 0; font-size: 13px; line-height: 18px; + min-inline-size: 0; margin: 0; font-size: 0.8125rem; line-height: 1.4; letter-spacing: normal; overflow-wrap: anywhere; } .surla-frame-project > span:first-child { font-weight: 700; } @@ -776,7 +866,7 @@ .surla-frame-journey, .surla-frame-references { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; } .surla-fixed-frame .surla-btn { min-block-size: 30px; padding: 4px 10px; border-radius: 4px; - font-size: 13px; line-height: 18px; white-space: normal; + font-size: 0.8125rem; line-height: 1.4; white-space: normal; } .surla-frame-journey .surla-btn { border-color: transparent; background: transparent; } .surla-frame-journey [aria-current="step"] { color: var(--accent); border-block-end-color: var(--accent); border-radius: 0; } @@ -785,8 +875,11 @@ display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(170px, auto); margin: 0; padding: 12px; gap: 16px; border-block-start: 1px solid var(--border); } +.surla-frame-slots:not(:has(.surla-frame-agreed)) { + grid-template-columns: minmax(0, 1fr) minmax(170px, auto); +} .surla-frame-slots > div { min-inline-size: 0; } -.surla-frame-slots dt { font-size: 12px; color: var(--muted-foreground); margin-block-end: 4px; } +.surla-frame-slots dt { font-size: 0.75rem; color: var(--muted-foreground); margin-block-end: 4px; } .surla-frame-slots dd { margin: 0; overflow-wrap: anywhere; } .surla-frame-summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; @@ -795,59 +888,64 @@ .surla-frame-agreed .surla-btn { margin-block-start: 4px; } #surla-agreement-summary:focus { outline: 2px solid var(--accent); outline-offset: 2px; } .surla-frame-next dd { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; } -#surla-frame-next .surla-btn-primary { - background-color: var(--primary); color: var(--primary-foreground); border-color: var(--primary); -} -.surla-frame-action-binding { font-size: 12px; color: var(--muted-foreground); } -.surla-frame-context { padding: 0 12px 8px; font-size: 12px; } +.surla-frame-action-binding { font-size: 0.75rem; color: var(--muted-foreground); } +.surla-frame-context { padding: 0 12px 8px; font-size: 0.75rem; } .surla-frame-context summary { color: var(--muted-foreground); cursor: pointer; } -.surla-frame-context .surla-workspace-context { margin-block-start: 8px; font-size: 12px; } -.surla-frame-project-menu { position: relative; justify-self: end; } +.surla-frame-context .surla-workspace-context { margin-block-start: 8px; font-size: 0.75rem; } +.surla-frame-project-menu { position: relative; grid-column: 3; justify-self: end; } .surla-frame-project-menu > summary { - padding: 10px 12px; min-block-size: 44px; cursor: pointer; + padding: 0.3rem 0.65rem; min-block-size: 1.875rem; cursor: pointer; border: 1px solid var(--border); border-radius: 4px; } +.surla-frame-project-menu > summary:hover { background: var(--muted); } +.surla-frame-project-menu > summary[data-active="true"] { color: var(--accent); border-color: var(--accent); } .surla-frame-project-menu .surla-frame-references { position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 4px); - z-index: 35; inline-size: min(260px, 85vw); padding: 8px; + display: grid; z-index: 35; inline-size: min(15rem, 85vw); padding: 0.5rem; background: var(--card); border: 1px solid var(--border); border-radius: 6px; } -.surla-approval-stage { min-inline-size: 0; font-size: 14px; line-height: 1.5; padding: 8px 0 24px; } -.surla-approval-stage h2 { font-size: 18px; line-height: 1.4; margin: 0 0 8px; } -.surla-approval-stage h3 { font-size: 14px; margin: 24px 0 8px; } -.surla-approval-stage h4 { font-size: 13px; margin: 16px 0 8px; } +.surla-frame-references .surla-btn { justify-content: flex-start; margin: 0; } +.surla-frame-references [aria-current="page"], .surla-frame-references [aria-expanded="true"] { + color: var(--accent); +} +.surla-approval-stage { min-inline-size: 0; font-size: 0.875rem; line-height: 1.5; padding: 8px 0 24px; } +.surla-approval-stage h2 { font-size: 1.125rem; line-height: 1.4; margin: 0 0 8px; } +.surla-approval-stage h3 { font-size: 0.875rem; margin: 24px 0 8px; } +.surla-approval-stage h4 { font-size: 0.8125rem; margin: 16px 0 8px; } .surla-approval-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; } .surla-approval-heading p { color: var(--muted-foreground); margin: 0; } .surla-approval-binding { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 16px 0; padding-block: 12px; border-block: 1px solid var(--border); } -.surla-approval-binding dt { color: var(--muted-foreground); font-size: 12px; } +.surla-approval-binding dt { color: var(--muted-foreground); font-size: 0.75rem; } .surla-approval-binding dd { margin: 4px 0 0; } .surla-approval-evidence { display: grid; grid-template-columns: minmax(0, 2fr) minmax(250px, 1fr); gap: 24px; align-items: start; } .surla-approval-evidence > * { min-inline-size: 0; } .surla-approval-basis { padding-inline-start: 24px; border-inline-start: 1px solid var(--border); } .surla-approval-notice { padding: 12px 0; color: var(--muted-foreground); } .surla-approval-exclusions { margin-block: 24px; padding-block: 0 16px; border-block-end: 1px solid var(--border); } -.surla-flow-evidence { inline-size: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; } +.surla-flow-evidence { inline-size: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.8125rem; } .surla-flow-evidence th, .surla-flow-evidence td { text-align: start; vertical-align: top; padding: 12px 8px; border-block-end: 1px solid var(--border); overflow-wrap: anywhere; } -.surla-flow-evidence thead th { font-size: 12px; color: var(--muted-foreground); font-weight: 500; } +.surla-flow-evidence thead th { font-size: 0.75rem; color: var(--muted-foreground); font-weight: 500; } .surla-flow-evidence th:first-child { inline-size: 49%; padding-inline-start: 0; } .surla-flow-evidence th:last-child { inline-size: 21%; } .surla-flow-evidence tbody th { font-weight: 400; } -.surla-flow-evidence tbody th p { font-size: 13px; color: var(--muted-foreground); margin-block-start: 4px; } +.surla-flow-evidence tbody th p { font-size: 0.8125rem; color: var(--muted-foreground); margin-block-start: 4px; } .surla-approval-stage [data-outcome="passed"] { color: var(--success); } .surla-approval-stage [data-outcome="failed"] { color: var(--destructive); } .surla-approval-stage [data-outcome="not_run"], .surla-approval-stage [data-outcome="harness_error"] { color: var(--warning); } .surla-approval-test-list { list-style: none; padding: 0; } .surla-approval-test-list li { display: flex; justify-content: space-between; gap: 12px; padding-block: 8px; border-block-end: 1px solid var(--border); } .surla-approval-basis dl { margin: 12px 0; } -.surla-approval-basis dt { margin-block-start: 12px; color: var(--muted-foreground); font-size: 12px; } +.surla-approval-basis dt { margin-block-start: 12px; color: var(--muted-foreground); font-size: 0.75rem; } .surla-approval-basis dd { margin: 4px 0 0; } .surla-approval-basis pre { white-space: pre; overflow-wrap: normal; max-inline-size: 100%; } .surla-approval-stage .surla-details > summary { display: list-item; padding: 4px 0; } +.surla-meta .surla-details > summary, +#surla-cp1-form-card > .surla-details > summary { display: list-item; } .surla-approval-stage :focus-visible, .surla-fixed-frame :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } -.surla-build-test-review { min-inline-size: 0; font-size: 14px; line-height: 1.5; } -.surla-build-test-review h4 { font-size: 18px; margin: 16px 0 8px; } -.surla-build-test-review h5 { font-size: 14px; margin: 12px 0 8px; } -.surla-build-test-binding { font-size: 12px; color: var(--muted-foreground); overflow-wrap: anywhere; } +.surla-build-test-review { min-inline-size: 0; font-size: 0.875rem; line-height: 1.5; } +.surla-build-test-review h4 { font-size: 1.125rem; margin: 16px 0 8px; } +.surla-build-test-review h5 { font-size: 0.875rem; margin: 12px 0 8px; } +.surla-build-test-binding { font-size: 0.75rem; color: var(--muted-foreground); overflow-wrap: anywhere; } .surla-build-test-evidence { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; } .surla-build-test-evidence > * { min-inline-size: 0; } .surla-build-test-evidence > section:only-child { grid-column: 1 / -1; } @@ -877,14 +975,21 @@ .surla-approval-evidence > div > section:last-child { margin-block-end: 0; padding-block-end: 0; border-block-end: 0; } } @media (max-width: 720px) { - body { padding-inline: 12px; padding-block-end: calc(var(--surla-next-height, 110px) + 24px); } + body { padding-inline: 12px; } + body:has(.surla-frame-next button) { padding-block-end: calc(var(--surla-next-height, 110px) + 24px); } #surla-checkpoint-nav:not([hidden]) { position: relative; margin-inline: -12px; } html { scroll-padding-block-start: 12px; } - .surla-frame-where { gap: 4px 8px; padding: 4px 12px; } - .surla-fixed-frame .surla-btn, .surla-approval-stage .surla-btn { min-block-size: 44px; padding: 10px 12px; } - .surla-frame-journey { flex-wrap: wrap; gap: 0; } - .surla-frame-journey .surla-btn { flex: 1; padding-inline: 6px; } - .surla-frame-slots { grid-template-columns: minmax(0, 1fr); gap: 8px; } + html:has(.surla-frame-next button) { scroll-padding-block-end: calc(var(--surla-next-height, 110px) + 16px); } + .surla-frame-where { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 4px 12px; } + .surla-frame-project-menu { grid-column: 2; grid-row: 1; } + .surla-fixed-frame .surla-btn, .surla-approval-stage .surla-btn, .surla-pill, .shadcn-choice-option, + .surla-frame-project-menu > summary { min-block-size: 2.75rem; padding-block: 0.625rem; } + .surla-example-fields { grid-template-columns: minmax(0, 1fr); } + .surla-frame-journey { grid-column: 1 / -1; grid-row: 2; gap: 0.25rem; } + .surla-frame-journey .surla-btn { margin: 0; padding-inline: 0.45rem; } + .surla-frame-slots, .surla-frame-slots:not(:has(.surla-frame-agreed)) { + grid-template-columns: minmax(0, 1fr); gap: 8px; + } .surla-frame-next { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; @@ -898,7 +1003,6 @@ grid-template-columns: minmax(0, 1fr); gap: 4px; } .surla-frame-next:not(:has(button)) dd { justify-content: flex-start; } - body:has(.surla-frame-next:not(:has(button))) { padding-block-end: 24px; } .surla-frame-action-binding { white-space: nowrap; } .surla-approval-binding { gap: 12px; } .surla-flow-evidence, .surla-flow-evidence tbody { display: block; } @@ -921,58 +1025,58 @@
diff --git a/internal/controlplane/checkpoint_openui_test.go b/internal/controlplane/checkpoint_openui_test.go index 21e65317..ce515fd0 100644 --- a/internal/controlplane/checkpoint_openui_test.go +++ b/internal/controlplane/checkpoint_openui_test.go @@ -136,7 +136,11 @@ expect(cells.length === 4 && cells[0].getAttribute("data-label") === "Scenario" workspace.querySelector('[data-openui-ambiguity-id="chg-openui-ambiguity-01"][data-openui-option="subtotal_only"]').click(); const canonicalPill = editorRegion().querySelector('[data-ambiguity-id="chg-openui-ambiguity-01"][data-option="subtotal_only"]'); const activeCells = workspace.querySelectorAll(".shadcn-cell-active"); -expect(canonicalPill && canonicalPill.getAttribute("aria-pressed") === "true" && activeCells.length === 3 && !page.$("#surla-confirmed-decisions") && editorRegion().textContent.includes("Summary: ") && editorRegion().textContent.includes("[Selected draft answer: subtotal_only]") && !editorRegion().textContent.includes("[Confirmed answer: subtotal_only]"), "OpenUI option click did not synchronize canonical pill, draft label, or active column cells (activeCells=" + activeCells.length + ")"); +expect(canonicalPill && canonicalPill.getAttribute("aria-pressed") === "true" && activeCells.length === 3 && + editorRegion().querySelectorAll('[data-ambiguity-id="chg-openui-ambiguity-01"]').length === 2 && + !page.$("#surla-confirmed-decisions") && editorRegion().textContent.includes("Summary: ") && + !editorRegion().textContent.includes("[Selected draft answer:"), "OpenUI click did not update the single choice group and active column"); +expect(workspace.querySelectorAll("details").length === 0, "decision instruments exposed repeated technical disclosures"); // 3. A local example edit qualifies the illustration. expect(!page.$("#surla-openui-local-edit-notice"), "unexpected local-edit notice before editing examples"); @@ -156,7 +160,7 @@ expect(decisions && decisions.textContent.includes("Confirmed Decisions:") && de // A confirmed card without questions keeps the plain Summary heading. await open("chg-zero-amb"); page.$("#surla-confirm-submit").click(); -await until(() => editorRegion().textContent.includes("Agreed:"), "the zero-question card did not confirm"); +await until(() => page.$("#surla-agreement-details"), "the zero-question card did not confirm"); expect(!page.$("#surla-confirmed-decisions") && editorRegion().textContent.includes("Summary: ") && !editorRegion().textContent.includes("Initial Proposal Summary: "), "expected zero-ambiguity confirmed card to omit #surla-confirmed-decisions and keep Summary heading"); // 4. Every invalid composition falls back to the canonical editor. diff --git a/internal/controlplane/checkpoint_ui_test.go b/internal/controlplane/checkpoint_ui_test.go index a1a408b2..19809ed8 100644 --- a/internal/controlplane/checkpoint_ui_test.go +++ b/internal/controlplane/checkpoint_ui_test.go @@ -225,7 +225,7 @@ expect(page.text("#surla-cp2-error").includes("must be confirmed before architec page.$("#surla-nav-cp1").click(); page.$('[data-ambiguity-id="chg-arch-ambiguity-01"][data-option="subtotal_only"]').click(); page.$("#surla-confirm-submit").click(); -await until(() => page.$("#surla-cp1-editor").textContent.includes("Agreed:"), "confirmation did not finish"); +await until(() => page.$("#surla-agreement-details"), "confirmation did not finish"); const revision = page.$("#surla-cp1-editor").dataset.requestRevision; page.$("#surla-nav-cp2").click(); expect(page.$("#surla-cp2-loading") && page.$("#surla-cp2-loading").getAttribute("aria-busy") === "true", "evaluating showed no loading state"); diff --git a/internal/controlplane/views_confirmed_build_first_test.go b/internal/controlplane/views_confirmed_build_first_test.go index 4953e916..a439815e 100644 --- a/internal/controlplane/views_confirmed_build_first_test.go +++ b/internal/controlplane/views_confirmed_build_first_test.go @@ -61,7 +61,7 @@ const next = () => page.text("#surla-frame-next dd"); expect(next().includes("Build controls below") && !page.$("#surla-frame-next button"), "initial Build did not point to its existing controls"); page.$("#surla-nav-changes").click(); expect(!page.$("#surla-agreement-details") && !page.$("#surla-read-full-summary"), "Describe exposed a hidden editor’s agreement"); -expect(page.text(".surla-frame-summary") === "No confirmed agreement opened", "Describe labeled a hidden agreement as open"); +expect(!page.$(".surla-frame-agreed"), "Changes labeled a hidden agreement as open"); page.$("#surla-nav-build").click(); const editor = page.$("#surla-cp1-editor"); const build = page.$("#surla-build-section"); diff --git a/internal/controlplane/views_page_script_gen.go b/internal/controlplane/views_page_script_gen.go index 5a247a46..8cbf7a17 100644 --- a/internal/controlplane/views_page_script_gen.go +++ b/internal/controlplane/views_page_script_gen.go @@ -4,4 +4,4 @@ package controlplane // viewsPageScriptSource is the Content-Security-Policy source that allows the // views page's one inline script: the SHA-256 digest of its exact text. -const viewsPageScriptSource = "'sha256-ZxQtEHgGLZbtqK5TMWSeu8iVwn/A2/MklYfe1WOA/G4='" +const viewsPageScriptSource = "'sha256-urQzdpJi7mEMdcdCpFNrBeh4YN8uL2O2S909Szczt0Q='" diff --git a/internal/controlplane/views_page_test.go b/internal/controlplane/views_page_test.go index 67dd6da7..786a7910 100644 --- a/internal/controlplane/views_page_test.go +++ b/internal/controlplane/views_page_test.go @@ -79,7 +79,7 @@ page.close(); } // TestViewsPageFindsOpensAndConfirmsChanges walks the user's journey: the -// empty project explains how a change appears, a proposed change appears by +// empty project explains how a change appears, the first proposal opens by // itself, the list orders changes by save time and opens one, and confirming // records the user's session as who confirmed. func TestViewsPageFindsOpensAndConfirmsChanges(t *testing.T) { @@ -88,11 +88,14 @@ func TestViewsPageFindsOpensAndConfirmsChanges(t *testing.T) { runPageScript(t, ps, nil, viewsPageScriptHelpers+` const page = await openPage(origin, { link: input.link }); await until(() => page.$("#surla-change-list-empty"), "empty project did not show its empty state"); -expect(page.text("#surla-change-list-empty").includes("Ask the guide to propose a change; it appears here by itself."), "empty state did not say how a change appears"); +expect(page.text("#surla-change-list-title") === "Start in your coding agent with /surla" && + page.text("#surla-change-list-empty").includes("Your Change Card will appear here automatically."), + "empty state did not say where to start and how a change appears"); expect(page.win.location.href === origin + "/views", "the link stayed in the address: " + page.win.location.href); await propose("chg-first", "Route refunds to a manager.", "Auto-approved"); -await until(() => page.$$("#surla-change-list li").length === 1, "a proposed change did not appear without a reload"); +await until(() => page.$("#surla-cp1-editor").dataset.changeId === "chg-first", "the first proposal did not open without a reload"); +page.$("#surla-nav-changes").click(); await propose("chg-second", "Hold refunds for review.", "Held"); await until(() => page.$$("#surla-change-list li").length === 2, "a second change did not appear"); const ids = page.$$("#surla-change-list li").map((li) => li.dataset.changeId); @@ -103,13 +106,28 @@ checkControl(page, page.$("#surla-open-change-chg-first"), "list control"); expect(page.$("#surla-open-change-chg-first").textContent.includes("Route refunds to a manager."), "the list control is not named by its change"); page.$("#surla-open-change-chg-first").click(); await until(() => page.$("#surla-cp1-editor").dataset.changeId === "chg-first", "opening a listed change did not show its card"); -page.$('[data-ambiguity-id="chg-first-ambiguity-01"][data-option="subtotal_only"]').click(); +const answer = page.$('[data-ambiguity-id="chg-first-ambiguity-01"][data-option="subtotal_only"]'); +checkControl(page, page.$("#surla-cp1-next-question"), "jump to unanswered question"); +page.$("#surla-cp1-next-question").click(); +expect(page.doc.activeElement === answer, "Next did not focus the first unanswered option"); +answer.click(); +const example = page.$('textarea[data-field="expected_outcome"]'); +const originalOutcome = example.value; +page.type(example, " "); checkControl(page, page.$("#surla-confirm-submit"), "confirm control"); -await control(origin, "hold", { key: "POST /changes/confirm" }); page.$("#surla-confirm-submit").click(); -expect(page.$("#surla-confirm-submit").disabled && page.$("#surla-cp1-form-card").getAttribute("aria-busy") === "true", "confirming showed no busy state"); +expect(page.doc.activeElement === example && page.text("#surla-confirm-error").includes("expected result for example 1") && + page.sent("POST", "/changes/confirm").length === 0, "invalid example did not focus its field and preserve the draft"); +page.type(example, originalOutcome); +checkControl(page, page.$("#surla-cp1-next-confirm"), "reachable confirm control"); +await control(origin, "hold", { key: "POST /changes/confirm" }); +page.$("#surla-cp1-next-confirm").click(); +expect(page.$("#surla-cp1-next-confirm").disabled && page.$("#surla-confirm-submit").disabled && + page.$("#surla-cp1-form-card").getAttribute("aria-busy") === "true", "confirming showed no busy state"); await control(origin, "release", { key: "POST /changes/confirm" }); -await until(() => page.$("#surla-cp1-editor").textContent.includes("Agreed: Route refunds to a manager."), "confirming did not show the confirmed card"); +await until(() => page.$("#surla-agreement-details") && + page.text("#surla-agreement-summary").includes("Route refunds to a manager."), + "confirming did not show the saved agreement"); const confirmed = await readCard("chg-first"); expect(confirmed.status === "confirmed" && confirmed.confirmed_by === input.owner, "the saved change does not record the user as who confirmed: " + confirmed.confirmed_by); expect(page.doc.activeElement === page.$("#surla-cp1-editor"), "confirming did not move focus to the result"); diff --git a/internal/controlplane/views_proposal_test.go b/internal/controlplane/views_proposal_test.go index 423385fa..15add1ee 100644 --- a/internal/controlplane/views_proposal_test.go +++ b/internal/controlplane/views_proposal_test.go @@ -80,7 +80,7 @@ const page = await openPage(origin, { link: input.link }); const editor = () => page.$("#surla-cp1-editor"); const outcome = () => page.$('textarea[data-example-id="check_01"][data-field="expected_outcome"]'); const answer = () => page.$('#surla-proposal [data-question-id="chg-proposal-ambiguity-01"] [data-option="with_tax"]'); -await until(() => editor().dataset.changeId === "chg-proposal" && page.text("#surla-cp1-editor").includes("Agreed:"), "the agreed change did not open"); +await until(() => editor().dataset.changeId === "chg-proposal" && page.$("#surla-agreement-details"), "the agreed change did not open"); const next = () => page.text("#surla-frame-next dd"); page.$("#surla-nav-cp1").click(); expect(next().includes("Review Agreement details"), "clean Agree did not point to the saved agreement"); diff --git a/internal/controlplane/views_story_test.go b/internal/controlplane/views_story_test.go index 89a01476..feb88bb2 100644 --- a/internal/controlplane/views_story_test.go +++ b/internal/controlplane/views_story_test.go @@ -36,7 +36,8 @@ checkControl(page, page.$("#surla-confirm-open-story"), "the confirm view's link page.$("#surla-confirm-open-story").click(); await until(() => page.$("#surla-story-stage") && page.$("#surla-story-draft").dataset.state === "succeeded", "the Story stage did not open with the current draft"); expect(page.$("#surla-nav-story").getAttribute("aria-current") === "page", "the Story tab is not marked current"); -checkControl(page, page.$("#surla-nav-story"), "Story tab"); +page.$(".surla-frame-project-menu").open = true; +checkControl(page, page.$("#surla-nav-story"), "Story in Inspect"); const context = page.text("#surla-workspace-context"); expect(context.includes("Story") && context.includes("chg-story") && context.includes("current draft succeeded"), "the context strip does not name the Story shown: " + context); @@ -83,7 +84,7 @@ expect(page.doc.activeElement === summary && summary.textContent.includes("3 flo page.$("#surla-nav-cp1").click(); await until(() => page.$("#surla-confirm-submit"), "returning to the change did not show the confirm view"); page.$("#surla-confirm-submit").click(); -await until(() => page.$("#surla-cp1-editor").dataset.requestRevision !== undefined && page.text("#surla-cp1-editor").includes("Agreed:"), "a change with draft flows could not be confirmed"); +await until(() => page.$("#surla-agreement-details"), "a change with draft flows could not be confirmed"); page.close(); `) } @@ -103,15 +104,16 @@ func TestViewsPageStoryStageFollowsTheEvaluationWithoutAChange(t *testing.T) { runPageScript(t, ps, map[string]any{"diagnostic": diagnostic}, viewsPageScriptHelpers+` const page = await openPage(origin, { link: input.link }); await until(() => page.$("#surla-change-list-empty"), "the empty project did not show"); -checkControl(page, page.$("#surla-nav-story"), "Story tab without a change"); +page.$(".surla-frame-project-menu").open = true; +checkControl(page, page.$("#surla-nav-story"), "Story in Inspect without a change"); page.$("#surla-nav-story").click(); await until(() => page.$("#surla-story-draft").dataset.state === "none", "the Story stage did not show the none state"); const announced = () => page.text("#surla-story-draft-announcement"); const liveRegions = () => page.$$("#surla-story-draft [role=status]").length; expect(announced() === "" && liveRegions() === 1, "the none state was announced or the draft has several live regions"); expect(!page.$("#surla-story-change"), "a Story of a change is shown with no change open"); -expect(page.text("#surla-story-draft-none").includes("Ask the guide to refresh the Story"), "the none state does not name the step to take"); -expect(page.text("#surla-frame-next dd").includes("Ask the guide to refresh the Story"), "Story did not surface the available next step"); +expect(page.text("#surla-story-draft-none").includes("Ask your coding agent to refresh the Story"), "the none state does not name the step to take"); +expect(page.text("#surla-frame-next dd").includes("Ask your coding agent to refresh the Story"), "Story did not surface the available next step"); const context = page.text("#surla-workspace-context"); expect(context.includes("Story") && context.includes("current draft none"), "the context strip does not name what is shown: " + context); @@ -168,7 +170,7 @@ const named = (kind) => Array.from(comparison.querySelectorAll('[data-difference expect(JSON.stringify(named("added")) === JSON.stringify(["Exchange instead of refund"]), "added flows: " + JSON.stringify(named("added"))); expect(JSON.stringify(named("removed")) === JSON.stringify(["Partial refund"]), "removed flows: " + JSON.stringify(named("removed"))); expect(JSON.stringify(named("changed")) === JSON.stringify(["Instant refund under the limit"]), "changed flows: " + JSON.stringify(named("changed"))); -expect(page.text("#surla-story-rule") === "The draft is not part of this change until the guide revises the change with it and you confirm the new revision.", "the rule is not stated: " + page.text("#surla-story-rule")); +expect(page.text("#surla-story-rule") === "The draft becomes part of this change after your coding agent proposes it and you confirm the new revision.", "the rule is not stated: " + page.text("#surla-story-rule")); expect(page.$$("#surla-story-change .surla-story-flow").length === 3, "the change's own Story was replaced by the draft"); page.close(); `) diff --git a/internal/controlplane/views_team_test.go b/internal/controlplane/views_team_test.go index 2e254cbb..a598d3e8 100644 --- a/internal/controlplane/views_team_test.go +++ b/internal/controlplane/views_team_test.go @@ -36,9 +36,29 @@ func TestViewsPageDescribeGuideStatusControlsNext(t *testing.T) { next.Roles[0].State = state next.Roles[1].Assignment = "no_work" next.Roles[2].Assignment = "no_work" + next.Roles[2].State = "waiting" f.snapshot = next }) } + for _, mode := range []string{"available", "unavailable"} { + ps.act("external-"+mode, func() { + f.mu.Lock() + defer f.mu.Unlock() + next := pageTeamSnapshot("working") + next.HerdrMode = mode + next.Roles[0].State, next.Roles[0].Watcher = "unknown", "unknown" + next.Roles[2].State = "waiting" + f.snapshot = next + }) + } + ps.act("worker-unknown", func() { + f.mu.Lock() + defer f.mu.Unlock() + next := pageTeamSnapshot("working") + next.HerdrMode = "available" + next.Roles[0].State = "unknown" + f.snapshot = next + }) runPageScript(t, ps, nil, viewsPageScriptHelpers+` await control(origin, "hold", { key: "GET /team" }); const page = await openPage(origin, { link: input.link }); @@ -64,11 +84,24 @@ expect(attention() === "Team status could not be read.", "failed Team status app page.$("#surla-nav-team").click(); await until(() => page.$("#surla-team-role-guide")?.dataset.state === "unknown", "Team did not retry its failed read"); page.$("#surla-nav-changes").click(); -expect(next().includes("refresh to check the guide’s status"), "unknown guide appeared ready or absent"); +expect(next().includes("refresh to check your coding agent’s status"), "unknown attached coding agent appeared ready or absent"); await control(origin, "act", { key: "starting" }); -await until(() => next().includes("Wait for the guide to start"), "a starting guide did not tell the user to wait"); +await until(() => next().includes("Wait for your coding agent to start"), "a starting coding agent did not tell the user to wait"); await control(origin, "act", { key: "working" }); -await until(() => next().includes("Show guide pane and describe your change"), "a working guide did not lead to its existing pane"); +await until(() => !page.$(".surla-frame-slots") && page.$("#surla-empty-show-guide"), "a working attached coding agent did not lead to its existing pane"); +for (const mode of ["available", "unavailable"]) { + await control(origin, "act", { key: "external-" + mode }); + await until(() => !page.$("#surla-empty-show-guide") && !page.$(".surla-frame-slots"), "external coding agent was treated as a Herdr pane"); + expect(page.text("#surla-change-list-title").includes("Describe what you want to build") && + !page.$("#surla-nav-changes") && !page.$(".surla-frame-context"), "healthy empty state kept unnecessary frame chrome"); + page.$("#surla-nav-team").click(); + const codingAgent = page.$("#surla-team-role-guide"); + expect(codingAgent.textContent.includes("Attached in coding agent") && !codingAgent.textContent.includes("Chorus watcher unknown") && + !page.$("#surla-team-show-guide"), "Team showed a false warning or pane action for external mode " + mode); + page.$("#surla-nav-changes").click(); +} +await control(origin, "act", { key: "worker-unknown" }); +await until(() => attention() === "Team status unknown." && next().includes("Open Team"), "a genuinely unobserved worker was hidden with the external guide's expected state"); await control(origin, "act", { key: "ended" }); await until(() => next().includes(connectGuide), "Describe did not explain how to reconnect an ended guide"); page.$("#surla-nav-team").click(); @@ -79,11 +112,8 @@ for (const state of ["ended", "not_started"]) { } page.$("#surla-nav-changes").click(); -await propose("chg-guide-next", "Route refunds to a manager.", "Auto-approved"); -await until(() => page.$("#surla-open-change-chg-guide-next"), "the existing card did not become available"); -expect(next().includes("Open a change"), "guide startup hid the existing card’s next step"); await control(origin, "reply", { key: "GET /changes/chg-guide-next", status: 503, body: { name: "unavailable", message: "Card unavailable." } }); -page.$("#surla-open-change-chg-guide-next").click(); +await propose("chg-guide-next", "Route refunds to a manager.", "Auto-approved"); await until(() => page.$("#surla-change-open-error"), "the failed card read did not appear"); expect(next().includes("Try opening the change again"), "card recovery did not take precedence over ordinary guidance"); page.$("#surla-open-change-chg-guide-next").click(); @@ -124,8 +154,8 @@ const live = page.$("#surla-team-attention"), operation = page.status(); expect(live.getAttribute("role") === "status" && live.getAttribute("aria-live") === "polite", "attention owner is not an announced live region"); expect(live.textContent === "", "idle roles invented an attention state"); await control(origin, "act", { key: "guide-permission" }); -await until(() => page.text("#surla-team-attention-guide").includes("Guide needs you: permission"), "real permission attention was suppressed"); -expect(page.text(".surla-frame-attention dd").includes("Guide needs you: permission") && page.text("#surla-frame-next dd").includes("Show guide pane"), "Describe did not surface the guide’s reported blocker and pane"); +await until(() => page.text("#surla-team-attention-guide").includes("Coding agent needs you: permission"), "real permission attention was suppressed"); +expect(page.text(".surla-frame-attention dd").includes("Coding agent needs you: permission") && page.text("#surla-frame-next dd").includes("Show coding agent pane"), "Describe did not surface the coding agent’s reported blocker and pane"); expect(page.$("#surla-team-attention") === live, "attention arrived in a newly mounted live region"); expect(page.status() === operation, "team attention overwrote operation feedback"); await control(origin, "act", { key: "two-roles" }); diff --git a/internal/controlplane/views_title_test.go b/internal/controlplane/views_title_test.go index cb88c130..4594976e 100644 --- a/internal/controlplane/views_title_test.go +++ b/internal/controlplane/views_title_test.go @@ -18,7 +18,7 @@ await control(origin, "hold", { key: "GET /changes" }); const page = await openPage(origin, { link: input.link }); await until(() => title(page, "Opening project"), "session did not identify its folder while opening"); await control(origin, "release", { key: "GET /changes" }); -await until(() => title(page, "Ask guide to propose a change"), "empty project did not name its next step"); +await until(() => title(page, "Describe your change"), "empty project did not name its next step"); const proposed = await api(origin, "POST", "/changes/propose", { change_id: "chg-title", prompt: "Route refunds to a manager.", analysis: { summary: "Route refunds to a manager.", ambiguities: [], examples: [{ scenario: "Refund", input_summary: "$40", expected_outcome: "Approved", verification_kind: "deterministic" }], preserved_behaviors: [] }, @@ -65,7 +65,7 @@ func TestViewsPageTitleRecoversTeamAndSession(t *testing.T) { runPageScript(t, ps, nil, ` const title = (page, step) => page.doc.title === step + ": Refunds café"; const page = await openPage(origin, { link: input.link }); -await until(() => title(page, "Guide needs you: permission"), "role order or project name is wrong: " + page.doc.title); +await until(() => title(page, "Coding agent needs you: permission"), "role order or project name is wrong: " + page.doc.title); expect(!page.doc.title.includes("page-team"), "title used the sanitized team identity"); page.$("#surla-nav-team").click(); await until(() => page.$("#surla-team-refresh") && !page.$("#surla-team-refresh").disabled, "Team did not open"); @@ -73,9 +73,9 @@ await control(origin, "reply", { key: "GET /team", status: 503, body: { name: "u page.$("#surla-team-refresh").click(); await until(() => title(page, "Refresh Team"), "failed read presented retained attention as current"); page.$("#surla-team-refresh").click(); -await until(() => title(page, "Guide needs you: permission"), "recovered read did not restore current attention"); +await until(() => title(page, "Coding agent needs you: permission"), "recovered read did not restore current attention"); await control(origin, "act", { key: "working" }); -await until(() => title(page, "Ask guide to propose a change"), "working role kept stale needs-you attention"); +await until(() => title(page, "Describe your change"), "working role kept stale needs-you attention"); await control(origin, "act", { key: "needs-you" }); await until(() => title(page, "Builder needs you: question"), "second attention did not arrive"); await control(origin, "reply", { key: "GET /team", status: 401, body: { name: "unauthorized", message: "Session ended." } }); diff --git a/internal/project/views_browser_test.go b/internal/project/views_browser_test.go index 6b4cb197..e847213e 100644 --- a/internal/project/views_browser_test.go +++ b/internal/project/views_browser_test.go @@ -53,6 +53,9 @@ type ( DevTools string `json:"devtools"` // Agreement selects the summary layout and keyboard-reading journey. Agreement bool `json:"agreement,omitempty"` + // Onboarding starts with a connected empty project, then sends its + // first proposal using the fixture's project-scoped guide credential. + Onboarding *onboardingInput `json:"onboarding,omitempty"` // Phone selects the focused Team and Build layout scenario. Phone bool `json:"phone,omitempty"` // Taking selects the focused passed-build layout and consent scenario. @@ -92,6 +95,12 @@ type ( ConfirmBody string `json:"confirm_body"` } + // onboardingInput binds the first proposal to the isolated test project. + onboardingInput struct { + Guide string `json:"guide"` + Proposal json.RawMessage `json:"proposal"` + } + // browserFacts is everything browser_harness.cjs observed in the browser. // Its fields mirror the harness's output exactly; decoding rejects any // other field so the two cannot drift apart silently. @@ -460,6 +469,12 @@ const ( // a reload ending the session, and the browser's cleanup. The Story comes // from a real evaluation of a workspace design, which takes most of a minute. func TestViewsPageInARealBrowser(t *testing.T) { + t.Run("project session", checkViewsSessionInBrowser) + t.Run("first run and agreement at desktop and phone widths", checkOnboardingInBrowser) +} + +// checkViewsSessionInBrowser drives link exchange, the loaded page, and session recovery. +func checkViewsSessionInBrowser(t *testing.T) { executable := findBrowser(t) node, err := exec.LookPath("node") if err != nil { @@ -669,7 +684,7 @@ func TestViewsPageInARealBrowser(t *testing.T) { t.Run("g a reload ends the session", func(t *testing.T) { assert.False(t, facts.Reload.SignedOutTimedOut, "the reloaded page did not say how to open it") assert.Contains(t, facts.Reload.SignedOutText, - "Ask your coding agent to open Surla views, or choose Open Page in the Herdr companion.", + "Ask your coding agent to open Surla views, or choose Open Surla Window in the Herdr companion.", "the reloaded page's recovery routes") assert.Equal(t, origin+"/views", facts.Reload.Href, "the reloaded page's address") assert.Len(t, requestsTo(facts.Reload.PageRequests, http.MethodGet, "/views"), 1, "the reload did not load the page again") @@ -727,6 +742,74 @@ func TestViewsPageInARealBrowser(t *testing.T) { }) } +// checkOnboardingInBrowser exercises the first proposed card through the +// real browser and typed HTTP server without relying on an existing card. +func checkOnboardingInBrowser(t *testing.T) { + executable := findBrowser(t) + node, err := exec.LookPath("node") + if err != nil { + missingPageTool(t, "node is required to drive the browser through its DevTools protocol") + } + skipWithoutNodeWebSocket(t, node) + harness, err := filepath.Abs("../../ui/checkpoint/testing/browser_harness.cjs") + require.NoError(t, err) + capture := os.Getenv("SURLA_TEST_LINK_CAPTURE_DIR") + if capture == "" { + capture = t.TempDir() + } + require.NoError(t, os.MkdirAll(capture, 0o700)) + + vp := startViewsProject(t, controlplane.Options{}) + program := strings.Join([]string{ + `root = DecisionWorkspace("Refund decisions", [matrix, rationale])`, + `matrix = PolicySimulatorTable("Tax threshold comparison", 1, [refund])`, + `refund = PolicySimulatorRow("Order just below the limit", "$48 subtotal plus $4 tax", ["Approve automatically", "Send to a manager"], 1)`, + `rationale = AmbiguityChoiceCard(1, "Including tax can send otherwise identical refunds to different approval paths.")`, + }, "\n") + payload, err := gensurla.EncodeProposeChangePayload(&gensurla.ProposeChangePayload{ + ChangeID: "refund-rules", + Prompt: "Require manager review for refunds above fifty dollars.", + Analysis: &gensurla.CP1Analysis{ + Summary: "Route larger refunds to a manager and leave smaller refunds on the automatic path.", + Ambiguities: []*gensurla.CP1AnalysisAmbiguity{ + { + Question: "Does the manager-review threshold include tax?", + Options: []string{ + "Use the order subtotal so changes to tax alone cannot move an otherwise identical refund into manager review.", + "Use the full amount the customer paid, including tax, to route refunds to the manager when they exceed the threshold.", + }, + }, + { + Question: "What happens when the amount is exactly fifty dollars?", + Options: []string{"Approve the refund automatically.", "Send the refund to a manager for review."}, + }, + }, + Examples: []*gensurla.CP1AnalysisExample{{ + Scenario: "Refund a smaller order", InputSummary: "A customer requests a refund for a $48 order with $4 tax.", + ExpectedOutcome: "The order follows the chosen threshold. The requester sees whether the refund was approved or needs review.", + VerificationKind: "deterministic", + }}, + PreservedBehaviors: []string{}, + UIComposition: &program, + }, + }) + require.NoError(t, err) + guide := vp.agent(t, "guide") + link, err := vp.link() + require.NoError(t, err) + browser := startBrowser(t, executable, t.TempDir()) + driveBrowser(t, node, harness, browserInput{ + DevTools: browser.devtools, Origin: vp.state.Origin(), Link: link, ChangeIDs: []string{}, + CaptureDirectory: capture, Onboarding: &onboardingInput{Guide: guide, Proposal: payload}, + }) + for _, view := range []string{"welcome", "agree"} { + for _, variant := range []string{"desktop-light", "desktop-dark", "phone-light", "phone-dark"} { + assert.FileExists(t, filepath.Join(capture, view+"-"+variant+".png")) + } + } + browser.stopAndCheck(t) +} + // Supervise holds the recorded observations until this test's control plane closes. func (o *phoneTeamOwner) Supervise(ctx context.Context, _ controlplane.AssignmentReader) error { <-ctx.Done() @@ -806,6 +889,7 @@ func TestTeamAndBuildAtPhoneWidth(t *testing.T) { // supervisor owner from three independent, recorded blocked terminal snapshots. vp.state.Record.Team = strings.Repeat("t", 32) vp.state.Record.Space = "phone-space" + vp.state.Record.Tab = "phone-tab" guide := "" for _, role := range []string{"guide", "builder", "test_writer"} { handle := role + strings.Repeat("x", 32-len(role)) diff --git a/internal/project/views_page_test.go b/internal/project/views_page_test.go index bdf536ba..3cc345f7 100644 --- a/internal/project/views_page_test.go +++ b/internal/project/views_page_test.go @@ -80,7 +80,7 @@ func TestViewsPageSessionLifecycle(t *testing.T) { // Recovery stays available through the agent or companion without a shell step. const expectRecovery = (page, selector) => { const text = page.text(selector); - expect(text.includes("coding agent") && text.includes("Open Page") && text.includes("Herdr companion"), "session recovery omitted the coding-agent or companion entry point: " + text); + expect(text.includes("coding agent") && text.includes("Open Surla Window") && text.includes("Herdr companion"), "session recovery omitted the coding-agent or companion entry point: " + text); expect(!text.includes("Run surla") && !text.includes("run surla"), "session recovery still requires a typed terminal command: " + text); }; // Without a link the page explains how to open it and asks the server nothing. diff --git a/ui/checkpoint/src/app.tsx b/ui/checkpoint/src/app.tsx index 7f9035ac..a1605e14 100644 --- a/ui/checkpoint/src/app.tsx +++ b/ui/checkpoint/src/app.tsx @@ -28,7 +28,7 @@ import { ApprovalStage } from "./components/approval-stage"; import { WorkspaceFrame } from "./components/workspace-frame"; import { SessionEndedNotice, SignedOutReason, SignedOutView } from "./components/session"; import { StoryStageView } from "./components/story"; -import { GlobalTeamAttention, TeamFactsError, TeamStageProps, TeamStageView, teamAttentionText } from "./components/team"; +import { GlobalTeamAttention, roleHasPane, TeamFactsError, TeamStageProps, TeamStageView, teamAttentionText } from "./components/team"; import { LiveTargetStageView, ModelDraft, ServerAnswer, describeApplied } from "./components/live-target"; import { Alert, Button, Card } from "./components/shadcn"; import { TraceDrawer, TraceFilter } from "./components/trace-drawer"; @@ -113,7 +113,7 @@ interface ActiveEditorState { // preservedDraft retains unsaved draft edits from an earlier revision. preservedDraft: PreservedDraft | null; // formError describes the latest failed editor request or invalid input. - formError: string | null; + formError: { message: string; source: "input" | "request" } | null; // proposalAnswers holds the user's choices for the waiting proposal's // questions; a re-read keeps those that still fit the proposal. proposalAnswers: Record; @@ -386,13 +386,15 @@ function describeActiveResultSubject( if ( !activeResult || activeResult.kind === "cp1-incoming-card" || - activeResult.kind === "changes" || activeResult.kind === "live" || activeResult.kind === "team" ) { return null; } const label = bothRegionsShown ? "Displayed view" : "Showing"; + if (activeResult.kind === "changes") { + return bothRegionsShown ? { role: "result", label, stage: "Project changes" } : null; + } if (activeResult.kind === "story") { let draft = "current draft not read yet"; if (storyEvaluation !== null) { @@ -804,7 +806,7 @@ export function bootstrapViewsPage() { // sessionEndedMessage tells the user what to do once the session is gone. function sessionEndedMessage(): string { - return "This page's Surla session has ended. Ask your coding agent to open Surla views, or choose Open Page in the Herdr companion."; + return "This page's Surla session has ended. Ask your coding agent to open Surla views, or choose Open Surla Window in the Herdr companion."; } // start exchanges the link from the address fragment for a session, removes @@ -843,8 +845,8 @@ export function bootstrapViewsPage() { rootEl.dataset.state = reason === "link-used" ? "link-used" : "signed-out"; statusEl.textContent = reason === "link-used" - ? "This link was already used. Ask your coding agent to open Surla views, or choose Open Page in the Herdr companion." - : "Ask your coding agent to open Surla views, or choose Open Page in the Herdr companion."; + ? "This link was already used. Ask your coding agent to open Surla views, or choose Open Surla Window in the Herdr companion." + : "Ask your coding agent to open Surla views, or choose Open Surla Window in the Herdr companion."; syncAllRegions(); } @@ -935,14 +937,16 @@ export function bootstrapViewsPage() { return pending; } - // applyListChanges opens the only change on the first read and otherwise - // re-reads the open card or its runs only when their list entry changed. + // applyListChanges opens the only change on the first read or when the + // first proposal arrives on the empty Changes view. Later reads preserve + // the current editor and reconcile its saved facts by change ID. function applyListChanges(previous: ChangeList | null, next: ChangeList) { + if (activeEditor === null && next.changes.length === 1 && + (previous === null || (previous.changes.length === 0 && activeResult?.kind === "changes"))) { + openChange(next.changes[0].change_id); + return; + } if (previous === null) { - if (next.changes.length === 1 && activeEditor === null) { - openChange(next.changes[0].change_id); - return; - } if (activeResult?.kind === "changes") { statusEl.textContent = next.changes.length === 0 @@ -1112,8 +1116,8 @@ export function bootstrapViewsPage() { if (after !== undefined && before?.request_revision !== after.request_revision) { statusEl.textContent = (before === undefined - ? "The guide proposed a new revision of this change." - : "The guide replaced its proposed revision of this change.") + + ? "Your coding agent proposed a new revision of this change." + : "Your coding agent replaced its proposed revision of this change.") + " Adopt or decline it in Agree; the agreed revision stays in force until then."; } syncAllRegions(); @@ -1751,7 +1755,7 @@ export function bootstrapViewsPage() { text: "Surla can use it for both workers. A second model family can give the builder and test writer different perspectives.", }); if (snapshot.herdr_mode === "available") notices.push({ - notice: "outside_herdr", title: "Your guide is outside Herdr.", + notice: "outside_herdr", title: "Your coding agent is outside Herdr.", text: "Workers will open in the project’s Herdr tab. Starting them selects that tab without bringing the Herdr window to the foreground. You can keep using this coding-agent session.", }); if (snapshot.herdr_mode === "unavailable") notices.push({ @@ -1798,6 +1802,14 @@ export function bootstrapViewsPage() { return null; } + // connectedGuide finds a registered guide that can still follow the project, + // including a guide whose terminal state Herdr cannot observe. + function connectedGuide(): TeamRoleState | undefined { + return teamSnapshot?.roles.find((role) => + role.role === "guide" && role.state !== "not_started" && role.state !== "ended" + ); + } + // showingTeamRoles derives pending controls from the registered snapshot, // preserving the generated role type instead of casting arbitrary subjects. function showingTeamRoles(): TeamRoleState["role"][] { @@ -2155,7 +2167,7 @@ export function bootstrapViewsPage() { buildSnapshot = result.build; buildDraftedBeforeDrop = result.drafted_before_drop; } - statusEl.textContent = "The build was dropped. Ask the guide to refresh its draft before revising; adopt the revision, then build."; + statusEl.textContent = "The build was dropped. Ask your coding agent to refresh its draft and propose a revision. Adopt the revision before building again."; readBuild(selected); refreshOpenCard(selected); refreshVerificationObservations(selected); @@ -2174,20 +2186,21 @@ export function bootstrapViewsPage() { // showTeamPane sends only the registered role the user selected; the server // rechecks ownership and open dialogs before it changes the window. function showTeamPane(role: TeamRoleState["role"]) { - if (sessionState !== "active" || teamSnapshot?.herdr_mode === "unavailable" || + if (sessionState !== "active" || !roleHasPane(role, teamSnapshot?.herdr_mode) || hasPending("show_team_pane", role)) return; teamActionError = null; + const label = role === "guide" ? "coding agent" : role.replaceAll("_", " "); callServer( "show_team_pane", { role }, role, () => { if (sessionState !== "active") return; - statusEl.textContent = "The " + role.replaceAll("_", " ") + "'s pane is shown in Herdr."; + statusEl.textContent = "The " + label + "'s pane is shown in Herdr."; readTeam(); }, (message) => { if (sessionState !== "active") return; teamActionError = message; - statusEl.textContent = "Could not show the " + role.replaceAll("_", " ") + "'s pane. " + message; + statusEl.textContent = "Could not show the " + label + "'s pane. " + message; } ); } @@ -2443,12 +2456,12 @@ export function bootstrapViewsPage() { active: boolean; onClick: () => void; }[] = []; - tabs.push({ - id: "surla-nav-changes", - label: "Describe", - active: activeResult?.kind === "changes", - onClick: showChanges, - }); + const onDescribe = activeResult?.kind === "changes"; + const changesLabel = changeList !== null && (changeList.changes.length > 0 || activeEditor !== null) + ? "Changes" : "Describe"; + if (!onDescribe || changeList === null || changeList.changes.length > 0 || activeEditor !== null) { + tabs.push({ id: "surla-nav-changes", label: changesLabel, active: onDescribe, onClick: showChanges }); + } tabs.push({ id: "surla-nav-team", label: "Team", @@ -2564,6 +2577,22 @@ export function bootstrapViewsPage() { const review = displayedApprovalReview(); const onApproval = activeResult?.kind === "cp5-approval"; const fresh = run !== null && approvalReviewFresh(run); + const teamError = teamFactsError(); + const teamLoading = hasPending("get_team", ""); + const teamStarting = hasPending("start_team_agents", ""); + const teamRoles = teamSnapshot?.roles ?? []; + const herdrMode = teamSnapshot?.herdr_mode; + const guideInHerdr = herdrMode === "attached"; + const herdrWorkerAvailable = herdrMode !== "unavailable"; + const guide = connectedGuide(); + const teamNeedsYou = teamRoles.find((role) => role.state === "needs_you"); + const teamStatusUnknown = teamRoles.some((role) => role.state === "error" || + (role.state === "unknown" && (role.role !== "guide" || guideInHerdr))); + const showSlots = !(onDescribe && !editorOpen && listError === null && + (lastOpenAttempt === null || !cardLoadErrors.has(lastOpenAttempt)) && + changeList !== null && changeList.changes.length === 0 && teamError === null && + !teamLoading && !teamStarting && teamSnapshot !== null && teamNeedsYou === undefined && + !teamStatusUnknown && guide !== undefined && (!guideInHerdr || guide.state !== "starting")); let attention = "Nothing now."; let next: React.ReactNode = null; if (onApproval) { @@ -2625,15 +2654,15 @@ export function bootstrapViewsPage() { next = Review the current agreement before deciding to build again.; } else if (build.taking.state === "dropped") { attention = "This build was dropped."; - next = The guide prepares a fresh revision before another build.; + next = Your coding agent prepares a fresh revision before another build.; } else if (build.taking.state === "merged") { attention = "The verified commits are merged."; next = Describe the next change when you are ready.; } else if (tests.state === "needs_changes") { - const needs = teamFactsError() === null ? (teamSnapshot?.roles ?? []).filter((role) => role.state === "needs_you") : []; + const needs = teamError === null ? teamRoles.filter((role) => role.state === "needs_you") : []; attention = needs.length > 0 - ? needs.map((role) => teamAttentionText(role, teamSnapshot?.herdr_mode !== "unavailable")).join(". ") - : teamFactsError() !== null || teamSnapshot === null || teamSnapshot.roles.some((role) => role.state === "unknown" || role.state === "error") + ? needs.map((role) => teamAttentionText(role, roleHasPane(role.role, herdrMode))).join(". ") + : teamError !== null || teamSnapshot === null || teamStatusUnknown ? "Team status unknown." : "Nothing now."; next = The test writer corrects the tests and reports again.; } else if (tests.state === "could_not_run") { @@ -2664,29 +2693,20 @@ export function bootstrapViewsPage() { next = ; attention = "Read the saved test evidence, then review the result for approval."; } - const onDescribe = activeResult?.kind === "changes"; if (next === null) { // Recovery takes precedence over guidance based on retained observations. - const teamError = teamFactsError(); - const teamLoading = hasPending("get_team", ""); - const teamStarting = hasPending("start_team_agents", ""); - const teamRoles = teamSnapshot?.roles ?? []; - const herdrAvailable = teamSnapshot?.herdr_mode !== "unavailable"; - const teamNeedsYou = teamRoles.find((role) => role.state === "needs_you"); - const guide = teamRoles.find((role) => role.role === "guide"); - const guideNeedsConnection = guide === undefined || guide.state === "not_started" || guide.state === "ended"; const connectGuide = "Connect your coding agent to this project’s Surla MCP server."; - attention = teamNeedsYou !== undefined ? teamAttentionText(teamNeedsYou, herdrAvailable) + attention = teamNeedsYou !== undefined ? teamAttentionText(teamNeedsYou, roleHasPane(teamNeedsYou.role, herdrMode)) : teamLoading || teamSnapshot === null ? "Waiting for Team status." - : teamRoles.some((role) => role.state === "unknown" || role.state === "error") ? "Team status unknown." + : teamStatusUnknown ? "Team status unknown." : "Nothing now."; let step: string | React.ReactElement; if (sessionState !== "active") { attention = "The session ended."; - step = "Ask your coding agent to open Surla views, or choose Open Page in the Herdr companion."; + step = "Ask your coding agent to open Surla views, or choose Open Surla Window in the Herdr companion."; } else if (listError !== null) { attention = "The changes could not be read."; - step = onDescribe ? "Choose Read the changes again below." : "Open Describe to retry reading changes."; + step = onDescribe ? "Choose Read the changes again below." : "Open " + changesLabel + " to retry reading changes."; } else if (waitTroubleShown) { attention = "Updates are unavailable."; step = "Wait for Surla to reconnect."; @@ -2695,7 +2715,7 @@ export function bootstrapViewsPage() { step = activeResult?.kind === "team" ? "Choose Retry team read below." : "Open Team to retry reading roles."; } else if (lastOpenAttempt !== null && lastOpenAttempt !== activeEditor?.card.change_id && cardLoadErrors.has(lastOpenAttempt)) { attention = "The Change Card could not be opened."; - step = onDescribe ? "Try opening the change again below." : "Open Describe and try opening the change again."; + step = onDescribe ? "Try opening the change again below." : "Open " + changesLabel + " and try opening the change again."; } else if (activeEditor !== null && cardLoadErrors.has(activeEditor.card.change_id)) { attention = "The latest saved Change Card could not be read."; step = editorRequest !== null ? "Wait for the current Change Card request." @@ -2711,27 +2731,29 @@ export function bootstrapViewsPage() { step = "Open a change from the list below."; } else if (teamLoading || teamSnapshot === null) { step = "Wait for Team status."; - } else if (guideNeedsConnection) { - if (teamNeedsYou === undefined) attention = "Guide needed."; + } else if (guide === undefined) { + if (teamNeedsYou === undefined) attention = "Coding agent needed."; step = connectGuide + " Then describe your change."; - } else if (!herdrAvailable) { - step = guide.state === "needs_you" ? "Return to your coding agent to address the guide’s request." - : "Describe your change in your coding agent."; + } else if (!guideInHerdr) { + step = guide.state === "needs_you" ? "Return to your coding agent to address its request." + : guide.state === "error" ? "Return to your coding agent to check its error." + : teamStatusUnknown && teamNeedsYou === undefined ? "Open Team to check role status." + : "Describe what you want to build in your coding agent."; } else if (guide.state === "starting") { - step = "Wait for the guide to start."; + step = "Wait for your coding agent to start."; } else if (guide.state === "unknown" || guide.state === "error") { if (teamNeedsYou === undefined) { - attention = guide.state === "unknown" ? "Guide status unknown." : "The guide reported an error."; + attention = guide.state === "unknown" ? "Coding agent status unknown." : "Your coding agent reported an error."; } - step = "Open Team and refresh to check the guide’s status."; + step = "Open Team and refresh to check your coding agent’s status."; } else if (guide.state === "needs_you") { - step = "In Team, choose Show guide pane to address the guide’s request."; + step = "In Team, choose Show coding agent pane to address its request."; } else { - step = "In Team, choose Show guide pane and describe your change."; + step = "Choose Show coding agent pane below to describe your change."; } } else if (cp1Active && activeEditor !== null) { const ed = activeEditor; - if (editorRequest !== null) { + if (editorRequest !== null && editorRequest !== "confirm_intent") { step = "Wait for the current Change Card request."; } else if (ed.incomingCard !== null) { attention = "A newer saved revision is available."; @@ -2739,12 +2761,30 @@ export function bootstrapViewsPage() { } else if (editorStage === "agree" && ed.card.proposed_revision !== undefined) { attention = "A proposed revision is waiting for your decision."; step = "Review the proposal below, then choose Adopt or Decline."; - } else if (ed.formError !== null) { + } else if (ed.formError?.source === "request") { attention = "The Change Card request failed."; step = "Choose Load Latest Card to review the saved card alongside your edits."; + } else if (ed.card.status === "needs_confirmation" && editorStage === "agree") { + const unanswered = unansweredQuestions(ed); + const question = unanswered[0]; + const exampleIssue = firstIncompleteExample(ed); + const confirming = editorRequest === "confirm_intent"; + if (question !== undefined) { + attention = unanswered.length === 1 ? "1 question to answer." : unanswered.length + " questions to answer."; + step = ; + } else if (exampleIssue !== null) { + attention = "An example needs " + exampleIssue.label + "."; + step = ; + } else { + attention = confirming ? "Saving your agreement." : "Ready to confirm intent."; + step = ; + } } else if (ed.card.status === "needs_confirmation") { attention = "This change needs confirmation."; - step = "Review the questions and examples below, then confirm the change."; + step = "Open Agree to review and confirm the change."; } else if (editorStage === "build") { step = "Review the Build controls below for this change."; } else if (ed.preservedDraft !== null) { @@ -2773,8 +2813,9 @@ export function bootstrapViewsPage() { step = teamStarting ? "Wait for workers to start." : teamLoading || teamSnapshot === null ? "Wait for Team status." : teamNeedsYou === undefined && teamWorkersHaveWork() ? "Use Start workers to bring up missing build workers." - : guideNeedsConnection ? connectGuide - : herdrAvailable ? "Review role status and use Show pane to contact an agent." + : guide === undefined ? connectGuide + : guideInHerdr || (herdrWorkerAvailable && teamRoles.some((role) => role.role !== "guide")) + ? "Review role status and use Show pane to contact an agent." : "Review role status below."; } else if (activeResult?.kind === "story") { if (storyEvaluationError !== null) { @@ -2782,9 +2823,9 @@ export function bootstrapViewsPage() { step = "Choose Read the draft again below."; } else { step = storyEvaluation === null ? "Wait for Surla to read the Story draft." - : storyEvaluation.state === "none" ? "Ask the guide to refresh the Story." + : storyEvaluation.state === "none" ? "Ask your coding agent to refresh the Story." : storyEvaluation.state === "running" ? "Wait for the Story evaluation." - : storyEvaluation.state === "failed" ? "Ask the guide to fix the Story and refresh it." + : storyEvaluation.state === "failed" ? "Ask your coding agent to fix the Story and refresh it." : "Review the current draft and any saved Story below."; } } else if (activeResult?.kind === "live") { @@ -2801,7 +2842,7 @@ export function bootstrapViewsPage() { : "Review the last live target’s status below."; } } else { - step = "Open Describe to find a change."; + step = "Open " + changesLabel + " to find a change."; } next = typeof step === "string" ? {step} : step; } @@ -2813,9 +2854,9 @@ export function bootstrapViewsPage() { journeyIds.has(tab.id))} references={tabs.filter((tab) => !journeyIds.has(tab.id))} - agreed={agreedCard?.summary ?? "No confirmed agreement opened"} + agreed={agreedCard?.summary ?? null} onReadFullSummary={agreedCard !== null ? handleReadFullSummary : null} - attention={attention} next={next} + showSlots={showSlots} attention={attention} next={next} diagnosticsOpen={traceOpen} onToggleDiagnostics={() => { traceOpen = !traceOpen; if (traceOpen && tracePage === null) loadTracePage(); @@ -2891,7 +2932,7 @@ export function bootstrapViewsPage() { teamSnapshot?.roles.find((item) => item.role === role && item.state === "needs_you") ).find((role) => role !== undefined); if (attention !== undefined) { - step = teamAttentionText(attention, teamSnapshot?.herdr_mode !== "unavailable"); + step = teamAttentionText(attention, roleHasPane(attention.role, teamSnapshot?.herdr_mode)); } else if (activeEditor !== null) { const ed = activeEditor; if (ed.incomingCard !== null || ed.card.proposed_revision !== undefined) { @@ -2906,7 +2947,7 @@ export function bootstrapViewsPage() { } else if (changeList === null) { step = "Opening project"; } else { - step = changeList.changes.length === 0 ? "Ask guide to propose a change" : "Open a change"; + step = changeList.changes.length === 0 ? "Describe your change" : "Open a change"; } } return step + ": " + projectName; @@ -2950,6 +2991,9 @@ export function bootstrapViewsPage() { onFocusedControlRemoved={focusCurrentViewHeading} /> ) : null} + {teamActionError !== null && activeResult?.kind !== "team" ? ( + {teamActionError} + ) : null} ); }); @@ -3069,7 +3113,7 @@ export function bootstrapViewsPage() { loadingVerifications={hasPending("list_verifications", ed.card.change_id)} cp4Open={activeResult?.kind === "cp4-verification"} preservedDraft={ed.preservedDraft} - formError={ed.formError} + formError={ed.formError?.message ?? null} onSetAnswer={(ambId, opt) => { if (!activeEditor || editorRequest !== null) { return; @@ -3077,6 +3121,7 @@ export function bootstrapViewsPage() { activeEditor = { ...activeEditor, draftAnswers: { ...activeEditor.draftAnswers, [ambId]: opt }, + formError: activeEditor.formError?.source === "input" ? null : activeEditor.formError, }; syncAllRegions(); }} @@ -3089,12 +3134,13 @@ export function bootstrapViewsPage() { draftExamples: activeEditor.draftExamples.map((item) => item.id === exId ? { ...item, [field]: value } : item ), + formError: activeEditor.formError?.source === "input" ? null : activeEditor.formError, }; syncAllRegions(); }} onSubmitConfirm={handleConfirmSubmit} onDiscardDraft={handleDiscardDraft} - onLoadLatestCard={handleLoadLatestCard} + onLoadLatestCard={ed.formError?.source === "input" ? null : handleLoadLatestCard} onLoadVerifications={() => handleListVerifications(ed.card.change_id)} onOpenStory={openStory} onReviewApproval={openRecordedApproval} @@ -3171,6 +3217,11 @@ export function bootstrapViewsPage() { openError={lastOpenAttempt !== null ? cardLoadErrors.get(lastOpenAttempt) ?? null : null} openChangeId={activeEditor ? activeEditor.card.change_id : null} busy={editorRequest !== null} + guideConnected={connectedGuide() !== undefined} + guideInHerdr={teamSnapshot?.herdr_mode === "attached"} + disabled={sessionState !== "active"} + showingGuide={hasPending("show_team_pane", "guide")} + onShowGuidePane={() => showTeamPane("guide")} onOpen={openChange} onRetry={() => void loadChanges()} /> @@ -3372,6 +3423,7 @@ export function bootstrapViewsPage() { // syncAllRegions synchronizes the notice, editor, result, nav, and trace regions. function syncAllRegions() { + statusEl.toggleAttribute("data-connection-warning", waitTroubleShown); viewEl.classList.toggle( "surla-split-workspace", Boolean(activeEditor !== null && editorOpen && activeResult !== null) @@ -3837,14 +3889,14 @@ export function bootstrapViewsPage() { // showFormError reports a failed read, save or input check without changing // the saved snapshot or discarding draft text. - function showFormError(msg: string) { + function showFormError(message: string, source: "input" | "request" = "request") { if (!activeEditor) { return; } - statusEl.textContent = "Change Card request failed; unsaved edits preserved."; + statusEl.textContent = source === "input" ? message : "Change Card request failed; unsaved edits preserved."; activeEditor = { ...activeEditor, - formError: String(msg), + formError: { message, source }, }; syncAllRegions(); } @@ -3858,32 +3910,56 @@ export function bootstrapViewsPage() { } } + // unansweredQuestions is shared by Next's progress and confirmation + // validation, including questions rendered by a decision instrument. + function unansweredQuestions(editor: ActiveEditorState) { + return (editor.card.ambiguities ?? []).filter((question) => + !Object.prototype.hasOwnProperty.call(editor.draftAnswers, question.id) || !editor.draftAnswers[question.id] + ); + } + + // focusDraftQuestion locates whichever renderer owns the current question. + function focusDraftQuestion(questionId: string) { + Array.from(editorRegionEl.querySelectorAll("button[data-ambiguity-id]")) + .find((option) => option.dataset.ambiguityId === questionId)?.focus(); + } + + // firstIncompleteExample locates the field blocking confirmation in the + // same order that the user reads the example. + function firstIncompleteExample(editor: ActiveEditorState) { + for (const [index, example] of editor.draftExamples.entries()) { + const blank = !example.scenario.trim() ? { field: "scenario", label: "a scenario" } + : !example.input_summary.trim() ? { field: "input_summary", label: "an input" } + : !example.expected_outcome.trim() ? { field: "expected_outcome", label: "an expected result" } : null; + if (blank !== null) return { ...blank, exampleId: example.id, number: index + 1 }; + } + return null; + } + + // focusDraftExample locates a bound example field without interpolating its + // owner-provided ID into a selector. + function focusDraftExample(issue: { exampleId: string; field: string }) { + Array.from(editorRegionEl.querySelectorAll("textarea[data-example-id]")) + .find((field) => field.dataset.exampleId === issue.exampleId && field.dataset.field === issue.field)?.focus(); + } + // handleConfirmSubmit sends complete answers and examples for the displayed // saved revision after checking that the user filled every required value. function handleConfirmSubmit() { if (!activeEditor || editorRequest !== null) { return; } - const ambiguities = Array.isArray(activeEditor.card.ambiguities) - ? activeEditor.card.ambiguities - : []; - for (let i = 0; i < ambiguities.length; i++) { - const ambId = ambiguities[i].id; - if (!Object.prototype.hasOwnProperty.call(activeEditor.draftAnswers, ambId) || !activeEditor.draftAnswers[ambId]) { - showFormError("Select an option for ambiguity " + ambId + " before confirming."); - focusResult("#surla-confirm-error"); - return; - } + const unanswered = unansweredQuestions(activeEditor)[0]; + if (unanswered !== undefined) { + showFormError("Choose an answer for “" + unanswered.question + "” before confirming.", "input"); + focusDraftQuestion(unanswered.id); + return; } - for (let j = 0; j < activeEditor.draftExamples.length; j++) { - const item = activeEditor.draftExamples[j]; - if (!item.scenario.trim() || !item.input_summary.trim() || !item.expected_outcome.trim()) { - showFormError( - "Example " + item.id + " requires non-empty scenario, input_summary, and expected_outcome." - ); - focusResult("#surla-confirm-error"); - return; - } + const exampleIssue = firstIncompleteExample(activeEditor); + if (exampleIssue !== null) { + showFormError("Enter " + exampleIssue.label + " for example " + exampleIssue.number + ".", "input"); + focusDraftExample(exampleIssue); + return; } activeEditor = { ...activeEditor, diff --git a/ui/checkpoint/src/components/build.tsx b/ui/checkpoint/src/components/build.tsx index b14ca02e..20e5b7f3 100644 --- a/ui/checkpoint/src/components/build.tsx +++ b/ui/checkpoint/src/components/build.tsx @@ -387,9 +387,8 @@ export function BuildSectionView({ {observations}{progress}{explanation}
{actions}
: null} {draftedBeforeDrop === true ?

- This agreement was drafted before a build was dropped; ask the guide to refresh its draft with refresh_story - {" and propose a revision from that refresh with "}revise_change, then adopt that revision before building. - {" A proposal already waiting may predate the drop; adopting it alone may not enable Build."} + This agreement was drafted before a build was dropped. Ask your coding agent to refresh its draft and propose a + revision from the refreshed Story. Adopt that revision before building. A proposal already waiting may predate the drop.

: null} {!confirmed ?

Confirm the change before building it.

: !displayedCurrent ? (

A newer agreed revision is available. Review it before starting a build.

@@ -540,7 +539,7 @@ export function BuildTakingView({ changeId, build, disabled, dropping, onDrop, o }}>

Drop change {changeId}?

-

Surla will not build on it. Its commits stay on this build’s branches, your branch is unchanged, and the guide’s draft starts again from your branch; edits it has not proposed are lost.

+

The build’s commits stay on its branches. Your coding agent starts a fresh draft from your branch. Any draft edits it has yet to propose are lost.

Architecture of the agreed revision’s saved design. Draft edits appear here only after - the guide proposes a revision and you adopt it. + your coding agent proposes a revision and you adopt it.

This preview shows what the design declares. It does not diff --git a/ui/checkpoint/src/components/change-list.tsx b/ui/checkpoint/src/components/change-list.tsx index 1530e7af..7dd05f3b 100644 --- a/ui/checkpoint/src/components/change-list.tsx +++ b/ui/checkpoint/src/components/change-list.tsx @@ -21,6 +21,13 @@ export interface ChangeListViewProps { openChangeId: string | null; // busy disables opening while a Change Card request is outstanding. busy: boolean; + // guideConnected and guideInHerdr describe the guide the project reports. + guideConnected: boolean; + guideInHerdr: boolean; + // disabled and showingGuide prevent a duplicate or expired pane request. + disabled: boolean; + showingGuide: boolean; + onShowGuidePane: () => void; // onOpen opens one change by its change_id. onOpen: (changeId: string) => void; // onRetry reads the list again after a failure. @@ -45,9 +52,43 @@ export function ChangeListView({ openError, openChangeId, busy, + guideConnected, + guideInHerdr, + disabled, + showingGuide, + onShowGuidePane, onOpen, onRetry, }: ChangeListViewProps) { + if (list !== null && list.changes.length === 0 && error === null && openError === null) { + return ( + +

+ {guideConnected ? "Describe what you want to build in your coding agent" : "Start in your coding agent with /surla"} +

+

+ {guideConnected + ? "Your coding agent drafts the Change Card. It opens here when it’s ready." + : <>Open your coding agent in this folder and invoke /surla ($surla in Codex) + to connect it, then describe what you want to build. Your Change Card will appear here automatically.} +

+ {guideConnected && guideInHerdr ? ( +
+ +
+ ) : null} +
    +
  1. Confirm intent Answer open questions and lock concrete examples before code is written.
  2. +
  3. Build & verify Surla coordinates implementation and independent checks.
  4. +
  5. Approve & merge Review the verified evidence and merge the change into your branch.
  6. +
+ + ); + } return ( item.latest_verification !== undefined) ? (

Run results describe their recorded candidate. The server compares each latest run - with the agreed revision and selected tests. Open a change, then Proof, to inspect it. + with the agreed revision and selected tests. Open a change, then Check, to inspect it.

) : null} {error !== null ? ( @@ -80,12 +121,7 @@ export function ChangeListView({ ) : null} {list === null ? ( error === null ?

Reading this project's changes...

: null - ) : list.changes.length === 0 ? ( -

- This project has no changes yet. Ask the guide to propose a change; it appears here - by itself. -

- ) : ( + ) : list.changes.length > 0 ? (
    {list.changes.map((item) => ( ))}
- )} + ) : null}
); } diff --git a/ui/checkpoint/src/components/cp1-editor.tsx b/ui/checkpoint/src/components/cp1-editor.tsx index 77547710..5b0a21b6 100644 --- a/ui/checkpoint/src/components/cp1-editor.tsx +++ b/ui/checkpoint/src/components/cp1-editor.tsx @@ -17,7 +17,7 @@ import { validateCompletedOpenUI, } from "../openui/library"; import { ChangeCardResult, ExampleItem } from "../types"; -import { Alert, Badge, Button, Card } from "./shadcn"; +import { Alert, Badge, Button, Card, CardFooter, ChoiceGroup, Label, Separator, Textarea } from "./shadcn"; import { countsPhrase, storyCounts } from "./story"; export interface CP1EditorProps { @@ -46,7 +46,7 @@ export interface CP1EditorProps { ) => void; onSubmitConfirm: () => void; onDiscardDraft: () => void; - onLoadLatestCard: () => void; + onLoadLatestCard: (() => void) | null; onLoadVerifications: () => void; // onOpenStory shows the Story stage for this change. onOpenStory: () => void; @@ -86,15 +86,14 @@ function FieldTextarea({ if (!node) { return; } - const handleInput = (evt: Event) => { - const target = (evt.target as HTMLTextAreaElement) || node; + const handleInput = () => { if (disabledRef.current) { - target.value = valueRef.current; + node.value = valueRef.current; return; } - if (typeof target.value === "string" && target.value !== valueRef.current) { + if (node.value !== valueRef.current) { flushSync(() => { - onChangeRef.current(target.value); + onChangeRef.current(node.value); }); } }; @@ -111,13 +110,12 @@ function FieldTextarea({ }, [value]); return ( -