#97 Se connecter à Docker (sbx login) depuis Sidekicks
Quand sbx répond « not signed in to Docker », Sidekicks l'explique et propose « Se connecter à Docker » : il lance sbx login, affiche le code et ouvre la page de confirmation, attend « Signed in as … », puis l'assistant des sandboxes reprend sa vérification. Même bouton sous l'erreur d'un agent sbx. - sbxcreate : NotSignedIn, StartLogin (code, adresse, utilisateur, annulation) - SbxCreatorService : Login, LoginStatus, CancelLogin - SbxLogin.svelte via ErrorText (error.sbxNotSignedIn) - docs EN + FR, notes de release v1.5.0 ; ticket #97 (essai sur le Mac) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
597e752 parent: 1e751ee added
.memory/handoffs/2026-11-15-sbx-login.md +9 -0 | new file mode 100644 | ||
| @@ -0,0 +1,9 @@ | ||
| 1 | +# Handoff — 2026-11-15 — #97 sbx login from Sidekicks | |
| 2 | + | |
| 3 | +## State | |
| 4 | + | |
| 5 | +Branch `feature/97-sbx-login` (from main after the merge of feature/86-vibe; nothing pushed). Implemented; tasks 1–5 closed, task 6 (Mac) open. #86 task 5 (Vibe on the Mac) also still open — the owner hit "not signed in" while testing it. | |
| 6 | + | |
| 7 | +## Next steps | |
| 8 | + | |
| 9 | +On the Mac, signed out of sbx (`sbx logout` if it exists): open the sandbox assistant, choose a kind → "Se connecter à Docker" → check the code and the page, confirm → the assistant goes on. If sbx prints other lines, `LoginState.output` shows them (details) — adapt `codePattern`/`urlPattern`/`userPattern` in `internal/sbxcreate/login.go`. On a first-ever sbx use, see whether the network-policy question breaks it (stdin is empty). | |
| new file mode 100644 | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | +# Handoff — 2026-11-15 — #97 sbx login from Sidekicks | ||
| 2 | + | ||
| 3 | +## State | ||
| 4 | + | ||
| 5 | +Branch `feature/97-sbx-login` (from main after the merge of feature/86-vibe; nothing pushed). Implemented; tasks 1–5 closed, task 6 (Mac) open. #86 task 5 (Vibe on the Mac) also still open — the owner hit "not signed in" while testing it. | ||
| 6 | + | ||
| 7 | +## Next steps | ||
| 8 | + | ||
| 9 | +On the Mac, signed out of sbx (`sbx logout` if it exists): open the sandbox assistant, choose a kind → "Se connecter à Docker" → check the code and the page, confirm → the assistant goes on. If sbx prints other lines, `LoginState.output` shows them (details) — adapt `codePattern`/`urlPattern`/`userPattern` in `internal/sbxcreate/login.go`. On a first-ever sbx use, see whether the network-policy question breaks it (stdin is empty). | ||
modified
.memory/history.md +6 -0 | @@ -271,3 +271,9 @@ | ||
| 271 | 271 | - Asked: "commit and merge the feature branch into main, then a new feature branch, still for v1.5.0, a ticket, and implement it". feature/96-sbx-creator merged into main (not pushed). Reused #86 (Vibe) instead of a duplicate ticket: put in v1.5.0, scope = a catalogue entry of #96, 5 tasks; listed in #93. |
| 272 | 272 | - Done: `sbxcreate.Catalogue` entry `vibe` 🟧 (agent vibe, kit docker.io/sbx/vibe-kit:latest, program vibe-acp, service mistral, bindings api.mistral.ai); agentform.ts `programOfSandbox('vibe')` → vibe-acp; texts EN/FR (kind label, welcome, palette); docs EN/FR (sandbox guide, SbxCreatorService table, labels everywhere "Claude, Gemini, Codex or Vibe"), release notes v1.5.0. Tests Go + vitest, lint (one catalogue test split for gocyclo). Not verified: anything with a real sbx (task 5 on the Mac). |
| 273 | 273 | - **2026-11-15 — "sbx ls: … not signed in to Docker"** (owner, while testing Vibe; asks whether Sidekicks could trigger `sbx login`): researched — `sbx login` is a device-code flow (prints "Your one-time device confirmation code is: XXXX-XXXX", "Open this URL to sign in: https://login.docker.com/activate?user_code=…", "Waiting for authentication…", then "Signed in as <user>." and starts the daemon; on a first run it may then ask for a default network policy interactively). Proposed design given to the owner (run it as a child, show code + URL, wait, re-check); nothing implemented yet. |
| 274 | + | |
| 275 | +## 2026-11-15 — #97 sign in to Docker (sbx login) from Sidekicks (branch feature/97-sbx-login) | |
| 276 | + | |
| 277 | +- Asked: "commit, merge into main, new branch, ticket, implement". feature/86-vibe merged into main (not pushed). Ticket #97 in v1.5.0 (listed in #93). | |
| 278 | +- Done: `internal/sbxcreate/login.go` (`NotSignedIn`, `StartLogin` → `Login` with `State`/`Wait`/`Cancel`; parses `XXXX-XXXX`, the first https URL with "login", "Signed in as <user>."; empty stdin; signed in counts as success even if sbx then fails on a question), `SbxCreatorService.Login/LoginStatus/CancelLogin` (20 s long polls; `Core.signIn`; cancelled at Shutdown), UI `chat/SbxLogin.svelte` rendered by `ErrorText` for the new errors.ts rule `error.sbxNotSignedIn` (prop `onSignedIn`; the sandbox assistant re-checks). Tests Go + vitest, lint; Xvfb with a fake sbx refusing until signed in: button → code → confirmed → assistant goes on to the key step. | |
| 279 | +- Not verified: the real `sbx login` (output format, first-run network-policy question without a terminal) — task 6 on the Mac. Docs EN/FR: sandbox guide (when something goes wrong), SbxCreatorService rows, release notes. | |
| @@ -271,3 +271,9 @@ | |||
| 271 | - Asked: "commit and merge the feature branch into main, then a new feature branch, still for v1.5.0, a ticket, and implement it". feature/96-sbx-creator merged into main (not pushed). Reused #86 (Vibe) instead of a duplicate ticket: put in v1.5.0, scope = a catalogue entry of #96, 5 tasks; listed in #93. | 271 | - Asked: "commit and merge the feature branch into main, then a new feature branch, still for v1.5.0, a ticket, and implement it". feature/96-sbx-creator merged into main (not pushed). Reused #86 (Vibe) instead of a duplicate ticket: put in v1.5.0, scope = a catalogue entry of #96, 5 tasks; listed in #93. |
| 272 | - Done: `sbxcreate.Catalogue` entry `vibe` 🟧 (agent vibe, kit docker.io/sbx/vibe-kit:latest, program vibe-acp, service mistral, bindings api.mistral.ai); agentform.ts `programOfSandbox('vibe')` → vibe-acp; texts EN/FR (kind label, welcome, palette); docs EN/FR (sandbox guide, SbxCreatorService table, labels everywhere "Claude, Gemini, Codex or Vibe"), release notes v1.5.0. Tests Go + vitest, lint (one catalogue test split for gocyclo). Not verified: anything with a real sbx (task 5 on the Mac). | 272 | - Done: `sbxcreate.Catalogue` entry `vibe` 🟧 (agent vibe, kit docker.io/sbx/vibe-kit:latest, program vibe-acp, service mistral, bindings api.mistral.ai); agentform.ts `programOfSandbox('vibe')` → vibe-acp; texts EN/FR (kind label, welcome, palette); docs EN/FR (sandbox guide, SbxCreatorService table, labels everywhere "Claude, Gemini, Codex or Vibe"), release notes v1.5.0. Tests Go + vitest, lint (one catalogue test split for gocyclo). Not verified: anything with a real sbx (task 5 on the Mac). |
| 273 | - **2026-11-15 — "sbx ls: … not signed in to Docker"** (owner, while testing Vibe; asks whether Sidekicks could trigger `sbx login`): researched — `sbx login` is a device-code flow (prints "Your one-time device confirmation code is: XXXX-XXXX", "Open this URL to sign in: https://login.docker.com/activate?user_code=…", "Waiting for authentication…", then "Signed in as <user>." and starts the daemon; on a first run it may then ask for a default network policy interactively). Proposed design given to the owner (run it as a child, show code + URL, wait, re-check); nothing implemented yet. | 273 | - **2026-11-15 — "sbx ls: … not signed in to Docker"** (owner, while testing Vibe; asks whether Sidekicks could trigger `sbx login`): researched — `sbx login` is a device-code flow (prints "Your one-time device confirmation code is: XXXX-XXXX", "Open this URL to sign in: https://login.docker.com/activate?user_code=…", "Waiting for authentication…", then "Signed in as <user>." and starts the daemon; on a first run it may then ask for a default network policy interactively). Proposed design given to the owner (run it as a child, show code + URL, wait, re-check); nothing implemented yet. |
| 274 | + | ||
| 275 | +## 2026-11-15 — #97 sign in to Docker (sbx login) from Sidekicks (branch feature/97-sbx-login) | ||
| 276 | + | ||
| 277 | +- Asked: "commit, merge into main, new branch, ticket, implement". feature/86-vibe merged into main (not pushed). Ticket #97 in v1.5.0 (listed in #93). | ||
| 278 | +- Done: `internal/sbxcreate/login.go` (`NotSignedIn`, `StartLogin` → `Login` with `State`/`Wait`/`Cancel`; parses `XXXX-XXXX`, the first https URL with "login", "Signed in as <user>."; empty stdin; signed in counts as success even if sbx then fails on a question), `SbxCreatorService.Login/LoginStatus/CancelLogin` (20 s long polls; `Core.signIn`; cancelled at Shutdown), UI `chat/SbxLogin.svelte` rendered by `ErrorText` for the new errors.ts rule `error.sbxNotSignedIn` (prop `onSignedIn`; the sandbox assistant re-checks). Tests Go + vitest, lint; Xvfb with a fake sbx refusing until signed in: button → code → confirmed → assistant goes on to the key step. | ||
| 279 | +- Not verified: the real `sbx login` (output format, first-run network-policy question without a terminal) — task 6 on the Mac. Docs EN/FR: sandbox guide (when something goes wrong), SbxCreatorService rows, release notes. | ||
modified
.tickets/issues/0093-publier-la-version-1-5-0.yaml +1 -0 | @@ -20,6 +20,7 @@ body: | | ||
| 20 | 20 | - [#95](.tickets/issues/0095-ask-user-de-mini-me-pas-de-zone-de-saisie-dans-s.yaml) — `ask_user` de mini-me : zone de saisie dans la conversation |
| 21 | 21 | - [#96](.tickets/issues/0096-assistant-create-a-sbx-agent-claude-gemini-codex.yaml) — assistant « Create a sbx agent » (Claude, Gemini, Codex) |
| 22 | 22 | - [#86](.tickets/issues/0086-simplifier-l-ajout-d-une-sbx-avec-mistral-vibe-acp.yaml) — Mistral Vibe dans l'assistant des sandboxes |
| 23 | + - [#97](.tickets/issues/0097-se-connecter-a-docker-sbx-login-depuis-sidekicks.yaml) — se connecter à Docker (sbx login) depuis Sidekicks | |
| 23 | 24 | |
| 24 | 25 | Même déroulé que [#92 — Publier la version 1.4.0](.tickets/issues/0092-publier-la-version-1-4-0.yaml), en suivant |
| 25 | 26 | [RELEASING.fr.md](RELEASING.fr.md) (scripts `local-ci-*.sh`), **kDrive en pause** pendant la construction. |
| @@ -20,6 +20,7 @@ body: | | |||
| 20 | - [#95](.tickets/issues/0095-ask-user-de-mini-me-pas-de-zone-de-saisie-dans-s.yaml) — `ask_user` de mini-me : zone de saisie dans la conversation | 20 | - [#95](.tickets/issues/0095-ask-user-de-mini-me-pas-de-zone-de-saisie-dans-s.yaml) — `ask_user` de mini-me : zone de saisie dans la conversation |
| 21 | - [#96](.tickets/issues/0096-assistant-create-a-sbx-agent-claude-gemini-codex.yaml) — assistant « Create a sbx agent » (Claude, Gemini, Codex) | 21 | - [#96](.tickets/issues/0096-assistant-create-a-sbx-agent-claude-gemini-codex.yaml) — assistant « Create a sbx agent » (Claude, Gemini, Codex) |
| 22 | - [#86](.tickets/issues/0086-simplifier-l-ajout-d-une-sbx-avec-mistral-vibe-acp.yaml) — Mistral Vibe dans l'assistant des sandboxes | 22 | - [#86](.tickets/issues/0086-simplifier-l-ajout-d-une-sbx-avec-mistral-vibe-acp.yaml) — Mistral Vibe dans l'assistant des sandboxes |
| 23 | + - [#97](.tickets/issues/0097-se-connecter-a-docker-sbx-login-depuis-sidekicks.yaml) — se connecter à Docker (sbx login) depuis Sidekicks | ||
| 23 | 24 | ||
| 24 | Même déroulé que [#92 — Publier la version 1.4.0](.tickets/issues/0092-publier-la-version-1-4-0.yaml), en suivant | 25 | Même déroulé que [#92 — Publier la version 1.4.0](.tickets/issues/0092-publier-la-version-1-4-0.yaml), en suivant |
| 25 | [RELEASING.fr.md](RELEASING.fr.md) (scripts `local-ci-*.sh`), **kDrive en pause** pendant la construction. | 26 | [RELEASING.fr.md](RELEASING.fr.md) (scripts `local-ci-*.sh`), **kDrive en pause** pendant la construction. |
added
.tickets/issues/0097-se-connecter-a-docker-sbx-login-depuis-sidekicks.yaml +131 -0 | new file mode 100644 | ||
| @@ -0,0 +1,131 @@ | ||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | |
| 2 | +id: 97 | |
| 3 | +title: "Se connecter à Docker (sbx login) depuis Sidekicks" | |
| 4 | +state: open | |
| 5 | +author: | |
| 6 | + name: k33g | |
| 7 | + email: ph.charriere@gmail.com | |
| 8 | +createdAt: 2026-11-15T02:55:07.000Z | |
| 9 | +updatedAt: 2026-11-15T03:00:14.000Z | |
| 10 | +labels: | |
| 11 | + - kind::feature | |
| 12 | + - area::ui | |
| 13 | + - citizen-ux | |
| 14 | +milestone: "v1.5.0 · Release" | |
| 15 | +epic: Docker SBX | |
| 16 | +related: | |
| 17 | + - 96 | |
| 18 | + - 86 | |
| 19 | +body: | | |
| 20 | + Constat (owner, en testant Vibe) : l'assistant des sandboxes échoue avec | |
| 21 | + `sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart`. Un utilisateur non | |
| 22 | + technique ne sait pas quoi faire de ce message. | |
| 23 | + | |
| 24 | + ## Proposition | |
| 25 | + - Quand une commande sbx répond « not signed in to Docker » (ou « not authenticated to Docker »), Sidekicks | |
| 26 | + l'explique en mots simples et propose **Se connecter à Docker** — dans l'assistant des sandboxes et partout où | |
| 27 | + l'erreur s'affiche (démarrage d'un agent sbx). | |
| 28 | + - Le bouton lance `sbx login` (flux « device code ») ; Sidekicks lit sa sortie et affiche le **code** et un bouton | |
| 29 | + **Ouvrir la page de connexion** (`https://login.docker.com/activate?user_code=…`), puis « En attente de votre | |
| 30 | + connexion… » jusqu'à « Signed in as <utilisateur>. ». | |
| 31 | + - Une fois connecté, l'assistant reprend où il en était (il relance sa vérification). | |
| 32 | + - **Annuler** arrête `sbx login`. | |
| 33 | + | |
| 34 | + Sortie attendue de `sbx login` (relevée dans un article, la doc officielle de la commande est vide) : | |
| 35 | + | |
| 36 | + ```text | |
| 37 | + You are not authenticated to Docker. Starting the sign-in flow... | |
| 38 | + Your one-time device confirmation code is: FXDG-FKTF | |
| 39 | + Open this URL to sign in: https://login.docker.com/activate?user_code=FXDG-FKTF | |
| 40 | + Waiting for authentication... | |
| 41 | + Signed in as andrewlock. | |
| 42 | + ``` | |
| 43 | + | |
| 44 | + ## Points à vérifier sur le Mac | |
| 45 | + - Le format réel de la sortie (lecture tolérante : l'adresse `https://…` et le code `XXXX-XXXX` ; sinon la sortie | |
| 46 | + brute est montrée). | |
| 47 | + - Au tout premier usage, sbx peut demander au clavier une politique réseau par défaut : sans terminal, que fait-il ? | |
| 48 | + Sinon, dire de lancer `sbx login` une fois dans un terminal. | |
| 49 | + - Si sbx ouvre lui-même le navigateur, le bouton reste un secours. | |
| 50 | + | |
| 51 | + ## Critères d'acceptation | |
| 52 | + - Non connecté, l'assistant des sandboxes propose de se connecter ; après la connexion il continue sans redémarrer | |
| 53 | + Sidekicks. | |
| 54 | + - L'erreur au démarrage d'un agent sbx propose la même connexion. | |
| 55 | + - Tests (faux sbx qui simule le flux), doc EN + FR. | |
| 56 | +tasks: | |
| 57 | + - id: 1 | |
| 58 | + title: "Go : lancer sbx login, lire le code, l'adresse et « Signed in as », attendre, annuler" | |
| 59 | + state: closed | |
| 60 | + priority: high | |
| 61 | + author: | |
| 62 | + name: k33g | |
| 63 | + email: ph.charriere@gmail.com | |
| 64 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 65 | + updatedAt: 2026-11-15T03:00:14.000Z | |
| 66 | + closedAt: 2026-11-15T03:00:14.000Z | |
| 67 | + - id: 2 | |
| 68 | + title: "Service : Login, LoginStatus, CancelLogin (SbxCreatorService)" | |
| 69 | + state: closed | |
| 70 | + priority: high | |
| 71 | + author: | |
| 72 | + name: k33g | |
| 73 | + email: ph.charriere@gmail.com | |
| 74 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 75 | + updatedAt: 2026-11-15T03:00:14.000Z | |
| 76 | + closedAt: 2026-11-15T03:00:14.000Z | |
| 77 | + - id: 3 | |
| 78 | + title: "Interface : composant de connexion (code, ouvrir la page, attente), dans l'assistant et sous l'erreur d'un agent" | |
| 79 | + state: closed | |
| 80 | + priority: high | |
| 81 | + author: | |
| 82 | + name: k33g | |
| 83 | + email: ph.charriere@gmail.com | |
| 84 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 85 | + updatedAt: 2026-11-15T03:00:14.000Z | |
| 86 | + closedAt: 2026-11-15T03:00:14.000Z | |
| 87 | + - id: 4 | |
| 88 | + title: "Tests Go + vitest, essai sous Xvfb avec un faux sbx" | |
| 89 | + state: closed | |
| 90 | + priority: high | |
| 91 | + author: | |
| 92 | + name: k33g | |
| 93 | + email: ph.charriere@gmail.com | |
| 94 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 95 | + updatedAt: 2026-11-15T03:00:14.000Z | |
| 96 | + closedAt: 2026-11-15T03:00:14.000Z | |
| 97 | + - id: 5 | |
| 98 | + title: "Doc EN + FR, notes de release v1.5.0" | |
| 99 | + state: closed | |
| 100 | + priority: medium | |
| 101 | + author: | |
| 102 | + name: k33g | |
| 103 | + email: ph.charriere@gmail.com | |
| 104 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 105 | + updatedAt: 2026-11-15T03:00:14.000Z | |
| 106 | + closedAt: 2026-11-15T03:00:14.000Z | |
| 107 | + - id: 6 | |
| 108 | + title: "Essai sur le Mac (vrai sbx login, première utilisation)" | |
| 109 | + state: open | |
| 110 | + priority: high | |
| 111 | + author: | |
| 112 | + name: k33g | |
| 113 | + email: ph.charriere@gmail.com | |
| 114 | + createdAt: 2026-11-15T02:55:07.000Z | |
| 115 | +comments: | |
| 116 | + - id: 1 | |
| 117 | + author: | |
| 118 | + name: k33g | |
| 119 | + email: ph.charriere@gmail.com | |
| 120 | + createdAt: 2026-11-15T03:00:14.000Z | |
| 121 | + body: | | |
| 122 | + Implémenté sur la branche `feature/97-sbx-login` : `sbxcreate.StartLogin` (lit le code `XXXX-XXXX`, | |
| 123 | + l'adresse `https://…login…` et « Signed in as … » ; entrée standard vide ; annulable), | |
| 124 | + `SbxCreatorService.Login / LoginStatus / CancelLogin`, composant `SbxLogin.svelte` affiché par `ErrorText` | |
| 125 | + sous l'erreur « not signed in to Docker » (assistant des sandboxes, qui reprend sa vérification une fois connecté, | |
| 126 | + et erreur d'un agent sbx). Doc EN + FR, notes de release v1.5.0. | |
| 127 | + | |
| 128 | + Vérifié : tests Go (faux `sbx login` : code, adresse, attente, connecté, échec, annulation) et vitest, lint ; | |
| 129 | + sous Xvfb avec un faux sbx qui refuse tant qu'on n'est pas connecté : bouton, code affiché, puis l'assistant | |
| 130 | + passe tout seul à l'étape de la clé. Reste la tâche 6 : le vrai `sbx login` sur le Mac (format réel de la | |
| 131 | + sortie, question de la politique réseau au premier usage). | |
| new file mode 100644 | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | +# Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | ||
| 2 | +id: 97 | ||
| 3 | +title: "Se connecter à Docker (sbx login) depuis Sidekicks" | ||
| 4 | +state: open | ||
| 5 | +author: | ||
| 6 | + name: k33g | ||
| 7 | + email: ph.charriere@gmail.com | ||
| 8 | +createdAt: 2026-11-15T02:55:07.000Z | ||
| 9 | +updatedAt: 2026-11-15T03:00:14.000Z | ||
| 10 | +labels: | ||
| 11 | + - kind::feature | ||
| 12 | + - area::ui | ||
| 13 | + - citizen-ux | ||
| 14 | +milestone: "v1.5.0 · Release" | ||
| 15 | +epic: Docker SBX | ||
| 16 | +related: | ||
| 17 | + - 96 | ||
| 18 | + - 86 | ||
| 19 | +body: | | ||
| 20 | + Constat (owner, en testant Vibe) : l'assistant des sandboxes échoue avec | ||
| 21 | + `sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart`. Un utilisateur non | ||
| 22 | + technique ne sait pas quoi faire de ce message. | ||
| 23 | + | ||
| 24 | + ## Proposition | ||
| 25 | + - Quand une commande sbx répond « not signed in to Docker » (ou « not authenticated to Docker »), Sidekicks | ||
| 26 | + l'explique en mots simples et propose **Se connecter à Docker** — dans l'assistant des sandboxes et partout où | ||
| 27 | + l'erreur s'affiche (démarrage d'un agent sbx). | ||
| 28 | + - Le bouton lance `sbx login` (flux « device code ») ; Sidekicks lit sa sortie et affiche le **code** et un bouton | ||
| 29 | + **Ouvrir la page de connexion** (`https://login.docker.com/activate?user_code=…`), puis « En attente de votre | ||
| 30 | + connexion… » jusqu'à « Signed in as <utilisateur>. ». | ||
| 31 | + - Une fois connecté, l'assistant reprend où il en était (il relance sa vérification). | ||
| 32 | + - **Annuler** arrête `sbx login`. | ||
| 33 | + | ||
| 34 | + Sortie attendue de `sbx login` (relevée dans un article, la doc officielle de la commande est vide) : | ||
| 35 | + | ||
| 36 | + ```text | ||
| 37 | + You are not authenticated to Docker. Starting the sign-in flow... | ||
| 38 | + Your one-time device confirmation code is: FXDG-FKTF | ||
| 39 | + Open this URL to sign in: https://login.docker.com/activate?user_code=FXDG-FKTF | ||
| 40 | + Waiting for authentication... | ||
| 41 | + Signed in as andrewlock. | ||
| 42 | + ``` | ||
| 43 | + | ||
| 44 | + ## Points à vérifier sur le Mac | ||
| 45 | + - Le format réel de la sortie (lecture tolérante : l'adresse `https://…` et le code `XXXX-XXXX` ; sinon la sortie | ||
| 46 | + brute est montrée). | ||
| 47 | + - Au tout premier usage, sbx peut demander au clavier une politique réseau par défaut : sans terminal, que fait-il ? | ||
| 48 | + Sinon, dire de lancer `sbx login` une fois dans un terminal. | ||
| 49 | + - Si sbx ouvre lui-même le navigateur, le bouton reste un secours. | ||
| 50 | + | ||
| 51 | + ## Critères d'acceptation | ||
| 52 | + - Non connecté, l'assistant des sandboxes propose de se connecter ; après la connexion il continue sans redémarrer | ||
| 53 | + Sidekicks. | ||
| 54 | + - L'erreur au démarrage d'un agent sbx propose la même connexion. | ||
| 55 | + - Tests (faux sbx qui simule le flux), doc EN + FR. | ||
| 56 | +tasks: | ||
| 57 | + - id: 1 | ||
| 58 | + title: "Go : lancer sbx login, lire le code, l'adresse et « Signed in as », attendre, annuler" | ||
| 59 | + state: closed | ||
| 60 | + priority: high | ||
| 61 | + author: | ||
| 62 | + name: k33g | ||
| 63 | + email: ph.charriere@gmail.com | ||
| 64 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 65 | + updatedAt: 2026-11-15T03:00:14.000Z | ||
| 66 | + closedAt: 2026-11-15T03:00:14.000Z | ||
| 67 | + - id: 2 | ||
| 68 | + title: "Service : Login, LoginStatus, CancelLogin (SbxCreatorService)" | ||
| 69 | + state: closed | ||
| 70 | + priority: high | ||
| 71 | + author: | ||
| 72 | + name: k33g | ||
| 73 | + email: ph.charriere@gmail.com | ||
| 74 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 75 | + updatedAt: 2026-11-15T03:00:14.000Z | ||
| 76 | + closedAt: 2026-11-15T03:00:14.000Z | ||
| 77 | + - id: 3 | ||
| 78 | + title: "Interface : composant de connexion (code, ouvrir la page, attente), dans l'assistant et sous l'erreur d'un agent" | ||
| 79 | + state: closed | ||
| 80 | + priority: high | ||
| 81 | + author: | ||
| 82 | + name: k33g | ||
| 83 | + email: ph.charriere@gmail.com | ||
| 84 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 85 | + updatedAt: 2026-11-15T03:00:14.000Z | ||
| 86 | + closedAt: 2026-11-15T03:00:14.000Z | ||
| 87 | + - id: 4 | ||
| 88 | + title: "Tests Go + vitest, essai sous Xvfb avec un faux sbx" | ||
| 89 | + state: closed | ||
| 90 | + priority: high | ||
| 91 | + author: | ||
| 92 | + name: k33g | ||
| 93 | + email: ph.charriere@gmail.com | ||
| 94 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 95 | + updatedAt: 2026-11-15T03:00:14.000Z | ||
| 96 | + closedAt: 2026-11-15T03:00:14.000Z | ||
| 97 | + - id: 5 | ||
| 98 | + title: "Doc EN + FR, notes de release v1.5.0" | ||
| 99 | + state: closed | ||
| 100 | + priority: medium | ||
| 101 | + author: | ||
| 102 | + name: k33g | ||
| 103 | + email: ph.charriere@gmail.com | ||
| 104 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 105 | + updatedAt: 2026-11-15T03:00:14.000Z | ||
| 106 | + closedAt: 2026-11-15T03:00:14.000Z | ||
| 107 | + - id: 6 | ||
| 108 | + title: "Essai sur le Mac (vrai sbx login, première utilisation)" | ||
| 109 | + state: open | ||
| 110 | + priority: high | ||
| 111 | + author: | ||
| 112 | + name: k33g | ||
| 113 | + email: ph.charriere@gmail.com | ||
| 114 | + createdAt: 2026-11-15T02:55:07.000Z | ||
| 115 | +comments: | ||
| 116 | + - id: 1 | ||
| 117 | + author: | ||
| 118 | + name: k33g | ||
| 119 | + email: ph.charriere@gmail.com | ||
| 120 | + createdAt: 2026-11-15T03:00:14.000Z | ||
| 121 | + body: | | ||
| 122 | + Implémenté sur la branche `feature/97-sbx-login` : `sbxcreate.StartLogin` (lit le code `XXXX-XXXX`, | ||
| 123 | + l'adresse `https://…login…` et « Signed in as … » ; entrée standard vide ; annulable), | ||
| 124 | + `SbxCreatorService.Login / LoginStatus / CancelLogin`, composant `SbxLogin.svelte` affiché par `ErrorText` | ||
| 125 | + sous l'erreur « not signed in to Docker » (assistant des sandboxes, qui reprend sa vérification une fois connecté, | ||
| 126 | + et erreur d'un agent sbx). Doc EN + FR, notes de release v1.5.0. | ||
| 127 | + | ||
| 128 | + Vérifié : tests Go (faux `sbx login` : code, adresse, attente, connecté, échec, annulation) et vitest, lint ; | ||
| 129 | + sous Xvfb avec un faux sbx qui refuse tant qu'on n'est pas connecté : bouton, code affiché, puis l'assistant | ||
| 130 | + passe tout seul à l'étape de la clé. Reste la tâche 6 : le vrai `sbx login` sur le Mac (format réel de la | ||
| 131 | + sortie, question de la politique réseau au premier usage). | ||
modified
docs/en/how-to/create-an-agent-in-a-sandbox.md +1 -0 | @@ -15,6 +15,7 @@ The agent's folder is created in your **Documents** folder, named after the agen | ||
| 15 | 15 | ## When something goes wrong |
| 16 | 16 | |
| 17 | 17 | - **"sbx (Docker Sandboxes) is not installed on this computer"**: install sbx, then click **Try again**. |
| 18 | +- **"sbx needs you to be signed in to Docker"**: click **Sign in to Docker**. Sidekicks shows a code: click **Open the sign-in page**, check that the page shows the same code, confirm and sign in with your Docker account (a free one is enough). The assistant goes on by itself once you are signed in. The same button appears under the error of an sbx agent that cannot start. If it does not work, type `sbx login` in a terminal once. | |
| 18 | 19 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. |
| 19 | 20 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe) in a terminal. |
| 20 | 21 | |
| @@ -15,6 +15,7 @@ The agent's folder is created in your **Documents** folder, named after the agen | |||
| 15 | ## When something goes wrong | 15 | ## When something goes wrong |
| 16 | 16 | ||
| 17 | - **"sbx (Docker Sandboxes) is not installed on this computer"**: install sbx, then click **Try again**. | 17 | - **"sbx (Docker Sandboxes) is not installed on this computer"**: install sbx, then click **Try again**. |
| 18 | +- **"sbx needs you to be signed in to Docker"**: click **Sign in to Docker**. Sidekicks shows a code: click **Open the sign-in page**, check that the page shows the same code, confirm and sign in with your Docker account (a free one is enough). The assistant goes on by itself once you are signed in. The same button appears under the error of an sbx agent that cannot start. If it does not work, type `sbx login` in a terminal once. | ||
| 18 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. | 19 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. |
| 19 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe) in a terminal. | 20 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe) in a terminal. |
| 20 | 21 | ||
modified
docs/en/reference/agents-and-events.md +3 -0 | @@ -268,6 +268,9 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | ||
| 268 | 268 | | `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl}`. | |
| 269 | 269 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder}`: whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | |
| 270 | 270 | | `SetKey(kind, key)` | `sbx secret set <service>` with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | |
| 271 | +| `Login()` | Runs `sbx login` (issue #97) — or joins the one in progress — and returns once sbx printed its device code and URL, 20 seconds at most: `{code, url, done, user, error, output[]}`. The code is the first `XXXX-XXXX`, the URL the first `https://…` naming `login`; `output` keeps every line for when sbx prints something else. Its standard input is empty: a question asked on the keyboard gets no answer. | | |
| 272 | +| `LoginStatus()` | Waits, 20 seconds at most, for `sbx login` to end and returns the same state; `done` with `user` (from `Signed in as <user>.`) when signed in, else `error` (`cancelled` after `CancelLogin`). The interface calls it again until `done`. | | |
| 273 | +| `CancelLogin()` | Stops `sbx login`; also done when Sidekicks quits. | | |
| 271 | 274 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | |
| 272 | 275 | |
| 273 | 276 | ## Tools offered to the agents |
| @@ -268,6 +268,9 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | |||
| 268 | | `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl}`. | | 268 | | `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl}`. | |
| 269 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder}`: whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | | 269 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder}`: whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | |
| 270 | | `SetKey(kind, key)` | `sbx secret set <service>` with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | | 270 | | `SetKey(kind, key)` | `sbx secret set <service>` with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | |
| 271 | +| `Login()` | Runs `sbx login` (issue #97) — or joins the one in progress — and returns once sbx printed its device code and URL, 20 seconds at most: `{code, url, done, user, error, output[]}`. The code is the first `XXXX-XXXX`, the URL the first `https://…` naming `login`; `output` keeps every line for when sbx prints something else. Its standard input is empty: a question asked on the keyboard gets no answer. | | ||
| 272 | +| `LoginStatus()` | Waits, 20 seconds at most, for `sbx login` to end and returns the same state; `done` with `user` (from `Signed in as <user>.`) when signed in, else `error` (`cancelled` after `CancelLogin`). The interface calls it again until `done`. | | ||
| 273 | +| `CancelLogin()` | Stops `sbx login`; also done when Sidekicks quits. | | ||
| 271 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | | 274 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | |
| 272 | 275 | ||
| 273 | ## Tools offered to the agents | 276 | ## Tools offered to the agents |
modified
docs/fr/how-to/creer-un-agent-dans-une-sandbox.md +1 -0 | @@ -15,6 +15,7 @@ Le dossier de l'agent est créé dans votre dossier **Documents**, au nom de l'a | ||
| 15 | 15 | ## Quand quelque chose ne va pas |
| 16 | 16 | |
| 17 | 17 | - **« sbx (Docker Sandboxes) n'est pas installé sur cet ordinateur »** : installez sbx, puis cliquez sur **Réessayer**. |
| 18 | +- **« sbx a besoin que vous soyez connecté à Docker »** : cliquez sur **Se connecter à Docker**. Sidekicks affiche un code : cliquez sur **Ouvrir la page de connexion**, vérifiez que la page montre le même code, confirmez et connectez-vous avec votre compte Docker (un compte gratuit suffit). L'assistant continue tout seul une fois la connexion faite. Le même bouton apparaît sous l'erreur d'un agent sbx qui ne démarre pas. Si cela ne fonctionne pas, tapez une fois `sbx login` dans un terminal. | |
| 18 | 19 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. |
| 19 | 20 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe) dans un terminal. |
| 20 | 21 | |
| @@ -15,6 +15,7 @@ Le dossier de l'agent est créé dans votre dossier **Documents**, au nom de l'a | |||
| 15 | ## Quand quelque chose ne va pas | 15 | ## Quand quelque chose ne va pas |
| 16 | 16 | ||
| 17 | - **« sbx (Docker Sandboxes) n'est pas installé sur cet ordinateur »** : installez sbx, puis cliquez sur **Réessayer**. | 17 | - **« sbx (Docker Sandboxes) n'est pas installé sur cet ordinateur »** : installez sbx, puis cliquez sur **Réessayer**. |
| 18 | +- **« sbx a besoin que vous soyez connecté à Docker »** : cliquez sur **Se connecter à Docker**. Sidekicks affiche un code : cliquez sur **Ouvrir la page de connexion**, vérifiez que la page montre le même code, confirmez et connectez-vous avec votre compte Docker (un compte gratuit suffit). L'assistant continue tout seul une fois la connexion faite. Le même bouton apparaît sous l'erreur d'un agent sbx qui ne démarre pas. Si cela ne fonctionne pas, tapez une fois `sbx login` dans un terminal. | ||
| 18 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. | 19 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. |
| 19 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe) dans un terminal. | 20 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe) dans un terminal. |
| 20 | 21 | ||
modified
docs/fr/reference/agents-et-evenements.md +3 -0 | @@ -268,6 +268,9 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | ||
| 268 | 268 | | `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl}`. | |
| 269 | 269 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder}` : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | |
| 270 | 270 | | `SetKey(kind, key)` | `sbx secret set <service>` avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | |
| 271 | +| `Login()` | Lance `sbx login` (issue #97) — ou rejoint celui en cours — et revient dès que sbx a affiché son code et son adresse, 20 secondes au plus : `{code, url, done, user, error, output[]}`. Le code est le premier `XXXX-XXXX`, l'adresse le premier `https://…` qui contient `login` ; `output` garde chaque ligne pour le cas où sbx affiche autre chose. Son entrée standard est vide : une question posée au clavier n'a pas de réponse. | | |
| 272 | +| `LoginStatus()` | Attend, 20 secondes au plus, la fin de `sbx login` et renvoie le même état ; `done` avec `user` (tiré de `Signed in as <user>.`) une fois connecté, sinon `error` (`cancelled` après `CancelLogin`). L'interface le rappelle jusqu'à `done`. | | |
| 273 | +| `CancelLogin()` | Arrête `sbx login` ; fait aussi quand Sidekicks se ferme. | | |
| 271 | 274 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | |
| 272 | 275 | |
| 273 | 276 | ## Outils proposés aux agents |
| @@ -268,6 +268,9 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | |||
| 268 | | `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl}`. | | 268 | | `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl}`. | |
| 269 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder}` : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | | 269 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder}` : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | |
| 270 | | `SetKey(kind, key)` | `sbx secret set <service>` avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | | 270 | | `SetKey(kind, key)` | `sbx secret set <service>` avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | |
| 271 | +| `Login()` | Lance `sbx login` (issue #97) — ou rejoint celui en cours — et revient dès que sbx a affiché son code et son adresse, 20 secondes au plus : `{code, url, done, user, error, output[]}`. Le code est le premier `XXXX-XXXX`, l'adresse le premier `https://…` qui contient `login` ; `output` garde chaque ligne pour le cas où sbx affiche autre chose. Son entrée standard est vide : une question posée au clavier n'a pas de réponse. | | ||
| 272 | +| `LoginStatus()` | Attend, 20 secondes au plus, la fin de `sbx login` et renvoie le même état ; `done` avec `user` (tiré de `Signed in as <user>.`) une fois connecté, sinon `error` (`cancelled` après `CancelLogin`). L'interface le rappelle jusqu'à `done`. | | ||
| 273 | +| `CancelLogin()` | Arrête `sbx login` ; fait aussi quand Sidekicks se ferme. | | ||
| 271 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | | 274 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | |
| 272 | 275 | ||
| 273 | ## Outils proposés aux agents | 276 | ## Outils proposés aux agents |
modified
docs/release-notes/v1.5.0.fr.md +1 -0 | @@ -20,6 +20,7 @@ Sidekicks 1.5.0 rend la création d'agents facile pour tout le monde : deux assi | ||
| 20 | 20 | - **✨ Créer un agent dans une sandbox** — sous la liste des agents, sur l'écran d'accueil et dans la palette de commandes : choisissez **Claude**, **Gemini** (via Google Antigravity), **Codex** ou **Vibe** (Mistral AI, #86), donnez-lui un nom et un emoji, et Sidekicks écrit son dossier dans votre dossier Documents (son `sbxenv.yaml` et son `workspace/`) puis l'ajoute. Sa sandbox est créée à son premier démarrage. |
| 21 | 21 | - Pas encore de clé d'API dans sbx ? L'assistant explique laquelle il faut, ouvre la page qui en donne une, et la confie à sbx (`sbx secret set`) : la clé n'est jamais écrite dans un fichier ni dans un journal. |
| 22 | 22 | - Le nom donné est aussi celui du dossier et de la sandbox ; Sidekicks en propose un qui est libre. |
| 23 | +- Pas encore connecté à Docker ? **Se connecter à Docker** lance `sbx login` pour vous : Sidekicks affiche le code et ouvre la page où vous le confirmez, puis continue (#97). Le même bouton apparaît sous l'erreur d'un agent sbx qui ne démarre pas. | |
| 23 | 24 | - L'assistant « Ajouter un agent » reconnaît aussi une sandbox de Gemini via Antigravity (`agent: antigravity` : `agy acp`) et de Vibe (`agent: vibe` : `vibe-acp`). |
| 24 | 25 | |
| 25 | 26 | → [Créer un agent Claude, Gemini, Codex ou Vibe dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) |
| @@ -20,6 +20,7 @@ Sidekicks 1.5.0 rend la création d'agents facile pour tout le monde : deux assi | |||
| 20 | - **✨ Créer un agent dans une sandbox** — sous la liste des agents, sur l'écran d'accueil et dans la palette de commandes : choisissez **Claude**, **Gemini** (via Google Antigravity), **Codex** ou **Vibe** (Mistral AI, #86), donnez-lui un nom et un emoji, et Sidekicks écrit son dossier dans votre dossier Documents (son `sbxenv.yaml` et son `workspace/`) puis l'ajoute. Sa sandbox est créée à son premier démarrage. | 20 | - **✨ Créer un agent dans une sandbox** — sous la liste des agents, sur l'écran d'accueil et dans la palette de commandes : choisissez **Claude**, **Gemini** (via Google Antigravity), **Codex** ou **Vibe** (Mistral AI, #86), donnez-lui un nom et un emoji, et Sidekicks écrit son dossier dans votre dossier Documents (son `sbxenv.yaml` et son `workspace/`) puis l'ajoute. Sa sandbox est créée à son premier démarrage. |
| 21 | - Pas encore de clé d'API dans sbx ? L'assistant explique laquelle il faut, ouvre la page qui en donne une, et la confie à sbx (`sbx secret set`) : la clé n'est jamais écrite dans un fichier ni dans un journal. | 21 | - Pas encore de clé d'API dans sbx ? L'assistant explique laquelle il faut, ouvre la page qui en donne une, et la confie à sbx (`sbx secret set`) : la clé n'est jamais écrite dans un fichier ni dans un journal. |
| 22 | - Le nom donné est aussi celui du dossier et de la sandbox ; Sidekicks en propose un qui est libre. | 22 | - Le nom donné est aussi celui du dossier et de la sandbox ; Sidekicks en propose un qui est libre. |
| 23 | +- Pas encore connecté à Docker ? **Se connecter à Docker** lance `sbx login` pour vous : Sidekicks affiche le code et ouvre la page où vous le confirmez, puis continue (#97). Le même bouton apparaît sous l'erreur d'un agent sbx qui ne démarre pas. | ||
| 23 | - L'assistant « Ajouter un agent » reconnaît aussi une sandbox de Gemini via Antigravity (`agent: antigravity` : `agy acp`) et de Vibe (`agent: vibe` : `vibe-acp`). | 24 | - L'assistant « Ajouter un agent » reconnaît aussi une sandbox de Gemini via Antigravity (`agent: antigravity` : `agy acp`) et de Vibe (`agent: vibe` : `vibe-acp`). |
| 24 | 25 | ||
| 25 | → [Créer un agent Claude, Gemini, Codex ou Vibe dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) | 26 | → [Créer un agent Claude, Gemini, Codex ou Vibe dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) |
modified
docs/release-notes/v1.5.0.md +1 -0 | @@ -20,6 +20,7 @@ Sidekicks 1.5.0 makes creating agents easy for everyone: two assistants create a | ||
| 20 | 20 | - **✨ Create an agent in a sandbox** — under the agents list, on the welcome screen and in the command palette: choose **Claude**, **Gemini** (through Google Antigravity), **Codex** or **Vibe** (Mistral AI, #86), give it a name and an emoji, and Sidekicks writes its folder in your Documents folder (its `sbxenv.yaml` and its `workspace/`) and adds it. Its sandbox is created at its first start. |
| 21 | 21 | - No API key in sbx yet? The assistant explains which one is needed, opens the page that gives one, and stores it with sbx (`sbx secret set`): the key is never written in a file nor in a log. |
| 22 | 22 | - The name you give is also the folder's and the sandbox's; Sidekicks suggests one that is free. |
| 23 | +- Not signed in to Docker yet? **Sign in to Docker** runs `sbx login` for you: Sidekicks shows the code and opens the page where you confirm it, then goes on (#97). The same button appears under the error of an sbx agent that cannot start. | |
| 23 | 24 | - The "Add an agent" assistant also recognises a sandbox of Gemini through Antigravity (`agent: antigravity`: `agy acp`) and of Vibe (`agent: vibe`: `vibe-acp`). |
| 24 | 25 | |
| 25 | 26 | → [Create a Claude, Gemini, Codex or Vibe agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) |
| @@ -20,6 +20,7 @@ Sidekicks 1.5.0 makes creating agents easy for everyone: two assistants create a | |||
| 20 | - **✨ Create an agent in a sandbox** — under the agents list, on the welcome screen and in the command palette: choose **Claude**, **Gemini** (through Google Antigravity), **Codex** or **Vibe** (Mistral AI, #86), give it a name and an emoji, and Sidekicks writes its folder in your Documents folder (its `sbxenv.yaml` and its `workspace/`) and adds it. Its sandbox is created at its first start. | 20 | - **✨ Create an agent in a sandbox** — under the agents list, on the welcome screen and in the command palette: choose **Claude**, **Gemini** (through Google Antigravity), **Codex** or **Vibe** (Mistral AI, #86), give it a name and an emoji, and Sidekicks writes its folder in your Documents folder (its `sbxenv.yaml` and its `workspace/`) and adds it. Its sandbox is created at its first start. |
| 21 | - No API key in sbx yet? The assistant explains which one is needed, opens the page that gives one, and stores it with sbx (`sbx secret set`): the key is never written in a file nor in a log. | 21 | - No API key in sbx yet? The assistant explains which one is needed, opens the page that gives one, and stores it with sbx (`sbx secret set`): the key is never written in a file nor in a log. |
| 22 | - The name you give is also the folder's and the sandbox's; Sidekicks suggests one that is free. | 22 | - The name you give is also the folder's and the sandbox's; Sidekicks suggests one that is free. |
| 23 | +- Not signed in to Docker yet? **Sign in to Docker** runs `sbx login` for you: Sidekicks shows the code and opens the page where you confirm it, then goes on (#97). The same button appears under the error of an sbx agent that cannot start. | ||
| 23 | - The "Add an agent" assistant also recognises a sandbox of Gemini through Antigravity (`agent: antigravity`: `agy acp`) and of Vibe (`agent: vibe`: `vibe-acp`). | 24 | - The "Add an agent" assistant also recognises a sandbox of Gemini through Antigravity (`agent: antigravity`: `agy acp`) and of Vibe (`agent: vibe`: `vibe-acp`). |
| 24 | 25 | ||
| 25 | → [Create a Claude, Gemini, Codex or Vibe agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) | 26 | → [Create a Claude, Gemini, Codex or Vibe agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.5.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/sbxcreatorservice.ts +24 -0 | @@ -27,6 +27,14 @@ import * as sbxcreate$0 from "../sbxcreate/models.js"; | ||
| 27 | 27 | // @ts-ignore: Unused imports |
| 28 | 28 | import * as $models from "./models.js"; |
| 29 | 29 | |
| 30 | +/** | |
| 31 | + * CancelLogin stops the sign-in in progress, if any. Also done when | |
| 32 | + * Sidekicks quits. | |
| 33 | + */ | |
| 34 | +export function CancelLogin(): $CancellablePromise<void> { | |
| 35 | + return $Call.ByID(1506734565); | |
| 36 | +} | |
| 37 | + | |
| 30 | 38 | /** |
| 31 | 39 | * Check checks that sbx is installed ("sbx is not installed" otherwise), |
| 32 | 40 | * whether the kind's key is stored, and suggests a free name: the kind's |
| @@ -53,6 +61,22 @@ export function Kinds(): $CancellablePromise<sbxcreate$0.Kind[] | null> { | ||
| 53 | 61 | return $Call.ByID(2047680797); |
| 54 | 62 | } |
| 55 | 63 | |
| 64 | +/** | |
| 65 | + * Login starts `sbx login` — or joins the one in progress — and returns once | |
| 66 | + * sbx printed the code and the URL the user confirms in a browser (or ended). | |
| 67 | + */ | |
| 68 | +export function Login(): $CancellablePromise<sbxcreate$0.LoginState> { | |
| 69 | + return $Call.ByID(1822202511); | |
| 70 | +} | |
| 71 | + | |
| 72 | +/** | |
| 73 | + * LoginStatus waits — 20 seconds at most — for the sign-in to end, and | |
| 74 | + * returns where it is. | |
| 75 | + */ | |
| 76 | +export function LoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | |
| 77 | + return $Call.ByID(931111353); | |
| 78 | +} | |
| 79 | + | |
| 56 | 80 | /** |
| 57 | 81 | * SetKey stores the kind's key in sbx, for every sandbox. The key goes to |
| 58 | 82 | * sbx on its standard input; it is never written in a file nor in a log. |
| @@ -27,6 +27,14 @@ import * as sbxcreate$0 from "../sbxcreate/models.js"; | |||
| 27 | // @ts-ignore: Unused imports | 27 | // @ts-ignore: Unused imports |
| 28 | import * as $models from "./models.js"; | 28 | import * as $models from "./models.js"; |
| 29 | 29 | ||
| 30 | +/** | ||
| 31 | + * CancelLogin stops the sign-in in progress, if any. Also done when | ||
| 32 | + * Sidekicks quits. | ||
| 33 | + */ | ||
| 34 | +export function CancelLogin(): $CancellablePromise<void> { | ||
| 35 | + return $Call.ByID(1506734565); | ||
| 36 | +} | ||
| 37 | + | ||
| 30 | /** | 38 | /** |
| 31 | * Check checks that sbx is installed ("sbx is not installed" otherwise), | 39 | * Check checks that sbx is installed ("sbx is not installed" otherwise), |
| 32 | * whether the kind's key is stored, and suggests a free name: the kind's | 40 | * whether the kind's key is stored, and suggests a free name: the kind's |
| @@ -53,6 +61,22 @@ export function Kinds(): $CancellablePromise<sbxcreate$0.Kind[] | null> { | |||
| 53 | return $Call.ByID(2047680797); | 61 | return $Call.ByID(2047680797); |
| 54 | } | 62 | } |
| 55 | 63 | ||
| 64 | +/** | ||
| 65 | + * Login starts `sbx login` — or joins the one in progress — and returns once | ||
| 66 | + * sbx printed the code and the URL the user confirms in a browser (or ended). | ||
| 67 | + */ | ||
| 68 | +export function Login(): $CancellablePromise<sbxcreate$0.LoginState> { | ||
| 69 | + return $Call.ByID(1822202511); | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +/** | ||
| 73 | + * LoginStatus waits — 20 seconds at most — for the sign-in to end, and | ||
| 74 | + * returns where it is. | ||
| 75 | + */ | ||
| 76 | +export function LoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | ||
| 77 | + return $Call.ByID(931111353); | ||
| 78 | +} | ||
| 79 | + | ||
| 56 | /** | 80 | /** |
| 57 | * SetKey stores the kind's key in sbx, for every sandbox. The key goes to | 81 | * SetKey stores the kind's key in sbx, for every sandbox. The key goes to |
| 58 | * sbx on its standard input; it is never written in a file nor in a log. | 82 | * sbx on its standard input; it is never written in a file nor in a log. |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate/index.ts +2 -1 | @@ -2,5 +2,6 @@ | ||
| 2 | 2 | // This file is automatically generated. DO NOT EDIT |
| 3 | 3 | |
| 4 | 4 | export type { |
| 5 | - Kind | |
| 5 | + Kind, | |
| 6 | + LoginState | |
| 6 | 7 | } from "./models.js"; |
| @@ -2,5 +2,6 @@ | |||
| 2 | // This file is automatically generated. DO NOT EDIT | 2 | // This file is automatically generated. DO NOT EDIT |
| 3 | 3 | ||
| 4 | export type { | 4 | export type { |
| 5 | - Kind | 5 | + Kind, |
| 6 | + LoginState | ||
| 6 | } from "./models.js"; | 7 | } from "./models.js"; |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate/models.ts +24 -0 | @@ -32,3 +32,27 @@ export interface Kind { | ||
| 32 | 32 | */ |
| 33 | 33 | "keyUrl": string; |
| 34 | 34 | } |
| 35 | + | |
| 36 | +/** | |
| 37 | + * LoginState is what the interface shows of a sign-in in progress. | |
| 38 | + */ | |
| 39 | +export interface LoginState { | |
| 40 | + /** | |
| 41 | + * Code and URL are what the user confirms in a browser; "" until sbx | |
| 42 | + * printed them. | |
| 43 | + */ | |
| 44 | + "code": string; | |
| 45 | + "url": string; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Done: sbx login ended. User is who is signed in ("" when it failed). | |
| 49 | + */ | |
| 50 | + "done": boolean; | |
| 51 | + "user": string; | |
| 52 | + "error": string; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Output is what sbx printed, for when its lines are not the expected ones. | |
| 56 | + */ | |
| 57 | + "output": string[] | null; | |
| 58 | +} | |
| @@ -32,3 +32,27 @@ export interface Kind { | |||
| 32 | */ | 32 | */ |
| 33 | "keyUrl": string; | 33 | "keyUrl": string; |
| 34 | } | 34 | } |
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * LoginState is what the interface shows of a sign-in in progress. | ||
| 38 | + */ | ||
| 39 | +export interface LoginState { | ||
| 40 | + /** | ||
| 41 | + * Code and URL are what the user confirms in a browser; "" until sbx | ||
| 42 | + * printed them. | ||
| 43 | + */ | ||
| 44 | + "code": string; | ||
| 45 | + "url": string; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Done: sbx login ended. User is who is signed in ("" when it failed). | ||
| 49 | + */ | ||
| 50 | + "done": boolean; | ||
| 51 | + "user": string; | ||
| 52 | + "error": string; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Output is what sbx printed, for when its lines are not the expected ones. | ||
| 56 | + */ | ||
| 57 | + "output": string[] | null; | ||
| 58 | +} | ||
modified
frontend/src/lib/agent/CreateSbxAgent.svelte +1 -1 | @@ -131,7 +131,7 @@ | ||
| 131 | 131 | <p class="status" role="status"><Spinner /> {t('sbxCreator.checking')}</p> |
| 132 | 132 | {:else if step === 'failed'} |
| 133 | 133 | <div class="problem" role="alert"> |
| 134 | - {#if sbxMissing(failure)}{t('sbxCreator.sbxMissing')}{:else}<ErrorText raw={failure} />{/if} | |
| 134 | + {#if sbxMissing(failure)}{t('sbxCreator.sbxMissing')}{:else}<ErrorText raw={failure} onSignedIn={check} />{/if} | |
| 135 | 135 | </div> |
| 136 | 136 | <div class="actions"> |
| 137 | 137 | <button type="button" onclick={close}>{t('creator.cancel')}</button> |
| @@ -131,7 +131,7 @@ | |||
| 131 | <p class="status" role="status"><Spinner /> {t('sbxCreator.checking')}</p> | 131 | <p class="status" role="status"><Spinner /> {t('sbxCreator.checking')}</p> |
| 132 | {:else if step === 'failed'} | 132 | {:else if step === 'failed'} |
| 133 | <div class="problem" role="alert"> | 133 | <div class="problem" role="alert"> |
| 134 | - {#if sbxMissing(failure)}{t('sbxCreator.sbxMissing')}{:else}<ErrorText raw={failure} />{/if} | 134 | + {#if sbxMissing(failure)}{t('sbxCreator.sbxMissing')}{:else}<ErrorText raw={failure} onSignedIn={check} />{/if} |
| 135 | </div> | 135 | </div> |
| 136 | <div class="actions"> | 136 | <div class="actions"> |
| 137 | <button type="button" onclick={close}>{t('creator.cancel')}</button> | 137 | <button type="button" onclick={close}>{t('creator.cancel')}</button> |
modified
frontend/src/lib/chat/ErrorText.svelte +5 -1 | @@ -3,15 +3,19 @@ | ||
| 3 | 3 | // An error in plain words when it is a known one (lib/errors.ts), with the |
| 4 | 4 | // technical text folded below; otherwise the text as it is. |
| 5 | 5 | // Usage: <ErrorText raw={agent.error} /> |
| 6 | + // sbx not signed in to Docker (issue #97) also offers to sign in; | |
| 7 | + // onSignedIn runs once it is done (an assistant checks again). | |
| 6 | 8 | import { explain } from '../errors' |
| 7 | 9 | import { t } from '../i18n/index.svelte' |
| 10 | + import SbxLogin from './SbxLogin.svelte' | |
| 8 | 11 | |
| 9 | - let { raw }: { raw: string } = $props() | |
| 12 | + let { raw, onSignedIn }: { raw: string; onSignedIn?: () => void } = $props() | |
| 10 | 13 | const explanation = $derived(explain(raw)) |
| 11 | 14 | </script> |
| 12 | 15 | |
| 13 | 16 | {#if explanation} |
| 14 | 17 | <span class="explained">{t(explanation.key, explanation.vars)}</span> |
| 18 | + {#if explanation.key === 'error.sbxNotSignedIn'}<SbxLogin onDone={onSignedIn} />{/if} | |
| 15 | 19 | <details> |
| 16 | 20 | <summary>{t('error.details')}</summary> |
| 17 | 21 | <code>{raw}</code> |
| @@ -3,15 +3,19 @@ | |||
| 3 | // An error in plain words when it is a known one (lib/errors.ts), with the | 3 | // An error in plain words when it is a known one (lib/errors.ts), with the |
| 4 | // technical text folded below; otherwise the text as it is. | 4 | // technical text folded below; otherwise the text as it is. |
| 5 | // Usage: <ErrorText raw={agent.error} /> | 5 | // Usage: <ErrorText raw={agent.error} /> |
| 6 | + // sbx not signed in to Docker (issue #97) also offers to sign in; | ||
| 7 | + // onSignedIn runs once it is done (an assistant checks again). | ||
| 6 | import { explain } from '../errors' | 8 | import { explain } from '../errors' |
| 7 | import { t } from '../i18n/index.svelte' | 9 | import { t } from '../i18n/index.svelte' |
| 10 | + import SbxLogin from './SbxLogin.svelte' | ||
| 8 | 11 | ||
| 9 | - let { raw }: { raw: string } = $props() | 12 | + let { raw, onSignedIn }: { raw: string; onSignedIn?: () => void } = $props() |
| 10 | const explanation = $derived(explain(raw)) | 13 | const explanation = $derived(explain(raw)) |
| 11 | </script> | 14 | </script> |
| 12 | 15 | ||
| 13 | {#if explanation} | 16 | {#if explanation} |
| 14 | <span class="explained">{t(explanation.key, explanation.vars)}</span> | 17 | <span class="explained">{t(explanation.key, explanation.vars)}</span> |
| 18 | + {#if explanation.key === 'error.sbxNotSignedIn'}<SbxLogin onDone={onSignedIn} />{/if} | ||
| 15 | <details> | 19 | <details> |
| 16 | <summary>{t('error.details')}</summary> | 20 | <summary>{t('error.details')}</summary> |
| 17 | <code>{raw}</code> | 21 | <code>{raw}</code> |
added
frontend/src/lib/chat/SbxLogin.svelte +95 -0 | new file mode 100644 | ||
| @@ -0,0 +1,95 @@ | ||
| 1 | +<!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> | |
| 2 | +<script lang="ts"> | |
| 3 | + // Signing in to Docker from Sidekicks (issue #97): sbx refuses to work | |
| 4 | + // until its user is signed in. "Sign in to Docker" runs `sbx login` | |
| 5 | + // (SbxCreatorService.Login), shows the code and a button that opens the | |
| 6 | + // page where the user confirms it, then waits (LoginStatus, called again | |
| 7 | + // until sbx says who signed in). Shown under the error by ErrorText. | |
| 8 | + import { onDestroy } from 'svelte' | |
| 9 | + import { Browser } from '@wailsio/runtime' | |
| 10 | + import { t } from '../i18n/index.svelte' | |
| 11 | + import { SbxCreatorService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | |
| 12 | + import type { LoginState } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate' | |
| 13 | + import Spinner from './Spinner.svelte' | |
| 14 | + | |
| 15 | + let { onDone }: { onDone?: () => void } = $props() | |
| 16 | + | |
| 17 | + type Step = 'idle' | 'starting' | 'waiting' | 'signed' | 'failed' | |
| 18 | + let step = $state<Step>('idle') | |
| 19 | + let login = $state<LoginState | null>(null) | |
| 20 | + let failure = $state('') | |
| 21 | + let active = true | |
| 22 | + | |
| 23 | + async function start() { | |
| 24 | + step = 'starting' | |
| 25 | + failure = '' | |
| 26 | + try { | |
| 27 | + login = await SbxCreatorService.Login() | |
| 28 | + step = 'waiting' | |
| 29 | + // Ask again until sbx ends: each call waits up to 20 seconds. | |
| 30 | + while (active && login && !login.done) login = await SbxCreatorService.LoginStatus() | |
| 31 | + if (!active || !login) return | |
| 32 | + if (login.user) { | |
| 33 | + step = 'signed' | |
| 34 | + onDone?.() | |
| 35 | + } else { | |
| 36 | + failure = login.error | |
| 37 | + step = 'failed' | |
| 38 | + } | |
| 39 | + } catch (caught) { | |
| 40 | + failure = caught instanceof Error ? caught.message : String(caught) | |
| 41 | + step = 'failed' | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + function cancel() { | |
| 46 | + void SbxCreatorService.CancelLogin() | |
| 47 | + step = 'idle' | |
| 48 | + } | |
| 49 | + | |
| 50 | + onDestroy(() => { | |
| 51 | + active = false | |
| 52 | + if (step === 'starting' || step === 'waiting') void SbxCreatorService.CancelLogin() | |
| 53 | + }) | |
| 54 | +</script> | |
| 55 | + | |
| 56 | +<div class="sbx-login"> | |
| 57 | + {#if step === 'idle'} | |
| 58 | + <button type="button" class="primary" onclick={start}>{t('sbxLogin.start')}</button> | |
| 59 | + {:else if step === 'starting'} | |
| 60 | + <p role="status"><Spinner /> {t('sbxLogin.starting')}</p> | |
| 61 | + {:else if step === 'waiting' && login} | |
| 62 | + {#if login.code} | |
| 63 | + <p>{t('sbxLogin.code')}</p> | |
| 64 | + <p class="code" aria-label={t('sbxLogin.codeLabel')}>{login.code}</p> | |
| 65 | + {/if} | |
| 66 | + {#if login.url} | |
| 67 | + <button type="button" class="primary" onclick={() => login && Browser.OpenURL(login.url)}>{t('sbxLogin.open')}</button> | |
| 68 | + {:else} | |
| 69 | + <pre>{(login.output ?? []).join('\n')}</pre> | |
| 70 | + {/if} | |
| 71 | + <p role="status"><Spinner /> {t('sbxLogin.waiting')}</p> | |
| 72 | + <button type="button" onclick={cancel}>{t('creator.cancel')}</button> | |
| 73 | + {:else if step === 'signed' && login} | |
| 74 | + <p class="ok" role="status">{t('sbxLogin.signed', { user: login.user })}</p> | |
| 75 | + {:else if step === 'failed'} | |
| 76 | + <p class="failed" role="alert">{failure === 'cancelled' ? t('sbxLogin.cancelled') : t('sbxLogin.failed')}</p> | |
| 77 | + {#if login && (login.output ?? []).length > 0} | |
| 78 | + <details><summary>{t('error.details')}</summary><pre>{(login.output ?? []).join('\n')}</pre></details> | |
| 79 | + {:else if failure && failure !== 'cancelled'} | |
| 80 | + <details><summary>{t('error.details')}</summary><pre>{failure}</pre></details> | |
| 81 | + {/if} | |
| 82 | + <button type="button" onclick={start}>{t('creator.retry')}</button> | |
| 83 | + {/if} | |
| 84 | +</div> | |
| 85 | + | |
| 86 | +<style> | |
| 87 | + .sbx-login { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; color: var(--text); } | |
| 88 | + .sbx-login p { margin: 0; display: flex; align-items: center; gap: 6px; } | |
| 89 | + .code { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: 2px; user-select: all; } | |
| 90 | + pre { margin: 0; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; } | |
| 91 | + .ok { color: var(--ok, var(--text)); } | |
| 92 | + .failed { color: var(--danger); } | |
| 93 | + details { font-size: 11px; } | |
| 94 | + .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } | |
| 95 | +</style> | |
| new file mode 100644 | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | +<!-- Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE --> | ||
| 2 | +<script lang="ts"> | ||
| 3 | + // Signing in to Docker from Sidekicks (issue #97): sbx refuses to work | ||
| 4 | + // until its user is signed in. "Sign in to Docker" runs `sbx login` | ||
| 5 | + // (SbxCreatorService.Login), shows the code and a button that opens the | ||
| 6 | + // page where the user confirms it, then waits (LoginStatus, called again | ||
| 7 | + // until sbx says who signed in). Shown under the error by ErrorText. | ||
| 8 | + import { onDestroy } from 'svelte' | ||
| 9 | + import { Browser } from '@wailsio/runtime' | ||
| 10 | + import { t } from '../i18n/index.svelte' | ||
| 11 | + import { SbxCreatorService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | ||
| 12 | + import type { LoginState } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate' | ||
| 13 | + import Spinner from './Spinner.svelte' | ||
| 14 | + | ||
| 15 | + let { onDone }: { onDone?: () => void } = $props() | ||
| 16 | + | ||
| 17 | + type Step = 'idle' | 'starting' | 'waiting' | 'signed' | 'failed' | ||
| 18 | + let step = $state<Step>('idle') | ||
| 19 | + let login = $state<LoginState | null>(null) | ||
| 20 | + let failure = $state('') | ||
| 21 | + let active = true | ||
| 22 | + | ||
| 23 | + async function start() { | ||
| 24 | + step = 'starting' | ||
| 25 | + failure = '' | ||
| 26 | + try { | ||
| 27 | + login = await SbxCreatorService.Login() | ||
| 28 | + step = 'waiting' | ||
| 29 | + // Ask again until sbx ends: each call waits up to 20 seconds. | ||
| 30 | + while (active && login && !login.done) login = await SbxCreatorService.LoginStatus() | ||
| 31 | + if (!active || !login) return | ||
| 32 | + if (login.user) { | ||
| 33 | + step = 'signed' | ||
| 34 | + onDone?.() | ||
| 35 | + } else { | ||
| 36 | + failure = login.error | ||
| 37 | + step = 'failed' | ||
| 38 | + } | ||
| 39 | + } catch (caught) { | ||
| 40 | + failure = caught instanceof Error ? caught.message : String(caught) | ||
| 41 | + step = 'failed' | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + function cancel() { | ||
| 46 | + void SbxCreatorService.CancelLogin() | ||
| 47 | + step = 'idle' | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + onDestroy(() => { | ||
| 51 | + active = false | ||
| 52 | + if (step === 'starting' || step === 'waiting') void SbxCreatorService.CancelLogin() | ||
| 53 | + }) | ||
| 54 | +</script> | ||
| 55 | + | ||
| 56 | +<div class="sbx-login"> | ||
| 57 | + {#if step === 'idle'} | ||
| 58 | + <button type="button" class="primary" onclick={start}>{t('sbxLogin.start')}</button> | ||
| 59 | + {:else if step === 'starting'} | ||
| 60 | + <p role="status"><Spinner /> {t('sbxLogin.starting')}</p> | ||
| 61 | + {:else if step === 'waiting' && login} | ||
| 62 | + {#if login.code} | ||
| 63 | + <p>{t('sbxLogin.code')}</p> | ||
| 64 | + <p class="code" aria-label={t('sbxLogin.codeLabel')}>{login.code}</p> | ||
| 65 | + {/if} | ||
| 66 | + {#if login.url} | ||
| 67 | + <button type="button" class="primary" onclick={() => login && Browser.OpenURL(login.url)}>{t('sbxLogin.open')}</button> | ||
| 68 | + {:else} | ||
| 69 | + <pre>{(login.output ?? []).join('\n')}</pre> | ||
| 70 | + {/if} | ||
| 71 | + <p role="status"><Spinner /> {t('sbxLogin.waiting')}</p> | ||
| 72 | + <button type="button" onclick={cancel}>{t('creator.cancel')}</button> | ||
| 73 | + {:else if step === 'signed' && login} | ||
| 74 | + <p class="ok" role="status">{t('sbxLogin.signed', { user: login.user })}</p> | ||
| 75 | + {:else if step === 'failed'} | ||
| 76 | + <p class="failed" role="alert">{failure === 'cancelled' ? t('sbxLogin.cancelled') : t('sbxLogin.failed')}</p> | ||
| 77 | + {#if login && (login.output ?? []).length > 0} | ||
| 78 | + <details><summary>{t('error.details')}</summary><pre>{(login.output ?? []).join('\n')}</pre></details> | ||
| 79 | + {:else if failure && failure !== 'cancelled'} | ||
| 80 | + <details><summary>{t('error.details')}</summary><pre>{failure}</pre></details> | ||
| 81 | + {/if} | ||
| 82 | + <button type="button" onclick={start}>{t('creator.retry')}</button> | ||
| 83 | + {/if} | ||
| 84 | +</div> | ||
| 85 | + | ||
| 86 | +<style> | ||
| 87 | + .sbx-login { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; color: var(--text); } | ||
| 88 | + .sbx-login p { margin: 0; display: flex; align-items: center; gap: 6px; } | ||
| 89 | + .code { font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: 2px; user-select: all; } | ||
| 90 | + pre { margin: 0; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; } | ||
| 91 | + .ok { color: var(--ok, var(--text)); } | ||
| 92 | + .failed { color: var(--danger); } | ||
| 93 | + details { font-size: 11px; } | ||
| 94 | + .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } | ||
| 95 | +</style> | ||
modified
frontend/src/lib/errors.test.ts +5 -0 | @@ -18,6 +18,11 @@ describe('explain', () => { | ||
| 18 | 18 | expect(explain('docker-agent: self-update failed\nError: accepts 1 arg(s), received 0')).toEqual({ key: 'error.agentFileMissing', vars: {} }) |
| 19 | 19 | }) |
| 20 | 20 | |
| 21 | + it('recognises sbx before sbx login (issue #97)', () => { | |
| 22 | + expect(explain('sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart')?.key).toBe('error.sbxNotSignedIn') | |
| 23 | + expect(explain('You are not authenticated to Docker. Starting the sign-in flow...')?.key).toBe('error.sbxNotSignedIn') | |
| 24 | + }) | |
| 25 | + | |
| 21 | 26 | it('recognises the limit of running agents', () => { |
| 22 | 27 | expect(explain('too many agents running: 2 agent(s) busy (alice, bob), the limit is 2')).toEqual({ key: 'error.limitReached', vars: { limit: '2' } }) |
| 23 | 28 | }) |
| @@ -18,6 +18,11 @@ describe('explain', () => { | |||
| 18 | expect(explain('docker-agent: self-update failed\nError: accepts 1 arg(s), received 0')).toEqual({ key: 'error.agentFileMissing', vars: {} }) | 18 | expect(explain('docker-agent: self-update failed\nError: accepts 1 arg(s), received 0')).toEqual({ key: 'error.agentFileMissing', vars: {} }) |
| 19 | }) | 19 | }) |
| 20 | 20 | ||
| 21 | + it('recognises sbx before sbx login (issue #97)', () => { | ||
| 22 | + expect(explain('sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart')?.key).toBe('error.sbxNotSignedIn') | ||
| 23 | + expect(explain('You are not authenticated to Docker. Starting the sign-in flow...')?.key).toBe('error.sbxNotSignedIn') | ||
| 24 | + }) | ||
| 25 | + | ||
| 21 | it('recognises the limit of running agents', () => { | 26 | it('recognises the limit of running agents', () => { |
| 22 | expect(explain('too many agents running: 2 agent(s) busy (alice, bob), the limit is 2')).toEqual({ key: 'error.limitReached', vars: { limit: '2' } }) | 27 | expect(explain('too many agents running: 2 agent(s) busy (alice, bob), the limit is 2')).toEqual({ key: 'error.limitReached', vars: { limit: '2' } }) |
| 23 | }) | 28 | }) |
modified
frontend/src/lib/errors.ts +2 -0 | @@ -21,6 +21,8 @@ interface Rule { | ||
| 21 | 21 | |
| 22 | 22 | // The first rule that matches wins: the most specific ones come first. |
| 23 | 23 | const rules: Rule[] = [ |
| 24 | + // sbx before `sbx login` (issue #97): ErrorText offers to sign in. | |
| 25 | + { pattern: /not signed in to Docker|not authenticated to Docker/i, key: 'error.sbxNotSignedIn' }, | |
| 24 | 26 | { pattern: /Cannot connect to the Docker daemon|docker daemon is not running|error during connect/i, key: 'error.dockerNotRunning' }, |
| 25 | 27 | { pattern: /No such container:\s*(\S+)/i, key: 'error.containerMissing', groups: ['box'] }, |
| 26 | 28 | // docker-agent serve acp without its agent file (cobra's message). |
| @@ -21,6 +21,8 @@ interface Rule { | |||
| 21 | 21 | ||
| 22 | // The first rule that matches wins: the most specific ones come first. | 22 | // The first rule that matches wins: the most specific ones come first. |
| 23 | const rules: Rule[] = [ | 23 | const rules: Rule[] = [ |
| 24 | + // sbx before `sbx login` (issue #97): ErrorText offers to sign in. | ||
| 25 | + { pattern: /not signed in to Docker|not authenticated to Docker/i, key: 'error.sbxNotSignedIn' }, | ||
| 24 | { pattern: /Cannot connect to the Docker daemon|docker daemon is not running|error during connect/i, key: 'error.dockerNotRunning' }, | 26 | { pattern: /Cannot connect to the Docker daemon|docker daemon is not running|error during connect/i, key: 'error.dockerNotRunning' }, |
| 25 | { pattern: /No such container:\s*(\S+)/i, key: 'error.containerMissing', groups: ['box'] }, | 27 | { pattern: /No such container:\s*(\S+)/i, key: 'error.containerMissing', groups: ['box'] }, |
| 26 | // docker-agent serve acp without its agent file (cobra's message). | 28 | // docker-agent serve acp without its agent file (cobra's message). |
modified
frontend/src/lib/i18n/messages.ts +20 -0 | @@ -158,6 +158,16 @@ export const en = { | ||
| 158 | 158 | // code blocks |
| 159 | 159 | 'error.dismiss': 'Close this message', |
| 160 | 160 | 'error.details': 'Technical details', |
| 161 | + 'error.sbxNotSignedIn': 'sbx needs you to be signed in to Docker (a free Docker account is enough).', | |
| 162 | + 'sbxLogin.start': 'Sign in to Docker', | |
| 163 | + 'sbxLogin.starting': 'Starting the sign-in…', | |
| 164 | + 'sbxLogin.code': 'Check that the page shows this code, then confirm:', | |
| 165 | + 'sbxLogin.codeLabel': 'Confirmation code', | |
| 166 | + 'sbxLogin.open': 'Open the sign-in page', | |
| 167 | + 'sbxLogin.waiting': 'Waiting for you to sign in…', | |
| 168 | + 'sbxLogin.signed': '✓ Signed in to Docker as {user}.', | |
| 169 | + 'sbxLogin.failed': 'The sign-in did not succeed. Try again, or type sbx login in a terminal.', | |
| 170 | + 'sbxLogin.cancelled': 'Sign-in cancelled.', | |
| 161 | 171 | 'error.programNotFound': 'The program "{program}" cannot be found. Install it, or give its full path in the agent\'s settings (for example /opt/homebrew/bin/{program}).', |
| 162 | 172 | 'error.programNotExecutable': '"{program}" cannot be run: it is not executable. In a terminal: chmod +x {program}', |
| 163 | 173 | 'error.dockerNotRunning': 'Docker is not running. Start Docker Desktop (or the Docker service), then try again.', |
| @@ -626,6 +636,16 @@ export const fr: Record<MessageKey, string> = { | ||
| 626 | 636 | |
| 627 | 637 | 'error.dismiss': 'Fermer ce message', |
| 628 | 638 | 'error.details': 'Détails techniques', |
| 639 | + 'error.sbxNotSignedIn': "sbx a besoin que vous soyez connecté à Docker (un compte Docker gratuit suffit).", | |
| 640 | + 'sbxLogin.start': 'Se connecter à Docker', | |
| 641 | + 'sbxLogin.starting': 'Démarrage de la connexion…', | |
| 642 | + 'sbxLogin.code': 'Vérifiez que la page affiche ce code, puis confirmez :', | |
| 643 | + 'sbxLogin.codeLabel': 'Code de confirmation', | |
| 644 | + 'sbxLogin.open': 'Ouvrir la page de connexion', | |
| 645 | + 'sbxLogin.waiting': 'En attente de votre connexion…', | |
| 646 | + 'sbxLogin.signed': '✓ Connecté à Docker en tant que {user}.', | |
| 647 | + 'sbxLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez sbx login dans un terminal.", | |
| 648 | + 'sbxLogin.cancelled': 'Connexion annulée.', | |
| 629 | 649 | 'error.programNotFound': "Le programme « {program} » est introuvable. Installez-le, ou indiquez son chemin complet dans les réglages de l'agent (par exemple /opt/homebrew/bin/{program}).", |
| 630 | 650 | 'error.programNotExecutable': "« {program} » ne peut pas être lancé : il n'est pas exécutable. Dans un terminal : chmod +x {program}", |
| 631 | 651 | 'error.dockerNotRunning': "Docker n'est pas démarré. Lancez Docker Desktop (ou le service Docker), puis réessayez.", |
| @@ -158,6 +158,16 @@ export const en = { | |||
| 158 | // code blocks | 158 | // code blocks |
| 159 | 'error.dismiss': 'Close this message', | 159 | 'error.dismiss': 'Close this message', |
| 160 | 'error.details': 'Technical details', | 160 | 'error.details': 'Technical details', |
| 161 | + 'error.sbxNotSignedIn': 'sbx needs you to be signed in to Docker (a free Docker account is enough).', | ||
| 162 | + 'sbxLogin.start': 'Sign in to Docker', | ||
| 163 | + 'sbxLogin.starting': 'Starting the sign-in…', | ||
| 164 | + 'sbxLogin.code': 'Check that the page shows this code, then confirm:', | ||
| 165 | + 'sbxLogin.codeLabel': 'Confirmation code', | ||
| 166 | + 'sbxLogin.open': 'Open the sign-in page', | ||
| 167 | + 'sbxLogin.waiting': 'Waiting for you to sign in…', | ||
| 168 | + 'sbxLogin.signed': '✓ Signed in to Docker as {user}.', | ||
| 169 | + 'sbxLogin.failed': 'The sign-in did not succeed. Try again, or type sbx login in a terminal.', | ||
| 170 | + 'sbxLogin.cancelled': 'Sign-in cancelled.', | ||
| 161 | 'error.programNotFound': 'The program "{program}" cannot be found. Install it, or give its full path in the agent\'s settings (for example /opt/homebrew/bin/{program}).', | 171 | 'error.programNotFound': 'The program "{program}" cannot be found. Install it, or give its full path in the agent\'s settings (for example /opt/homebrew/bin/{program}).', |
| 162 | 'error.programNotExecutable': '"{program}" cannot be run: it is not executable. In a terminal: chmod +x {program}', | 172 | 'error.programNotExecutable': '"{program}" cannot be run: it is not executable. In a terminal: chmod +x {program}', |
| 163 | 'error.dockerNotRunning': 'Docker is not running. Start Docker Desktop (or the Docker service), then try again.', | 173 | 'error.dockerNotRunning': 'Docker is not running. Start Docker Desktop (or the Docker service), then try again.', |
| @@ -626,6 +636,16 @@ export const fr: Record<MessageKey, string> = { | |||
| 626 | 636 | ||
| 627 | 'error.dismiss': 'Fermer ce message', | 637 | 'error.dismiss': 'Fermer ce message', |
| 628 | 'error.details': 'Détails techniques', | 638 | 'error.details': 'Détails techniques', |
| 639 | + 'error.sbxNotSignedIn': "sbx a besoin que vous soyez connecté à Docker (un compte Docker gratuit suffit).", | ||
| 640 | + 'sbxLogin.start': 'Se connecter à Docker', | ||
| 641 | + 'sbxLogin.starting': 'Démarrage de la connexion…', | ||
| 642 | + 'sbxLogin.code': 'Vérifiez que la page affiche ce code, puis confirmez :', | ||
| 643 | + 'sbxLogin.codeLabel': 'Code de confirmation', | ||
| 644 | + 'sbxLogin.open': 'Ouvrir la page de connexion', | ||
| 645 | + 'sbxLogin.waiting': 'En attente de votre connexion…', | ||
| 646 | + 'sbxLogin.signed': '✓ Connecté à Docker en tant que {user}.', | ||
| 647 | + 'sbxLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez sbx login dans un terminal.", | ||
| 648 | + 'sbxLogin.cancelled': 'Connexion annulée.', | ||
| 629 | 'error.programNotFound': "Le programme « {program} » est introuvable. Installez-le, ou indiquez son chemin complet dans les réglages de l'agent (par exemple /opt/homebrew/bin/{program}).", | 649 | 'error.programNotFound': "Le programme « {program} » est introuvable. Installez-le, ou indiquez son chemin complet dans les réglages de l'agent (par exemple /opt/homebrew/bin/{program}).", |
| 630 | 'error.programNotExecutable': "« {program} » ne peut pas être lancé : il n'est pas exécutable. Dans un terminal : chmod +x {program}", | 650 | 'error.programNotExecutable': "« {program} » ne peut pas être lancé : il n'est pas exécutable. Dans un terminal : chmod +x {program}", |
| 631 | 'error.dockerNotRunning': "Docker n'est pas démarré. Lancez Docker Desktop (ou le service Docker), puis réessayez.", | 651 | 'error.dockerNotRunning': "Docker n'est pas démarré. Lancez Docker Desktop (ou le service Docker), puis réessayez.", |
modified
internal/app/app.go +3 -0 | @@ -91,6 +91,8 @@ type Core struct { | ||
| 91 | 91 | stopWait context.CancelFunc |
| 92 | 92 | // creator is the mini-me creation assistant's wizard (issue #94). |
| 93 | 93 | creator *creation |
| 94 | + // signIn is the `sbx login` in progress (issue #97). | |
| 95 | + signIn signIn | |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | // New loads the configuration at location — creating the default file first |
| @@ -294,6 +296,7 @@ func (c *Core) Open(ctx context.Context, path string) error { | ||
| 294 | 296 | // closes the history. |
| 295 | 297 | func (c *Core) Shutdown(ctx context.Context) { |
| 296 | 298 | (&CreatorService{Core: c}).Cancel() |
| 299 | + (&SbxCreatorService{Core: c}).CancelLogin() | |
| 297 | 300 | c.closeChannels() |
| 298 | 301 | c.stopWorkspaces() |
| 299 | 302 | c.manager.StopAll(ctx) |
| @@ -91,6 +91,8 @@ type Core struct { | |||
| 91 | stopWait context.CancelFunc | 91 | stopWait context.CancelFunc |
| 92 | // creator is the mini-me creation assistant's wizard (issue #94). | 92 | // creator is the mini-me creation assistant's wizard (issue #94). |
| 93 | creator *creation | 93 | creator *creation |
| 94 | + // signIn is the `sbx login` in progress (issue #97). | ||
| 95 | + signIn signIn | ||
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | // New loads the configuration at location — creating the default file first | 98 | // New loads the configuration at location — creating the default file first |
| @@ -294,6 +296,7 @@ func (c *Core) Open(ctx context.Context, path string) error { | |||
| 294 | // closes the history. | 296 | // closes the history. |
| 295 | func (c *Core) Shutdown(ctx context.Context) { | 297 | func (c *Core) Shutdown(ctx context.Context) { |
| 296 | (&CreatorService{Core: c}).Cancel() | 298 | (&CreatorService{Core: c}).Cancel() |
| 299 | + (&SbxCreatorService{Core: c}).CancelLogin() | ||
| 297 | c.closeChannels() | 300 | c.closeChannels() |
| 298 | c.stopWorkspaces() | 301 | c.stopWorkspaces() |
| 299 | c.manager.StopAll(ctx) | 302 | c.manager.StopAll(ctx) |
modified
internal/app/sbxcreator.go +60 -0 | @@ -9,6 +9,8 @@ import ( | ||
| 9 | 9 | "os" |
| 10 | 10 | "path/filepath" |
| 11 | 11 | "slices" |
| 12 | + "sync" | |
| 13 | + "time" | |
| 12 | 14 | |
| 13 | 15 | "git.rickub.com/bots-garden/sidekicks/internal/lifecycle" |
| 14 | 16 | "git.rickub.com/bots-garden/sidekicks/internal/sbxcreate" |
| @@ -175,3 +177,61 @@ func (s *SbxCreatorService) Create(ctx context.Context, form SbxCreateForm) (Cre | ||
| 175 | 177 | } |
| 176 | 178 | return CreatorResult{Problems: []string{}, Name: form.Name, Folder: dir}, nil |
| 177 | 179 | } |
| 180 | + | |
| 181 | +// signIn holds the `sbx login` in progress (issue #97). | |
| 182 | +type signIn struct { | |
| 183 | + mu sync.Mutex | |
| 184 | + login *sbxcreate.Login | |
| 185 | +} | |
| 186 | + | |
| 187 | +// loginWait bounds one call of Login or LoginStatus: the interface calls | |
| 188 | +// LoginStatus again while the user has not confirmed. | |
| 189 | +const loginWait = 20 * time.Second | |
| 190 | + | |
| 191 | +// Login starts `sbx login` — or joins the one in progress — and returns once | |
| 192 | +// sbx printed the code and the URL the user confirms in a browser (or ended). | |
| 193 | +func (s *SbxCreatorService) Login(ctx context.Context) (sbxcreate.LoginState, error) { | |
| 194 | + in := &s.Core.signIn | |
| 195 | + in.mu.Lock() | |
| 196 | + login := in.login | |
| 197 | + if login == nil || login.State().Done { | |
| 198 | + started, err := s.Core.sbx().StartLogin() | |
| 199 | + if err != nil { | |
| 200 | + in.mu.Unlock() | |
| 201 | + return sbxcreate.LoginState{}, err | |
| 202 | + } | |
| 203 | + in.login, login = started, started | |
| 204 | + } | |
| 205 | + in.mu.Unlock() | |
| 206 | + ctx, cancel := context.WithTimeout(ctx, loginWait) | |
| 207 | + defer cancel() | |
| 208 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { | |
| 209 | + return state.Done || (state.URL != "" && state.Code != "") | |
| 210 | + }), nil | |
| 211 | +} | |
| 212 | + | |
| 213 | +// LoginStatus waits — 20 seconds at most — for the sign-in to end, and | |
| 214 | +// returns where it is. | |
| 215 | +func (s *SbxCreatorService) LoginStatus(ctx context.Context) (sbxcreate.LoginState, error) { | |
| 216 | + in := &s.Core.signIn | |
| 217 | + in.mu.Lock() | |
| 218 | + login := in.login | |
| 219 | + in.mu.Unlock() | |
| 220 | + if login == nil { | |
| 221 | + return sbxcreate.LoginState{}, errors.New("no sign-in in progress") | |
| 222 | + } | |
| 223 | + ctx, cancel := context.WithTimeout(ctx, loginWait) | |
| 224 | + defer cancel() | |
| 225 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { return state.Done }), nil | |
| 226 | +} | |
| 227 | + | |
| 228 | +// CancelLogin stops the sign-in in progress, if any. Also done when | |
| 229 | +// Sidekicks quits. | |
| 230 | +func (s *SbxCreatorService) CancelLogin() { | |
| 231 | + in := &s.Core.signIn | |
| 232 | + in.mu.Lock() | |
| 233 | + defer in.mu.Unlock() | |
| 234 | + if in.login != nil { | |
| 235 | + in.login.Cancel() | |
| 236 | + } | |
| 237 | +} | |
| @@ -9,6 +9,8 @@ import ( | |||
| 9 | "os" | 9 | "os" |
| 10 | "path/filepath" | 10 | "path/filepath" |
| 11 | "slices" | 11 | "slices" |
| 12 | + "sync" | ||
| 13 | + "time" | ||
| 12 | 14 | ||
| 13 | "git.rickub.com/bots-garden/sidekicks/internal/lifecycle" | 15 | "git.rickub.com/bots-garden/sidekicks/internal/lifecycle" |
| 14 | "git.rickub.com/bots-garden/sidekicks/internal/sbxcreate" | 16 | "git.rickub.com/bots-garden/sidekicks/internal/sbxcreate" |
| @@ -175,3 +177,61 @@ func (s *SbxCreatorService) Create(ctx context.Context, form SbxCreateForm) (Cre | |||
| 175 | } | 177 | } |
| 176 | return CreatorResult{Problems: []string{}, Name: form.Name, Folder: dir}, nil | 178 | return CreatorResult{Problems: []string{}, Name: form.Name, Folder: dir}, nil |
| 177 | } | 179 | } |
| 180 | + | ||
| 181 | +// signIn holds the `sbx login` in progress (issue #97). | ||
| 182 | +type signIn struct { | ||
| 183 | + mu sync.Mutex | ||
| 184 | + login *sbxcreate.Login | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +// loginWait bounds one call of Login or LoginStatus: the interface calls | ||
| 188 | +// LoginStatus again while the user has not confirmed. | ||
| 189 | +const loginWait = 20 * time.Second | ||
| 190 | + | ||
| 191 | +// Login starts `sbx login` — or joins the one in progress — and returns once | ||
| 192 | +// sbx printed the code and the URL the user confirms in a browser (or ended). | ||
| 193 | +func (s *SbxCreatorService) Login(ctx context.Context) (sbxcreate.LoginState, error) { | ||
| 194 | + in := &s.Core.signIn | ||
| 195 | + in.mu.Lock() | ||
| 196 | + login := in.login | ||
| 197 | + if login == nil || login.State().Done { | ||
| 198 | + started, err := s.Core.sbx().StartLogin() | ||
| 199 | + if err != nil { | ||
| 200 | + in.mu.Unlock() | ||
| 201 | + return sbxcreate.LoginState{}, err | ||
| 202 | + } | ||
| 203 | + in.login, login = started, started | ||
| 204 | + } | ||
| 205 | + in.mu.Unlock() | ||
| 206 | + ctx, cancel := context.WithTimeout(ctx, loginWait) | ||
| 207 | + defer cancel() | ||
| 208 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { | ||
| 209 | + return state.Done || (state.URL != "" && state.Code != "") | ||
| 210 | + }), nil | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +// LoginStatus waits — 20 seconds at most — for the sign-in to end, and | ||
| 214 | +// returns where it is. | ||
| 215 | +func (s *SbxCreatorService) LoginStatus(ctx context.Context) (sbxcreate.LoginState, error) { | ||
| 216 | + in := &s.Core.signIn | ||
| 217 | + in.mu.Lock() | ||
| 218 | + login := in.login | ||
| 219 | + in.mu.Unlock() | ||
| 220 | + if login == nil { | ||
| 221 | + return sbxcreate.LoginState{}, errors.New("no sign-in in progress") | ||
| 222 | + } | ||
| 223 | + ctx, cancel := context.WithTimeout(ctx, loginWait) | ||
| 224 | + defer cancel() | ||
| 225 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { return state.Done }), nil | ||
| 226 | +} | ||
| 227 | + | ||
| 228 | +// CancelLogin stops the sign-in in progress, if any. Also done when | ||
| 229 | +// Sidekicks quits. | ||
| 230 | +func (s *SbxCreatorService) CancelLogin() { | ||
| 231 | + in := &s.Core.signIn | ||
| 232 | + in.mu.Lock() | ||
| 233 | + defer in.mu.Unlock() | ||
| 234 | + if in.login != nil { | ||
| 235 | + in.login.Cancel() | ||
| 236 | + } | ||
| 237 | +} | ||
modified
internal/app/sbxcreator_test.go +27 -0 | @@ -140,3 +140,30 @@ func TestWithoutSbxTheAssistantSaysSo(t *testing.T) { | ||
| 140 | 140 | t.Fatalf("Check: %v", err) |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | + | |
| 144 | +// TestLoginRunsSbxLoginAndReportsWhoSignedIn: issue #97. | |
| 145 | +func TestLoginRunsSbxLoginAndReportsWhoSignedIn(t *testing.T) { | |
| 146 | + dir := t.TempDir() | |
| 147 | + script := "#!/bin/sh\n[ \"$1\" = login ] || exit 1\necho 'Your one-time device confirmation code is: ABCD-1234'\n" + | |
| 148 | + "echo 'Open this URL to sign in: https://login.docker.com/activate?user_code=ABCD-1234'\nsleep 0.3\necho 'Signed in as citizen.'\n" | |
| 149 | + write(t, filepath.Join(dir, "sbx"), script) | |
| 150 | + if err := os.Chmod(filepath.Join(dir, "sbx"), 0o755); err != nil { | |
| 151 | + t.Fatal(err) | |
| 152 | + } | |
| 153 | + path := filepath.Join(dir, "config.yaml") | |
| 154 | + write(t, path, "version: 1\nagents: []\n") | |
| 155 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: starter, Sbx: filepath.Join(dir, "sbx")}) | |
| 156 | + defer core.Shutdown(context.Background()) | |
| 157 | + service := &app.SbxCreatorService{Core: core} | |
| 158 | + if _, err := service.LoginStatus(context.Background()); err == nil { | |
| 159 | + t.Fatal("no sign-in yet") | |
| 160 | + } | |
| 161 | + started, err := service.Login(context.Background()) | |
| 162 | + if err != nil || started.Code != "ABCD-1234" || !strings.HasPrefix(started.URL, "https://login.docker.com/activate") { | |
| 163 | + t.Fatalf("login: %+v %v", started, err) | |
| 164 | + } | |
| 165 | + done, err := service.LoginStatus(context.Background()) | |
| 166 | + if err != nil || !done.Done || done.User != "citizen" || done.Error != "" { | |
| 167 | + t.Fatalf("status: %+v %v", done, err) | |
| 168 | + } | |
| 169 | +} | |
| @@ -140,3 +140,30 @@ func TestWithoutSbxTheAssistantSaysSo(t *testing.T) { | |||
| 140 | t.Fatalf("Check: %v", err) | 140 | t.Fatalf("Check: %v", err) |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | + | ||
| 144 | +// TestLoginRunsSbxLoginAndReportsWhoSignedIn: issue #97. | ||
| 145 | +func TestLoginRunsSbxLoginAndReportsWhoSignedIn(t *testing.T) { | ||
| 146 | + dir := t.TempDir() | ||
| 147 | + script := "#!/bin/sh\n[ \"$1\" = login ] || exit 1\necho 'Your one-time device confirmation code is: ABCD-1234'\n" + | ||
| 148 | + "echo 'Open this URL to sign in: https://login.docker.com/activate?user_code=ABCD-1234'\nsleep 0.3\necho 'Signed in as citizen.'\n" | ||
| 149 | + write(t, filepath.Join(dir, "sbx"), script) | ||
| 150 | + if err := os.Chmod(filepath.Join(dir, "sbx"), 0o755); err != nil { | ||
| 151 | + t.Fatal(err) | ||
| 152 | + } | ||
| 153 | + path := filepath.Join(dir, "config.yaml") | ||
| 154 | + write(t, path, "version: 1\nagents: []\n") | ||
| 155 | + core := app.New(config.Location{Path: path, Source: config.SourceFlag}, app.Options{Starter: starter, Sbx: filepath.Join(dir, "sbx")}) | ||
| 156 | + defer core.Shutdown(context.Background()) | ||
| 157 | + service := &app.SbxCreatorService{Core: core} | ||
| 158 | + if _, err := service.LoginStatus(context.Background()); err == nil { | ||
| 159 | + t.Fatal("no sign-in yet") | ||
| 160 | + } | ||
| 161 | + started, err := service.Login(context.Background()) | ||
| 162 | + if err != nil || started.Code != "ABCD-1234" || !strings.HasPrefix(started.URL, "https://login.docker.com/activate") { | ||
| 163 | + t.Fatalf("login: %+v %v", started, err) | ||
| 164 | + } | ||
| 165 | + done, err := service.LoginStatus(context.Background()) | ||
| 166 | + if err != nil || !done.Done || done.User != "citizen" || done.Error != "" { | ||
| 167 | + t.Fatalf("status: %+v %v", done, err) | ||
| 168 | + } | ||
| 169 | +} | ||
added
internal/sbxcreate/login.go +168 -0 | new file mode 100644 | ||
| @@ -0,0 +1,168 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package sbxcreate | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "bufio" | |
| 7 | + "context" | |
| 8 | + "io" | |
| 9 | + "os/exec" | |
| 10 | + "regexp" | |
| 11 | + "strings" | |
| 12 | + "sync" | |
| 13 | +) | |
| 14 | + | |
| 15 | +// Signing in to Docker (issue #97): sbx refuses to work until its user is | |
| 16 | +// signed in ("error: not signed in to Docker"). `sbx login` is a device-code | |
| 17 | +// flow that asks nothing on the keyboard: it prints a code and a URL, waits | |
| 18 | +// for the user to confirm in a browser, then prints "Signed in as <user>.". | |
| 19 | +// Sidekicks runs it, reads those lines and shows them. | |
| 20 | + | |
| 21 | +// NotSignedIn reports whether an error of sbx says that its user is not | |
| 22 | +// signed in to Docker. | |
| 23 | +func NotSignedIn(text string) bool { | |
| 24 | + lower := strings.ToLower(text) | |
| 25 | + return strings.Contains(lower, "not signed in to docker") || strings.Contains(lower, "not authenticated to docker") | |
| 26 | +} | |
| 27 | + | |
| 28 | +// LoginState is what the interface shows of a sign-in in progress. | |
| 29 | +type LoginState struct { | |
| 30 | + // Code and URL are what the user confirms in a browser; "" until sbx | |
| 31 | + // printed them. | |
| 32 | + Code string `json:"code"` | |
| 33 | + URL string `json:"url"` | |
| 34 | + // Done: sbx login ended. User is who is signed in ("" when it failed). | |
| 35 | + Done bool `json:"done"` | |
| 36 | + User string `json:"user"` | |
| 37 | + Error string `json:"error"` | |
| 38 | + // Output is what sbx printed, for when its lines are not the expected ones. | |
| 39 | + Output []string `json:"output"` | |
| 40 | +} | |
| 41 | + | |
| 42 | +var ( | |
| 43 | + codePattern = regexp.MustCompile(`\b([A-Z0-9]{4}-[A-Z0-9]{4})\b`) | |
| 44 | + urlPattern = regexp.MustCompile(`https://\S+`) | |
| 45 | + userPattern = regexp.MustCompile(`(?i)signed in as (\S+?)\.?\s*$`) | |
| 46 | +) | |
| 47 | + | |
| 48 | +// Login is a `sbx login` in progress. | |
| 49 | +type Login struct { | |
| 50 | + cancel context.CancelFunc | |
| 51 | + | |
| 52 | + mu sync.Mutex | |
| 53 | + state LoginState | |
| 54 | + changed chan struct{} // closed, then replaced, at each change | |
| 55 | +} | |
| 56 | + | |
| 57 | +// StartLogin runs `sbx login`. Its standard input is empty: a question sbx | |
| 58 | +// would ask on the keyboard gets no answer, and is shown in Output. | |
| 59 | +func (s Sbx) StartLogin() (*Login, error) { | |
| 60 | + program, err := s.program() | |
| 61 | + if err != nil { | |
| 62 | + return nil, err | |
| 63 | + } | |
| 64 | + ctx, cancel := context.WithCancel(context.Background()) | |
| 65 | + command := exec.CommandContext(ctx, program, "login") | |
| 66 | + command.Stdin = strings.NewReader("") | |
| 67 | + reader, writer := io.Pipe() | |
| 68 | + command.Stdout, command.Stderr = writer, writer | |
| 69 | + l := &Login{cancel: cancel, changed: make(chan struct{}), state: LoginState{Output: []string{}}} | |
| 70 | + if err := command.Start(); err != nil { | |
| 71 | + cancel() | |
| 72 | + return nil, err | |
| 73 | + } | |
| 74 | + read := make(chan struct{}) | |
| 75 | + go func() { | |
| 76 | + defer close(read) | |
| 77 | + scanner := bufio.NewScanner(reader) | |
| 78 | + for scanner.Scan() { | |
| 79 | + l.line(strings.TrimRight(scanner.Text(), "\r")) | |
| 80 | + } | |
| 81 | + _, _ = io.Copy(io.Discard, reader) | |
| 82 | + }() | |
| 83 | + go func() { | |
| 84 | + err := command.Wait() | |
| 85 | + _ = writer.Close() | |
| 86 | + <-read | |
| 87 | + l.finish(err, ctx.Err() != nil) | |
| 88 | + cancel() | |
| 89 | + }() | |
| 90 | + return l, nil | |
| 91 | +} | |
| 92 | + | |
| 93 | +func (l *Login) update(change func(*LoginState)) { | |
| 94 | + l.mu.Lock() | |
| 95 | + change(&l.state) | |
| 96 | + close(l.changed) | |
| 97 | + l.changed = make(chan struct{}) | |
| 98 | + l.mu.Unlock() | |
| 99 | +} | |
| 100 | + | |
| 101 | +// line reads one line of sbx login: the code, the URL, who signed in. | |
| 102 | +func (l *Login) line(text string) { | |
| 103 | + if strings.TrimSpace(text) == "" { | |
| 104 | + return | |
| 105 | + } | |
| 106 | + l.update(func(state *LoginState) { | |
| 107 | + state.Output = append(state.Output, text) | |
| 108 | + if url := urlPattern.FindString(text); url != "" && state.URL == "" && strings.Contains(url, "login") { | |
| 109 | + state.URL = strings.TrimRight(url, ".,;)") | |
| 110 | + if code := codePattern.FindStringSubmatch(url); code != nil && state.Code == "" { | |
| 111 | + state.Code = code[1] | |
| 112 | + } | |
| 113 | + } | |
| 114 | + if code := codePattern.FindStringSubmatch(text); code != nil && state.Code == "" && !strings.Contains(text, "https://") { | |
| 115 | + state.Code = code[1] | |
| 116 | + } | |
| 117 | + if user := userPattern.FindStringSubmatch(text); user != nil { | |
| 118 | + state.User = user[1] | |
| 119 | + } | |
| 120 | + }) | |
| 121 | +} | |
| 122 | + | |
| 123 | +// finish marks the end of sbx login. Signed in counts as success even when | |
| 124 | +// sbx then stopped on a question nobody answered. | |
| 125 | +func (l *Login) finish(err error, cancelled bool) { | |
| 126 | + l.update(func(state *LoginState) { | |
| 127 | + state.Done = true | |
| 128 | + switch { | |
| 129 | + case state.User != "": | |
| 130 | + case cancelled: | |
| 131 | + state.Error = "cancelled" | |
| 132 | + case err != nil: | |
| 133 | + state.Error = err.Error() | |
| 134 | + default: | |
| 135 | + state.Error = "sbx login ended without signing in" | |
| 136 | + } | |
| 137 | + }) | |
| 138 | +} | |
| 139 | + | |
| 140 | +// State is the sign-in now. | |
| 141 | +func (l *Login) State() LoginState { | |
| 142 | + l.mu.Lock() | |
| 143 | + defer l.mu.Unlock() | |
| 144 | + state := l.state | |
| 145 | + state.Output = append([]string{}, l.state.Output...) | |
| 146 | + return state | |
| 147 | +} | |
| 148 | + | |
| 149 | +// Wait returns once until is true of the state, or ctx is done; it returns | |
| 150 | +// the state then. | |
| 151 | +func (l *Login) Wait(ctx context.Context, until func(LoginState) bool) LoginState { | |
| 152 | + for { | |
| 153 | + l.mu.Lock() | |
| 154 | + state, changed := l.state, l.changed | |
| 155 | + l.mu.Unlock() | |
| 156 | + if until(state) { | |
| 157 | + return l.State() | |
| 158 | + } | |
| 159 | + select { | |
| 160 | + case <-changed: | |
| 161 | + case <-ctx.Done(): | |
| 162 | + return l.State() | |
| 163 | + } | |
| 164 | + } | |
| 165 | +} | |
| 166 | + | |
| 167 | +// Cancel stops sbx login. | |
| 168 | +func (l *Login) Cancel() { l.cancel() } | |
| new file mode 100644 | |||
| @@ -0,0 +1,168 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package sbxcreate | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "bufio" | ||
| 7 | + "context" | ||
| 8 | + "io" | ||
| 9 | + "os/exec" | ||
| 10 | + "regexp" | ||
| 11 | + "strings" | ||
| 12 | + "sync" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +// Signing in to Docker (issue #97): sbx refuses to work until its user is | ||
| 16 | +// signed in ("error: not signed in to Docker"). `sbx login` is a device-code | ||
| 17 | +// flow that asks nothing on the keyboard: it prints a code and a URL, waits | ||
| 18 | +// for the user to confirm in a browser, then prints "Signed in as <user>.". | ||
| 19 | +// Sidekicks runs it, reads those lines and shows them. | ||
| 20 | + | ||
| 21 | +// NotSignedIn reports whether an error of sbx says that its user is not | ||
| 22 | +// signed in to Docker. | ||
| 23 | +func NotSignedIn(text string) bool { | ||
| 24 | + lower := strings.ToLower(text) | ||
| 25 | + return strings.Contains(lower, "not signed in to docker") || strings.Contains(lower, "not authenticated to docker") | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +// LoginState is what the interface shows of a sign-in in progress. | ||
| 29 | +type LoginState struct { | ||
| 30 | + // Code and URL are what the user confirms in a browser; "" until sbx | ||
| 31 | + // printed them. | ||
| 32 | + Code string `json:"code"` | ||
| 33 | + URL string `json:"url"` | ||
| 34 | + // Done: sbx login ended. User is who is signed in ("" when it failed). | ||
| 35 | + Done bool `json:"done"` | ||
| 36 | + User string `json:"user"` | ||
| 37 | + Error string `json:"error"` | ||
| 38 | + // Output is what sbx printed, for when its lines are not the expected ones. | ||
| 39 | + Output []string `json:"output"` | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +var ( | ||
| 43 | + codePattern = regexp.MustCompile(`\b([A-Z0-9]{4}-[A-Z0-9]{4})\b`) | ||
| 44 | + urlPattern = regexp.MustCompile(`https://\S+`) | ||
| 45 | + userPattern = regexp.MustCompile(`(?i)signed in as (\S+?)\.?\s*$`) | ||
| 46 | +) | ||
| 47 | + | ||
| 48 | +// Login is a `sbx login` in progress. | ||
| 49 | +type Login struct { | ||
| 50 | + cancel context.CancelFunc | ||
| 51 | + | ||
| 52 | + mu sync.Mutex | ||
| 53 | + state LoginState | ||
| 54 | + changed chan struct{} // closed, then replaced, at each change | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +// StartLogin runs `sbx login`. Its standard input is empty: a question sbx | ||
| 58 | +// would ask on the keyboard gets no answer, and is shown in Output. | ||
| 59 | +func (s Sbx) StartLogin() (*Login, error) { | ||
| 60 | + program, err := s.program() | ||
| 61 | + if err != nil { | ||
| 62 | + return nil, err | ||
| 63 | + } | ||
| 64 | + ctx, cancel := context.WithCancel(context.Background()) | ||
| 65 | + command := exec.CommandContext(ctx, program, "login") | ||
| 66 | + command.Stdin = strings.NewReader("") | ||
| 67 | + reader, writer := io.Pipe() | ||
| 68 | + command.Stdout, command.Stderr = writer, writer | ||
| 69 | + l := &Login{cancel: cancel, changed: make(chan struct{}), state: LoginState{Output: []string{}}} | ||
| 70 | + if err := command.Start(); err != nil { | ||
| 71 | + cancel() | ||
| 72 | + return nil, err | ||
| 73 | + } | ||
| 74 | + read := make(chan struct{}) | ||
| 75 | + go func() { | ||
| 76 | + defer close(read) | ||
| 77 | + scanner := bufio.NewScanner(reader) | ||
| 78 | + for scanner.Scan() { | ||
| 79 | + l.line(strings.TrimRight(scanner.Text(), "\r")) | ||
| 80 | + } | ||
| 81 | + _, _ = io.Copy(io.Discard, reader) | ||
| 82 | + }() | ||
| 83 | + go func() { | ||
| 84 | + err := command.Wait() | ||
| 85 | + _ = writer.Close() | ||
| 86 | + <-read | ||
| 87 | + l.finish(err, ctx.Err() != nil) | ||
| 88 | + cancel() | ||
| 89 | + }() | ||
| 90 | + return l, nil | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +func (l *Login) update(change func(*LoginState)) { | ||
| 94 | + l.mu.Lock() | ||
| 95 | + change(&l.state) | ||
| 96 | + close(l.changed) | ||
| 97 | + l.changed = make(chan struct{}) | ||
| 98 | + l.mu.Unlock() | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +// line reads one line of sbx login: the code, the URL, who signed in. | ||
| 102 | +func (l *Login) line(text string) { | ||
| 103 | + if strings.TrimSpace(text) == "" { | ||
| 104 | + return | ||
| 105 | + } | ||
| 106 | + l.update(func(state *LoginState) { | ||
| 107 | + state.Output = append(state.Output, text) | ||
| 108 | + if url := urlPattern.FindString(text); url != "" && state.URL == "" && strings.Contains(url, "login") { | ||
| 109 | + state.URL = strings.TrimRight(url, ".,;)") | ||
| 110 | + if code := codePattern.FindStringSubmatch(url); code != nil && state.Code == "" { | ||
| 111 | + state.Code = code[1] | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + if code := codePattern.FindStringSubmatch(text); code != nil && state.Code == "" && !strings.Contains(text, "https://") { | ||
| 115 | + state.Code = code[1] | ||
| 116 | + } | ||
| 117 | + if user := userPattern.FindStringSubmatch(text); user != nil { | ||
| 118 | + state.User = user[1] | ||
| 119 | + } | ||
| 120 | + }) | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +// finish marks the end of sbx login. Signed in counts as success even when | ||
| 124 | +// sbx then stopped on a question nobody answered. | ||
| 125 | +func (l *Login) finish(err error, cancelled bool) { | ||
| 126 | + l.update(func(state *LoginState) { | ||
| 127 | + state.Done = true | ||
| 128 | + switch { | ||
| 129 | + case state.User != "": | ||
| 130 | + case cancelled: | ||
| 131 | + state.Error = "cancelled" | ||
| 132 | + case err != nil: | ||
| 133 | + state.Error = err.Error() | ||
| 134 | + default: | ||
| 135 | + state.Error = "sbx login ended without signing in" | ||
| 136 | + } | ||
| 137 | + }) | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +// State is the sign-in now. | ||
| 141 | +func (l *Login) State() LoginState { | ||
| 142 | + l.mu.Lock() | ||
| 143 | + defer l.mu.Unlock() | ||
| 144 | + state := l.state | ||
| 145 | + state.Output = append([]string{}, l.state.Output...) | ||
| 146 | + return state | ||
| 147 | +} | ||
| 148 | + | ||
| 149 | +// Wait returns once until is true of the state, or ctx is done; it returns | ||
| 150 | +// the state then. | ||
| 151 | +func (l *Login) Wait(ctx context.Context, until func(LoginState) bool) LoginState { | ||
| 152 | + for { | ||
| 153 | + l.mu.Lock() | ||
| 154 | + state, changed := l.state, l.changed | ||
| 155 | + l.mu.Unlock() | ||
| 156 | + if until(state) { | ||
| 157 | + return l.State() | ||
| 158 | + } | ||
| 159 | + select { | ||
| 160 | + case <-changed: | ||
| 161 | + case <-ctx.Done(): | ||
| 162 | + return l.State() | ||
| 163 | + } | ||
| 164 | + } | ||
| 165 | +} | ||
| 166 | + | ||
| 167 | +// Cancel stops sbx login. | ||
| 168 | +func (l *Login) Cancel() { l.cancel() } | ||
added
internal/sbxcreate/login_test.go +107 -0 | new file mode 100644 | ||
| @@ -0,0 +1,107 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package sbxcreate_test | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "context" | |
| 7 | + "os" | |
| 8 | + "path/filepath" | |
| 9 | + "strings" | |
| 10 | + "testing" | |
| 11 | + "time" | |
| 12 | + | |
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/sbxcreate" | |
| 14 | +) | |
| 15 | + | |
| 16 | +// loginScript is `sbx login` in short: the lines of its device-code flow, | |
| 17 | +// then it waits for the file confirmed (the user confirming in a browser); | |
| 18 | +// with the file refuse it stops with an error instead. | |
| 19 | +const loginScript = `#!/bin/sh | |
| 20 | +here=$(dirname "$0") | |
| 21 | +[ "$1" = login ] || exit 1 | |
| 22 | +echo "You are not authenticated to Docker. Starting the sign-in flow..." | |
| 23 | +echo "Your one-time device confirmation code is: FXDG-FKTF" | |
| 24 | +echo "Open this URL to sign in: https://login.docker.com/activate?user_code=FXDG-FKTF" | |
| 25 | +echo "Waiting for authentication..." | |
| 26 | +if [ -f "$here/refuse" ]; then echo "error: the code expired" >&2; exit 1; fi | |
| 27 | +while [ ! -f "$here/confirmed" ]; do sleep 0.05; done | |
| 28 | +echo "Signed in as k33g." | |
| 29 | +` | |
| 30 | + | |
| 31 | +func loginSbx(t *testing.T) (sbxcreate.Sbx, string) { | |
| 32 | + t.Helper() | |
| 33 | + dir := t.TempDir() | |
| 34 | + if err := os.WriteFile(filepath.Join(dir, "sbx"), []byte(loginScript), 0o755); err != nil { | |
| 35 | + t.Fatal(err) | |
| 36 | + } | |
| 37 | + return sbxcreate.Sbx{Command: filepath.Join(dir, "sbx")}, dir | |
| 38 | +} | |
| 39 | + | |
| 40 | +func waitLogin(t *testing.T, login *sbxcreate.Login, until func(sbxcreate.LoginState) bool) sbxcreate.LoginState { | |
| 41 | + t.Helper() | |
| 42 | + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | |
| 43 | + defer cancel() | |
| 44 | + state := login.Wait(ctx, until) | |
| 45 | + if !until(state) { | |
| 46 | + t.Fatalf("timed out: %+v", state) | |
| 47 | + } | |
| 48 | + return state | |
| 49 | +} | |
| 50 | + | |
| 51 | +func TestLoginShowsTheCodeAndTheURLThenWhoSignedIn(t *testing.T) { | |
| 52 | + sbx, dir := loginSbx(t) | |
| 53 | + login, err := sbx.StartLogin() | |
| 54 | + if err != nil { | |
| 55 | + t.Fatal(err) | |
| 56 | + } | |
| 57 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.URL != "" && s.Code != "" }) | |
| 58 | + if state.Code != "FXDG-FKTF" || state.URL != "https://login.docker.com/activate?user_code=FXDG-FKTF" || state.Done { | |
| 59 | + t.Fatalf("waiting: %+v", state) | |
| 60 | + } | |
| 61 | + if err := os.WriteFile(filepath.Join(dir, "confirmed"), nil, 0o644); err != nil { | |
| 62 | + t.Fatal(err) | |
| 63 | + } | |
| 64 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | |
| 65 | + if state.User != "k33g" || state.Error != "" || len(state.Output) != 5 { | |
| 66 | + t.Fatalf("done: %+v", state) | |
| 67 | + } | |
| 68 | +} | |
| 69 | + | |
| 70 | +func TestAFailedOrCancelledLoginSaysSo(t *testing.T) { | |
| 71 | + sbx, dir := loginSbx(t) | |
| 72 | + if err := os.WriteFile(filepath.Join(dir, "refuse"), nil, 0o644); err != nil { | |
| 73 | + t.Fatal(err) | |
| 74 | + } | |
| 75 | + login, err := sbx.StartLogin() | |
| 76 | + if err != nil { | |
| 77 | + t.Fatal(err) | |
| 78 | + } | |
| 79 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | |
| 80 | + if state.User != "" || state.Error == "" || !strings.Contains(strings.Join(state.Output, "\n"), "the code expired") { | |
| 81 | + t.Fatalf("failed: %+v", state) | |
| 82 | + } | |
| 83 | + | |
| 84 | + _ = os.Remove(filepath.Join(dir, "refuse")) | |
| 85 | + login, err = sbx.StartLogin() | |
| 86 | + if err != nil { | |
| 87 | + t.Fatal(err) | |
| 88 | + } | |
| 89 | + waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Code != "" }) | |
| 90 | + login.Cancel() | |
| 91 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | |
| 92 | + if state.Error != "cancelled" || state.User != "" { | |
| 93 | + t.Fatalf("cancelled: %+v", state) | |
| 94 | + } | |
| 95 | +} | |
| 96 | + | |
| 97 | +func TestNotSignedIn(t *testing.T) { | |
| 98 | + for text, want := range map[string]bool{ | |
| 99 | + "sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart": true, | |
| 100 | + "You are not authenticated to Docker. Starting the sign-in flow...": true, | |
| 101 | + "sbx ls: exit status 1: daemon not running": false, | |
| 102 | + } { | |
| 103 | + if got := sbxcreate.NotSignedIn(text); got != want { | |
| 104 | + t.Errorf("%q: %v", text, got) | |
| 105 | + } | |
| 106 | + } | |
| 107 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package sbxcreate_test | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "context" | ||
| 7 | + "os" | ||
| 8 | + "path/filepath" | ||
| 9 | + "strings" | ||
| 10 | + "testing" | ||
| 11 | + "time" | ||
| 12 | + | ||
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/sbxcreate" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +// loginScript is `sbx login` in short: the lines of its device-code flow, | ||
| 17 | +// then it waits for the file confirmed (the user confirming in a browser); | ||
| 18 | +// with the file refuse it stops with an error instead. | ||
| 19 | +const loginScript = `#!/bin/sh | ||
| 20 | +here=$(dirname "$0") | ||
| 21 | +[ "$1" = login ] || exit 1 | ||
| 22 | +echo "You are not authenticated to Docker. Starting the sign-in flow..." | ||
| 23 | +echo "Your one-time device confirmation code is: FXDG-FKTF" | ||
| 24 | +echo "Open this URL to sign in: https://login.docker.com/activate?user_code=FXDG-FKTF" | ||
| 25 | +echo "Waiting for authentication..." | ||
| 26 | +if [ -f "$here/refuse" ]; then echo "error: the code expired" >&2; exit 1; fi | ||
| 27 | +while [ ! -f "$here/confirmed" ]; do sleep 0.05; done | ||
| 28 | +echo "Signed in as k33g." | ||
| 29 | +` | ||
| 30 | + | ||
| 31 | +func loginSbx(t *testing.T) (sbxcreate.Sbx, string) { | ||
| 32 | + t.Helper() | ||
| 33 | + dir := t.TempDir() | ||
| 34 | + if err := os.WriteFile(filepath.Join(dir, "sbx"), []byte(loginScript), 0o755); err != nil { | ||
| 35 | + t.Fatal(err) | ||
| 36 | + } | ||
| 37 | + return sbxcreate.Sbx{Command: filepath.Join(dir, "sbx")}, dir | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +func waitLogin(t *testing.T, login *sbxcreate.Login, until func(sbxcreate.LoginState) bool) sbxcreate.LoginState { | ||
| 41 | + t.Helper() | ||
| 42 | + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
| 43 | + defer cancel() | ||
| 44 | + state := login.Wait(ctx, until) | ||
| 45 | + if !until(state) { | ||
| 46 | + t.Fatalf("timed out: %+v", state) | ||
| 47 | + } | ||
| 48 | + return state | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +func TestLoginShowsTheCodeAndTheURLThenWhoSignedIn(t *testing.T) { | ||
| 52 | + sbx, dir := loginSbx(t) | ||
| 53 | + login, err := sbx.StartLogin() | ||
| 54 | + if err != nil { | ||
| 55 | + t.Fatal(err) | ||
| 56 | + } | ||
| 57 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.URL != "" && s.Code != "" }) | ||
| 58 | + if state.Code != "FXDG-FKTF" || state.URL != "https://login.docker.com/activate?user_code=FXDG-FKTF" || state.Done { | ||
| 59 | + t.Fatalf("waiting: %+v", state) | ||
| 60 | + } | ||
| 61 | + if err := os.WriteFile(filepath.Join(dir, "confirmed"), nil, 0o644); err != nil { | ||
| 62 | + t.Fatal(err) | ||
| 63 | + } | ||
| 64 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | ||
| 65 | + if state.User != "k33g" || state.Error != "" || len(state.Output) != 5 { | ||
| 66 | + t.Fatalf("done: %+v", state) | ||
| 67 | + } | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +func TestAFailedOrCancelledLoginSaysSo(t *testing.T) { | ||
| 71 | + sbx, dir := loginSbx(t) | ||
| 72 | + if err := os.WriteFile(filepath.Join(dir, "refuse"), nil, 0o644); err != nil { | ||
| 73 | + t.Fatal(err) | ||
| 74 | + } | ||
| 75 | + login, err := sbx.StartLogin() | ||
| 76 | + if err != nil { | ||
| 77 | + t.Fatal(err) | ||
| 78 | + } | ||
| 79 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | ||
| 80 | + if state.User != "" || state.Error == "" || !strings.Contains(strings.Join(state.Output, "\n"), "the code expired") { | ||
| 81 | + t.Fatalf("failed: %+v", state) | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + _ = os.Remove(filepath.Join(dir, "refuse")) | ||
| 85 | + login, err = sbx.StartLogin() | ||
| 86 | + if err != nil { | ||
| 87 | + t.Fatal(err) | ||
| 88 | + } | ||
| 89 | + waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Code != "" }) | ||
| 90 | + login.Cancel() | ||
| 91 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | ||
| 92 | + if state.Error != "cancelled" || state.User != "" { | ||
| 93 | + t.Fatalf("cancelled: %+v", state) | ||
| 94 | + } | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +func TestNotSignedIn(t *testing.T) { | ||
| 98 | + for text, want := range map[string]bool{ | ||
| 99 | + "sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart": true, | ||
| 100 | + "You are not authenticated to Docker. Starting the sign-in flow...": true, | ||
| 101 | + "sbx ls: exit status 1: daemon not running": false, | ||
| 102 | + } { | ||
| 103 | + if got := sbxcreate.NotSignedIn(text); got != want { | ||
| 104 | + t.Errorf("%q: %v", text, got) | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | +} | ||