Add Done to recheck granted access
Done now sits beside Grant access on initial and live-updated cards, and resolves them only after access is verified. Repeat clicks and stale cards are guarded without creating tasks or replaying completed work. I preserved guided, explicitly scoped onboarding as a separate design follow-up. JavaScript syntax checks passed, but dependency restrictions blocked Go tests, and browser accessibility and mobile checks remain outstanding. Equipo task tknitqeua7yy, Engineering step attempt 1.
14 files changed,
+224
−49
docs/access-recovery-follow-up.md+33 −0internal/equipo/chat/projects.go+4 −2internal/equipo/chat/tools.go+20 −1internal/equipo/chat_page.go+9 −0internal/equipo/copy.go+32 −28internal/equipo/migrations/0060_access_check.sql+1 −0internal/equipo/migrations/schema.sql+1 −1internal/equipo/static/chat-stream.js+41 −2internal/equipo/static/equipo.css+5 −0internal/equipo/templates/chat.html+1 −1internal/runner/thin/run.go+11 −4internal/thintest/pages_test.go+9 −0internal/thintest/tasks_contract_test.go+45 −0internal/wire/api.go+12 −10
CI failed — run details
diff --git a/docs/access-recovery-follow-up.md b/docs/access-recovery-follow-up.md| new file mode 100644 |
| index 00000000..f239cf13 |
| --- /dev/null |
| +++ b/docs/access-recovery-follow-up.md |
| @@ -0,0 +1,33 @@ |
| +# Access recovery and guided setup |
| + |
| +Done is the existing Check now action, visible without opening Grant access. |
| +It requests fresh permission and repository discovery, never a grant. The card |
| +stays open until the runner reports the intended repository in its catalog. |
| +Missing access and unavailable runners are retryable. Revision checks prevent |
| +replaying the same click from queuing another check. No tasks or messages are |
| +created by Done, and no completed coordinator turn is replayed. An active |
| +workflow can observe the refreshed catalog through its existing tools; safely |
| +resuming an already-ended turn needs an explicit continuation contract and is |
| +not introduced here. |
| + |
| +Follow-up: make guided in-app onboarding establish repository hosting and |
| +access before the first task. Ask which host, account, repositories and creation |
| +namespaces the person intends to use. Explain read, clone, write, repository |
| +creation and runner execution scopes separately, obtain explicit consent for |
| +each required scope, and verify discovery with the selected runner before |
| +finishing. Include unavailable-host and offline-runner recovery, show precisely |
| +what remains missing, and allow skipping optional permissions. Never infer a |
| +blanket grant from connecting a host. Keep access cards as exception recovery |
| +for later revocation, changed scope or newly requested repositories. |
| + |
| +Validation: contract coverage exercises verified and unrelated catalogs, |
| +checking/missing feedback, retries, offline runners, repeat submissions and stale |
| +resolved cards. Page |
| +coverage verifies Done is outside the closed disclosure and has status feedback. |
| +CSS allows wrapping on narrow screens. Keyboard, screen-reader announcements, |
| +focus after feed replacement and mobile rendering still need browser review. |
| + |
| +JavaScript syntax validation passed. Go tests could not run in this environment: |
| +dependencies were not cached, network downloads were blocked, and the requested |
| +escalation was unavailable. Run the thintest, runner/thin, equipo/chat and wire |
| +packages before approval. No browser validation was performed here. |
diff --git a/internal/equipo/chat/projects.go b/internal/equipo/chat/projects.go| index beb473be..f3cb9518 100644 |
| --- a/internal/equipo/chat/projects.go |
| +++ b/internal/equipo/chat/projects.go |
| @@ -52,7 +52,8 @@ type cardRecord struct { |
| // TaskID names the task a task card reports. |
| TaskID string `gorm:"index:chat_card_task"` |
| // Name is an access card's namespace, when the name looked for says it. |
| - Name string |
| + Name string |
| + AccessCheck string |
| // Undo is a home card's homeUndo JSON: the setting it replaced and the |
| // setting revision its change made. |
| Undo string |
| @@ -250,6 +251,7 @@ func (t *txn) cardView(c cardRecord) (wire.Card, error) { |
| } |
| if c.Kind == wire.CardAccess || c.Kind == wire.CardMerge { |
| v.Name = c.Name |
| + v.AccessCheck = c.AccessCheck |
| } |
| if c.Kind == wire.CardTask { |
| k, err := t.loadTask(c.TaskID) |
| @@ -282,7 +284,7 @@ func (t *txn) saveCard(c *cardRecord) error { |
| } |
| c.Revision++ |
| c.UpdatedAt = t.now() |
| - if err := t.db.Model(&cardRecord{}).Where("id = ?", c.ID).Select("state", "choice", "answer_message", "undo", "revision", "updated_at").Updates(c).Error; err != nil { |
| + if err := t.db.Model(&cardRecord{}).Where("id = ?", c.ID).Select("state", "access_check", "choice", "answer_message", "undo", "revision", "updated_at").Updates(c).Error; err != nil { |
| return err |
| } |
| return t.cardEvent(*c) |
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go| index 92749e1c..0b691abd 100644 |
| --- a/internal/equipo/chat/tools.go |
| +++ b/internal/equipo/chat/tools.go |
| @@ -896,8 +896,15 @@ func (t *txn) resolveAccess(person string, h wire.Hello) error { |
| for i := range rows { |
| c := rows[i] |
| if c.Name == "" || !slices.ContainsFunc(h.Catalog, func(e wire.RepoInfo) bool { return intended(e.Repo, c.Name) }) { |
| + if c.AccessCheck == "checking" { |
| + c.AccessCheck = "missing" |
| + if err := t.saveCard(&c); err != nil { |
| + return err |
| + } |
| + } |
| continue |
| } |
| + c.AccessCheck = "" |
| c.State = wire.CardResolved |
| if err := t.saveCard(&c); err != nil { |
| return err |
| @@ -919,8 +926,20 @@ func (t *txn) answerAccess(person string, c cardRecord, in wire.AnswerCard) (wir |
| if c.State != wire.CardOpen || c.Revision != in.Revision { |
| return wire.Card{}, v, ErrCardConflict |
| } |
| + runner, err := t.s.runnerView(t.db, person) |
| + if err != nil { |
| + return wire.Card{}, wire.Card{}, err |
| + } |
| + if !runner.Online { |
| + return wire.Card{}, wire.Card{}, ErrRunnerOffline |
| + } |
| if err := t.command(person, wire.FrameRecheck, wire.RecheckCommand{Person: person}); err != nil { |
| return wire.Card{}, wire.Card{}, err |
| } |
| - return v, wire.Card{}, nil |
| + c.AccessCheck = "checking" |
| + if err := t.saveCard(&c); err != nil { |
| + return wire.Card{}, wire.Card{}, err |
| + } |
| + v, err = t.cardView(c) |
| + return v, wire.Card{}, err |
| } |
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go| index cd60d43c..7891c0fd 100644 |
| --- a/internal/equipo/chat_page.go |
| +++ b/internal/equipo/chat_page.go |
| @@ -105,6 +105,11 @@ func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCar |
| } |
| v.Open = c.State == wire.CardHomeSet || c.State == wire.CardHomeAsk |
| case wire.CardAccess: |
| + if c.AccessCheck == "checking" { |
| + v.Note = copyText("chat.card.grant_pending") |
| + } else if c.AccessCheck == "missing" { |
| + v.Note = copyText("chat.card.grant_missing") |
| + } |
| reach := strings.Join(c.Options, ", ") |
| v.Agent, v.Namespace = c.Choice, "<namespace>" |
| if c.Name != "" { |
| @@ -395,6 +400,10 @@ func (a *application) chatActionTo(w http.ResponseWriter, r *http.Request, back |
| return |
| } |
| if err := act(ctx, address); err != nil && !errors.Is(err, chat.ErrCardConflict) { |
| + if errors.Is(err, chat.ErrRunnerOffline) { |
| + http.Error(w, copyText("chat.card.grant_unavailable"), http.StatusServiceUnavailable) |
| + return |
| + } |
| a.failure(w, r, chatError(err)) |
| return |
| } |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 38f4da37..f6f46266 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -526,34 +526,38 @@ var pageCopy = map[string]string{ |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.title |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "conversation.thinking": "Thinking", |
| - "chat.offline": "Your runner is offline. Messages wait here until it is back.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.failed": "The coordinator could not answer this message.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.cancelled": "Stopped.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.thinking": "Thinking", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.status": "Checking your projects…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.add_project": "Adding a project…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.ask_person": "Writing you a question…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.other": "Working…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.find": "Looking for it…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.search_code": "Searching the code…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.read_file": "Reading the code…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.create_project": "Creating a repository…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.set_project_home": "Updating where new projects go…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.star_project": "Starring a project…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| - "chat.activity.write_note": "Writing notes…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.read_notes": "Reading notes…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.read_file_repo": "Reading %s…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.search_code_repo": "Searching %s…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.move_in": "Moving in… %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.explore": "Looking at new access… %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.record_task": "Noting the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.add_finding": "Noting what I found…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.start_task": "Handing it to Engineering…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.read_task": "Checking the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.activity.cancel_task": "Cancelling the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "nav.tasks": "Tasks", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.card.access_resolved": "%s is reachable now.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "chat.card.grant_check": "Check now", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.offline": "Your runner is offline. Messages wait here until it is back.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.failed": "The coordinator could not answer this message.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.cancelled": "Stopped.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.thinking": "Thinking", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.status": "Checking your projects…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.add_project": "Adding a project…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.ask_person": "Writing you a question…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.other": "Working…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.find": "Looking for it…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.search_code": "Searching the code…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.read_file": "Reading the code…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.create_project": "Creating a repository…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.set_project_home": "Updating where new projects go…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.star_project": "Starring a project…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| + "chat.activity.write_note": "Writing notes…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.read_notes": "Reading notes…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.read_file_repo": "Reading %s…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.search_code_repo": "Searching %s…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.move_in": "Moving in… %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.explore": "Looking at new access… %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.record_task": "Noting the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.add_finding": "Noting what I found…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.start_task": "Handing it to Engineering…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.read_task": "Checking the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.activity.cancel_task": "Cancelling the task…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "nav.tasks": "Tasks", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.card.access_resolved": "%s is reachable now.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.card.grant_checking": "Checking access…", |
| + "chat.card.grant_pending": "Checking access. If the runner is offline, reconnect it and choose Done to retry.", |
| + "chat.card.grant_missing": "Access is not verified yet. Check the grant, then choose Done to retry.", |
| + "chat.card.grant_unavailable": "Could not check access. Check your connection and that the runner is online, then choose Done to retry.", |
| + "chat.card.grant_check": "Done", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.stage.noted": "Noted", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.stage.investigated": "Looking into it", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.stage.in_progress": "In progress", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/migrations/0060_access_check.sql b/internal/equipo/migrations/0060_access_check.sql| new file mode 100644 |
| index 00000000..0003cfba |
| --- /dev/null |
| +++ b/internal/equipo/migrations/0060_access_check.sql |
| @@ -0,0 +1 @@ |
| +ALTER TABLE chat_cards ADD COLUMN access_check text; |
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql| index 0a02895c..e27ebd10 100644 |
| --- a/internal/equipo/migrations/schema.sql |
| +++ b/internal/equipo/migrations/schema.sql |
| @@ -586,7 +586,7 @@ CREATE TABLE runner_inbox (runner_id text, frame_id text, seen_at datetime, PRIM |
| CREATE TABLE runner_sessions (runner_id text PRIMARY KEY, generation integer, connected numeric, process text, revision integer, hello text, seen_at datetime, protocol integer); |
| CREATE TABLE chat_projects (id text PRIMARY KEY, repo text, state text, added_by text, revision integer, created_at datetime, updated_at datetime, title text); |
| CREATE UNIQUE INDEX chat_project_repo ON chat_projects(repo); |
| -CREATE TABLE chat_cards (id text PRIMARY KEY, person text, kind text, state text, turn_id text, project_id text, question text, options text, choice text, answer_message text, revision integer, created_at datetime, updated_at datetime, undo text, task_id text, name text, action_id text, visible_at datetime, held numeric); |
| +CREATE TABLE chat_cards (id text PRIMARY KEY, person text, kind text, state text, turn_id text, project_id text, question text, options text, choice text, answer_message text, revision integer, created_at datetime, updated_at datetime, undo text, task_id text, name text, action_id text, visible_at datetime, held numeric, access_check text); |
| CREATE INDEX chat_card_person ON chat_cards(person); |
| CREATE INDEX chat_card_project ON chat_cards(project_id); |
| CREATE INDEX chat_card_answer ON chat_cards(answer_message); |
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js| index d7baa8f1..96ff7162 100644 |
| --- a/internal/equipo/static/chat-stream.js |
| +++ b/internal/equipo/static/chat-stream.js |
| @@ -511,6 +511,17 @@ |
| var at = Number(page.dataset.cursor) || 0; |
| if (at < pageCursor) return; |
| pageCursor = at; |
| + var focusedAccess = document.activeElement && document.activeElement.closest('[equipo-card="access"]'); |
| + var focusedCheck = focusedAccess && document.activeElement.matches("[data-grant-check]"); |
| + var accessChanges = []; |
| + next.querySelectorAll('[equipo-card="access"]').forEach(function (card) { |
| + var old = Array.from(feed.querySelectorAll('[equipo-card="access"]')).find(function (el) { return el.dataset.card === card.dataset.card; }); |
| + if (!old) return; |
| + var note = card.querySelector("[data-grant-status]"); |
| + var oldNote = old.querySelector("[data-grant-status]"); |
| + if (card.dataset.state !== old.dataset.state) accessChanges.push(card.querySelector("[equipo-card-line]").textContent); |
| + else if (note && note.textContent && (!oldNote || note.textContent !== oldNote.textContent)) accessChanges.push(note.textContent); |
| + }); |
| // Keep live timers and activity lines across the re-render. |
| // A newly committed reply settles into its draft's element; a turn |
| // may already have earlier messages on the page. |
| @@ -548,6 +559,16 @@ |
| delete keep[turn]; |
| return el.hasAttribute("equipo-thinking") ? old : settle(old, el); |
| })); |
| + if (focusedCheck) { |
| + var access = Array.from(feed.querySelectorAll('[equipo-card="access"]')).find(function (el) { return el.dataset.card === focusedAccess.dataset.card; }); |
| + if (access) { |
| + var target = access.querySelector("[data-grant-check]"); |
| + if (!target) { target = access; target.tabIndex = -1; } |
| + target.focus({ preventScroll: true }); |
| + } |
| + } |
| + var announcements = root.querySelector("[equipo-announcements]"); |
| + if (announcements && accessChanges.length) announcements.textContent = accessChanges.join(" "); |
| local.forEach(function (el) { place(el); }); |
| pending.forEach(function (el) { feed.append(el); }); |
| Object.keys(drafts).forEach(function (turn) { |
| @@ -689,11 +710,29 @@ |
| var f = event.target.closest("[data-card-form]"); |
| if (!f) return; |
| event.preventDefault(); |
| + if (f.dataset.submitting) return; |
| + f.dataset.submitting = "true"; |
| + var check = f.querySelector("[data-grant-check]"); |
| + var status = check && f.closest("[data-card]").querySelector("[data-grant-status]"); |
| + if (status) status.textContent = check.dataset.checking; |
| + f.setAttribute("aria-busy", "true"); |
| var body = new URLSearchParams(new FormData(f, event.submitter)); |
| f.querySelectorAll("button").forEach(function (b) { b.disabled = true; }); |
| fetch(f.action, { method: "POST", credentials: "same-origin", headers: { "Accept": "application/json" }, body: body }) |
| - .then(function (r) { if (!r.ok) throw new Error("card"); return refresh(); }) |
| - .catch(function () { refreshSoon(); }); |
| + .then(function (r) { |
| + if (r.status === 409) return refresh(); |
| + if (!r.ok) throw new Error("card"); |
| + return refresh(); |
| + }) |
| + .catch(function () { |
| + if (status) status.textContent = check.dataset.unavailable; |
| + else refreshSoon(); |
| + }) |
| + .finally(function () { |
| + delete f.dataset.submitting; |
| + f.removeAttribute("aria-busy"); |
| + f.querySelectorAll("button").forEach(function (b) { b.disabled = false; }); |
| + }); |
| }); |
| // Sending stays on this page: no navigation, so no page transition. The |
| // bubble shows at once; the background post uses the form's own action |
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css| index b557db40..7fb29247 100644 |
| --- a/internal/equipo/static/equipo.css |
| +++ b/internal/equipo/static/equipo.css |
| @@ -1440,3 +1440,8 @@ label[equipo-sp-label] { cursor: pointer; } |
| [equipo-team-facts] { flex-direction: column; } |
| [equipo-team-facts] > * + *::before { content: none; } |
| } |
| + |
| +/* Grant instructions can wrap without pushing Done off a narrow screen. */ |
| +[equipo-grant] { min-width: 0; max-width: 100%; } |
| +[equipo-grant] code { white-space: normal; overflow-wrap: anywhere; } |
| +[equipo-card="access"] [equipo-actions] { align-items: flex-start; } |
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html| index 40aa6c2d..92e5ace0 100644 |
| --- a/internal/equipo/templates/chat.html |
| +++ b/internal/equipo/templates/chat.html |
| @@ -7,7 +7,7 @@ |
| {{else if eq .Kind "question"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{else}}<input rst-input name="choice" required maxlength="2000" aria-label="{{copy "chat.card.answer"}}"><button rst-btn="primary" type="submit">{{copy "chat.card.answer"}}</button>{{end}}</form>{{else}}<p equipo-card-note>{{printf (copy "chat.card.answered") .Choice}}</p>{{end}} |
| {{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn="primary" name="choice" value="confirm" type="submit">{{copy "chat.card.confirm"}}</button></form> |
| {{else if eq .Kind "merge"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<button rst-btn="{{if eq . "merge"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-merge-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}} |
| -{{else if eq .Kind "access"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<details equipo-grant><summary rst-btn>{{copy "chat.card.grant"}}</summary><p>{{copy "chat.card.grant_how"}}</p><code>amadan agent grant {{.Agent}} {{.Namespace}}</code><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn name="choice" value="check" type="submit" data-grant-check>{{copy "chat.card.grant_check"}}</button></form></details>{{end}} |
| +{{else if eq .Kind "access"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<div equipo-actions><details equipo-grant><summary rst-btn>{{copy "chat.card.grant"}}</summary><p>{{copy "chat.card.grant_how"}}</p><code>amadan agent grant {{.Agent}} {{.Namespace}}</code></details><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn name="choice" value="check" type="submit" data-grant-check data-checking="{{copy "chat.card.grant_checking"}}" data-unavailable="{{copy "chat.card.grant_unavailable"}}">{{copy "chat.card.grant_check"}}</button></form></div><p equipo-card-note role="status" data-grant-status>{{.Note}}</p>{{end}} |
| {{end}}</li>{{end}} |
| {{define "work-task-receipt"}}{{with .Task}}<p equipo-card-line>{{icon "check-circle"}}<span><a href="/tasks/{{.ID}}">{{.Title}}</a></span><span equipo-stage data-stage="{{.Stage}}" data-needs="{{.NeedsYou}}">{{.StageLine}}</span></p>{{if and .Pushed (not .MergedLine)}}<p equipo-card-note data-pushed><span>{{.Pushed}}</span><a href="{{.URL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{if or .ChecksLine .ReviewLine}}<p equipo-card-note data-judged>{{with .ChecksLine}}<span data-checks>{{.}}</span>{{end}}{{with .ReviewLine}}<span data-verdict>{{.}}</span>{{end}}</p>{{end}}{{if .MergedLine}}<p equipo-card-note data-merged><span>{{.MergedLine}}</span><a href="{{.RepoURL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{end}}{{if .Open}}<button type="button" equipo-receipt-more aria-expanded="false" aria-controls="acts-{{.ID}}" aria-label="{{copy "chat.card.more"}}">⋯</button><span equipo-receipt-actions id="acts-{{.ID}}">{{template "work-task-actions" .Task}}</span>{{end}}{{end}} |
| {{define "message-files"}}{{with .}}<div equipo-message-files>{{range .}}{{if eq .Kind "image"}}<a equipo-file-thumb href="/conversation/attachments/{{.ID}}" target="_blank" rel="noopener" data-attachment="{{.ID}}"><img src="/conversation/attachments/{{.ID}}/preview" alt="{{.Name}}"{{if .Width}} width="{{.Width}}" height="{{.Height}}"{{end}} loading="lazy" decoding="async"></a>{{else}}<a equipo-file-chip href="/conversation/attachments/{{.ID}}" target="_blank" rel="noopener" data-attachment="{{.ID}}">{{icon "file-text"}}<span equipo-file-name>{{.Name}}</span><span equipo-file-size>{{fileSize .Size}}</span></a>{{end}}{{end}}</div>{{end}}{{end}} |
diff --git a/internal/runner/thin/run.go b/internal/runner/thin/run.go| index 98c2e132..1ab1ed03 100644 |
| --- a/internal/runner/thin/run.go |
| +++ b/internal/runner/thin/run.go |
| @@ -220,10 +220,13 @@ func Run(ctx context.Context, c runner.Config, o Options) error { |
| } |
| } |
| go createIn.loop(ctx, fg, link, index, recheck) |
| + // A recheck must report even an unchanged catalog, so the access card |
| + // can offer a retry rather than stay in checking indefinitely. |
| + index.Refreshed = link.HelloSoon |
| var settle *settler |
| if !o.NoMoveIn { |
| settle = &settler{State: state, Link: link, Index: index, SessionRoot: o.Claude.SessionRoot, Persons: coordinatorPersons(c), Logger: o.Logger} |
| - index.Refreshed = func() { settle.Check(ctx) } |
| + index.Refreshed = func() { link.HelloSoon(); settle.Check(ctx) } |
| } |
| engine.ResetDesk = func(person string) error { |
| desk, err := OpenDesk(o.Claude.SessionRoot, person) |
| @@ -328,9 +331,11 @@ func (n *namespaces) get() []string { |
| // loop watches what the agent may create in and what it reaches: a |
| // cheap conditional check about once a minute, and at once when a |
| // person acts on a grant card (recheck). A change in reach is sent in a |
| -// hello and refreshes the index for the new repositories only. |
| +// hello and refreshes the index for the new repositories only. An explicit |
| +// recheck refreshes the index even when reach is unchanged. |
| func (n *namespaces) loop(ctx context.Context, f Forge, link *Link, index *Index, recheck <-chan struct{}) { |
| var reach []string |
| + forced := false |
| for { |
| rctx, cancel := context.WithTimeout(ctx, 40*time.Second) |
| ns := f.CreateIn(rctx) |
| @@ -342,17 +347,19 @@ func (n *namespaces) loop(ctx context.Context, f Forge, link *Link, index *Index |
| n.mu.Unlock() |
| moved := reach != nil && !slices.Equal(now, reach) |
| reach = now |
| - if changed || moved { |
| + if changed || moved || forced && index == nil { |
| link.HelloSoon() |
| } |
| - if moved && index != nil { |
| + if (moved || forced) && index != nil { |
| index.Kick() |
| } |
| + forced = false |
| select { |
| case <-ctx.Done(): |
| return |
| case <-time.After(reachEvery + 5*time.Second): |
| case <-recheck: |
| + forced = true |
| f.Recheck() |
| } |
| } |
diff --git a/internal/thintest/pages_test.go b/internal/thintest/pages_test.go| index dc156dc2..b082a2f1 100644 |
| --- a/internal/thintest/pages_test.go |
| +++ b/internal/thintest/pages_test.go |
| @@ -240,6 +240,15 @@ func TestPagesGrantCard(t *testing.T) { |
| if !strings.Contains(page, "amadan agent grant equipo-test moonbeam") || !strings.Contains(page, `data-grant-check`) { |
| t.Fatal("grant card lacks the command or the check") |
| } |
| + grant := strings.Index(page, "<details equipo-grant>") |
| + if grant < 0 { |
| + t.Fatal("missing grant disclosure") |
| + } |
| + closed := strings.Index(page[grant:], "</details>") + grant |
| + done := strings.Index(page, "data-grant-check") |
| + if grant < 0 || done < closed || !strings.Contains(page[done:], ">Done</button>") || !strings.Contains(page, `role="status" data-grant-status`) { |
| + t.Fatal("Done must be visible outside the disclosure, with accessible feedback") |
| + } |
| if status, _ := r.post(owner, "/conversation/cards/"+card.ID+"/answer", url.Values{"choice": {"check"}, "revision": {"1"}}); status != 303 { |
| t.Fatalf("check: %d", status) |
| } |
diff --git a/internal/thintest/tasks_contract_test.go b/internal/thintest/tasks_contract_test.go| index 00d4aa04..49696713 100644 |
| --- a/internal/thintest/tasks_contract_test.go |
| +++ b/internal/thintest/tasks_contract_test.go |
| @@ -379,11 +379,18 @@ func TestContractGrantCard(t *testing.T) { |
| } |
| r.expect(wire.FrameRecheck) |
| shape(t, "frames/recheck.json", r.runner.Received[len(r.runner.Received)-1]) |
| + if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceCheck, card.Revision); Status(err) != 409 { |
| + t.Fatalf("repeated stale check: %v", err) |
| + } |
| + r.wait("checking", func(c *Conversation) bool { return c.Cards[card.ID].AccessCheck == "checking" }) |
| // A hello that still does not reach it changes nothing. |
| hello := wire.Hello{Generation: r.runner.Welcome.Generation, Repos: []string{"amadan.net/oficina/sample"}, CreateIn: []string{}, Agent: "equipo-test", Catalog: []wire.RepoInfo{{Repo: "amadan.net/oficina/sample", Names: []string{"sample"}, Hints: []string{}}}, Connections: []wire.HeldConnection{}, Versions: map[string]string{}} |
| if err := r.runner.Send(r.ctx, "h-g1", wire.FrameHello, hello); err != nil { |
| t.Fatal(err) |
| } |
| + r.wait("still missing", func(c *Conversation) bool { |
| + return c.Cards[card.ID].AccessCheck == "missing" && c.Cards[card.ID].State == wire.CardOpen |
| + }) |
| // An unrelated repository that merely matches a word of the query |
| // (app) does not resolve it. |
| hello.Catalog = append(hello.Catalog, wire.RepoInfo{Repo: "amadan.net/other/app", Summary: "An app.", Names: []string{"app", "Moonbeams"}, Hints: []string{}}) |
| @@ -402,6 +409,16 @@ func TestContractGrantCard(t *testing.T) { |
| }() != wire.CardOpen { |
| t.Fatal("resolved by an unrelated repository") |
| } |
| + // Retry uses the current revision, without creating work or confirmation messages. |
| + var current wire.Card |
| + r.wait("retryable", func(c *Conversation) bool { |
| + current = c.Cards[card.ID] |
| + return current.AccessCheck == "missing" |
| + }) |
| + if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceCheck, current.Revision); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.expect(wire.FrameRecheck) |
| hello.Catalog = append(hello.Catalog, wire.RepoInfo{Repo: "amadan.net/moonbeam/web", Names: []string{"web", "Moonbeam"}, Hints: []string{}}) |
| if err := r.runner.Send(r.ctx, "h-g2", wire.FrameHello, hello); err != nil { |
| t.Fatal(err) |
| @@ -412,6 +429,34 @@ func TestContractGrantCard(t *testing.T) { |
| } |
| } |
| +func TestContractGrantCardOffline(t *testing.T) { |
| + r := newToolRig(t) |
| + r.call("offline-grant", wire.ToolFind, map[string]string{"query": "Moonbeam"}) |
| + var card wire.Card |
| + r.wait("access card", func(c *Conversation) bool { |
| + for _, k := range c.Cards { |
| + if k.Kind == wire.CardAccess { |
| + card = k |
| + } |
| + } |
| + return card.ID != "" |
| + }) |
| + r.runner.Close() |
| + r.wait("offline", func(c *Conversation) bool { return !c.Runner.Online }) |
| + if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceCheck, card.Revision); Status(err) != 409 { |
| + t.Fatalf("offline check: %v", err) |
| + } |
| + snap, err := r.client.Snapshot(r.ctx) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, k := range snap.Cards { |
| + if k.ID == card.ID && (k.State != wire.CardOpen || k.Revision != card.Revision) { |
| + t.Fatalf("offline check changed card: %+v", k) |
| + } |
| + } |
| +} |
| + |
| func TestNamespaceGuess(t *testing.T) { |
| for q, want := range map[string]string{"Woodstar": "woodstar", "the Woodstar iOS app": "woodstar", "Moon Beam": "moon", "¿Qué?": "", "my app": "", "x": ""} { |
| if got := chat.NamespaceGuess(q); got != want { |
diff --git a/internal/wire/api.go b/internal/wire/api.go| index c9ad36ad..e80bc153 100644 |
| --- a/internal/wire/api.go |
| +++ b/internal/wire/api.go |
| @@ -330,16 +330,18 @@ type AddProject struct { |
| // Card is something in the conversation the person can act on: a project |
| // the coordinator added (Remove) or a question (answer). |
| type Card struct { |
| - ID string `json:"id"` |
| - Revision int64 `json:"revision"` |
| - Kind string `json:"kind"` |
| - State string `json:"state"` |
| - TurnID string `json:"turn_id"` |
| - ProjectID string `json:"project_id"` |
| - Name string `json:"name"` |
| - Question string `json:"question"` |
| - Options []string `json:"options"` |
| - Choice string `json:"choice"` |
| + // AccessCheck is checking or missing while an access card remains open. |
| + AccessCheck string `json:"access_check,omitempty"` |
| + ID string `json:"id"` |
| + Revision int64 `json:"revision"` |
| + Kind string `json:"kind"` |
| + State string `json:"state"` |
| + TurnID string `json:"turn_id"` |
| + ProjectID string `json:"project_id"` |
| + Name string `json:"name"` |
| + Question string `json:"question"` |
| + Options []string `json:"options"` |
| + Choice string `json:"choice"` |
| // TaskID names the task a task card reports. |
| TaskID string `json:"task_id"` |
| CreatedAt time.Time `json:"created_at"` |