Repository navigation
feat: save suggested cloud profiles on first use - #170875
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b57b6eb1d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const suggestion = await resolveSuggestedWorkerProfile({ | ||
| config: snapshot.config, | ||
| refresh: true, | ||
| }); |
There was a problem hiding this comment.
Bind adoption to the suggestion the user selected
When multiple eligible workerProfileSuggestions owners exist, the list can display owner B because owner A currently returns no suggestion, but adoption carries no suggestion identity and this fresh resolution can select A if its state has changed. The handler then persists A's profile even though the operator selected B, potentially routing a later paid worker dispatch through an unexpected backend; carry an owner/profile token from listing into adoption and reject a mismatch.
AGENTS.md reference: src/gateway/AGENTS.md:L22-L25
Useful? React with 👍 / 👎.
| return ({ refresh }) => { | ||
| if (refresh || !cached) { | ||
| cached = discover().catch((error: unknown) => { | ||
| dependencies.warn(`Crabbox profile discovery unavailable: ${String(error)}`); | ||
| return undefined; | ||
| }); |
There was a problem hiding this comment.
Allow recovery after negative profile discovery
If the first discovery runs before Crabbox is configured, while its CLI is temporarily unavailable, or before a Linux class is advertised, this caches a promise resolving to undefined permanently. Subsequent catalog refreshes reuse that negative result, while the only caller passing refresh: true is the adoption RPC—which the UI cannot invoke because no suggestion is visible—so fixing the Crabbox setup does not expose Cloud until the Gateway restarts. Avoid permanently caching negative results or provide an independently reachable refresh path.
AGENTS.md reference: AGENTS.md:L78-L80
Useful? React with 👍 / 👎.
b57b6eb to
6b67e80
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b67e804e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| refresh: true, | ||
| }); | ||
| authority.assertCurrent(); | ||
| if (!suggestion || suggestion.id !== "cloud") { |
There was a problem hiding this comment.
Honor profile IDs allowed by the suggestion contract
A plugin can validly return any non-empty SuggestedWorkerProfile.id, and environments.list advertises that ID, but adoption rejects every ID except cloud. A third-party plugin returning a conforming suggestion such as gpu therefore presents a selectable item that always fails with UNAVAILABLE; either constrain the public type/schema/docs to the literal cloud or persist and return the refreshed suggestion under its declared ID.
AGENTS.md reference: src/plugins/AGENTS.md:L25-L29
Useful? React with 👍 / 👎.
| ); | ||
| } | ||
| const profiles = await listWorkerProfilesWithMachines(context); | ||
| const suggestedProfile = await listSuggestedWorkerProfile(context); |
There was a problem hiding this comment.
Skip admin-only discovery for non-admin list calls
When no cloud profiles exist, every first environments.list call awaits suggestion discovery before responding, even for read-only callers that cannot invoke the admin-only adoption method. On a host with an installed but hung Crabbox binary, this runs config show with its 60-second timeout and stalls the otherwise unrelated environment/device catalog; check admin scope before discovery so non-admin reads remain independent of this optional setup probe.
Useful? React with 👍 / 👎.
6b67e80 to
6c83fe0
Compare
|
Merged with a pinned-head REST squash on The only red was
|
Shares the snapshot status rule between repository summaries and snapshot rows, and shares unassigned-preparation eligibility between repository grouping and unlabeled builds. Removes duplicate label arguments, a redeclared action props type, naming-only accessors, an input-only form-control helper, singleton fragments and consecutive store updates. Net production change: -41 lines across four Control UI files. No user-visible behavior change. Related: #170892, #170895, #170875, #171176 Refs: #171684
Cloud is available in New Session without hand-writing a profile. When no cloud worker profiles exist and the Crabbox CLI on the Gateway host reports a usable provider, environments.list carries one non-dispatchable suggested profile discovered through a cached, manifest-declared Crabbox discovery path. Picking Cloud calls the new admin-only environments.adoptSuggestedProfile, which writes cloudWorkers.profiles.cloud through the normal config.patch owner (snapshot CAS and live-authority checks) and then selects it like any configured profile. Existing cloud profiles are returned untouched; dispatch, repository defaults and Doctor read only real config. The saved profile uses Linux, the smallest advertised standard class, an 8 h lifetime, 45 min idle and suspend defaults, and warm images on. Refs: openclaw#170875
Shares the snapshot status rule between repository summaries and snapshot rows, and shares unassigned-preparation eligibility between repository grouping and unlabeled builds. Removes duplicate label arguments, a redeclared action props type, naming-only accessors, an input-only form-control helper, singleton fragments and consecutive store updates. Net production change: -41 lines across four Control UI files. No user-visible behavior change. Related: openclaw#170892, openclaw#170895, openclaw#170875, openclaw#171176 Refs: openclaw#171684
Problem
What Problem This Solves
New Session requires a manually configured cloud-worker profile even when Crabbox on the Gateway host already has a configured backend or coordinator login.
Solution
Expose one separate
suggestedProfilethroughenvironments.list. Crabbox discovers it through a manifest-declared lightweight artifact with lifecycle-owned caching; its provisioning plugin retainsonStartup: false.Selecting Cloud calls the admin-only
environments.adoptSuggestedProfilemethod. Adoption refreshes discovery, savescloudWorkers.profiles.cloudthrough the normalconfig.patchvalidation/concurrency/reload path, and returns the configured summary. Existingcloudprofiles are returned untouched. Suggestions never enter dispatch, repository defaults, retention, or Doctor as virtual profiles.The picker shows one Cloud item and provider icon. Saving errors use the existing error surface. Pending adoption cannot submit a session or overwrite a newer selection. Config publication retains live request authority.
The CI repair regenerates the Crabbox reference through
pnpm plugins:inventory:gen, shares the catalog fixture without an unsafe array access, preserves real exports in four partial mocks, and removes the UI type-import cycle through the existing draft-place contract owner. No guard, budget, or mock baseline was changed.Impact
Administrators can pick Cloud in New Session without writing a profile first. The saved profile uses Linux, the smallest advertised canonical class, an eight-hour TTL, 45-minute idle timeout and suspend, and warm images. Explicit profiles suppress the suggestion.
Updates need no migration or database changes. Adopted profiles use existing public configuration keys and reload behavior. Discovery verifies configured inputs; allocation retains its live preflights. Integrated AWS proof remains outside this lane.
Evidence
Rebased onto
db87a3b6364584c0667bd527298e5a91fd836bac, including the landed Crabbox provider/profile changes. Each comparison below ran separately in the same worktree, first on pinned main and then on the rebased branch. Wall times include shared-host contention and compiler preparation.pnpm test src/gateway/server.sessions.archive-worker-placement.test.ts --maxWorkers=1pnpm test src/gateway/server.sessions.create.titles.test.ts --maxWorkers=1pnpm test src/gateway/server.chat-steer-direct-command.test.ts --maxWorkers=1The title failures are pre-existing: both revisions reproduce
sessions.create preserves background title recovery after generator errorand... after delayed title, with the same assertion as CI: the mock expected no call but received one call. Their owner is unchanged. The archive and steering shard failures did not reproduce in either isolated comparison; these passing replays are not presented as fixes for the original failures.Failed checks repaired and rerun:
pnpm tsgo:extensions:test— passed, 46.20s.pnpm tsgo:test:ui— passed, 527.43s, including artifact-lock wait.pnpm check:test-mock-exports --base db87a3b6364584c0667bd527298e5a91fd836bac— passed, 136.39s; baseline unchanged at 9709 grandfathered factories.pnpm check:madge-import-cycles— passed, 259.29s; zero cycles.pnpm plugins:inventory:check— passed, 1.17s; generator changed only the Crabbox Contracts line.git diff --checkpassed.The initial mixed core/extension scoped lint attempt stopped before linting: plugin SDK declaration preparation hit its unchanged 300000ms timeout (356.95s wall). Extension lint remains for PR CI; no timeout or artifact guard was bypassed. A fresh independent Codex review of the repair was scoped clean through P2.
Original feature proof, before this rebase (head b57b6eb1d3a032386fdf9901392d5b8c89c93507)
165 passed and one existing platform skip in 148.30s:
pnpm test src/gateway/server-methods/config.test.ts src/gateway/server-methods/environments.suggested-profile.test.ts extensions/crabbox/src/crabbox-worker-profile-suggestion.test.ts extensions/crabbox/src/crabbox-worker-provider.test.ts src/plugins/worker-profile-suggestions.test.ts packages/gateway-protocol/src/schema/environments.test.ts ui/src/pages/new-session/where-chip.test.ts ui/src/pages/new-session/suggested-cloud.test.ts --maxWorkers=1Picker browser proof: two passed in 40.24s, including UI build:
The original full build passed in 6047.42s, with an identity-qualified cached refresh in 823.99s. Qualified Crabbox cold import passed in 16.82s, with 196.3 MB peak RSS. These are prior-head results; broad builds and suites were not repeated for the CI repair. The repair changes no visual behavior, so the inspected captures remain applicable.
Release-note context
New Session can discover a configured Crabbox backend and save a Cloud profile on first selection, removing the need to hand-author cloud-worker configuration. Existing profiles and admin authority remain canonical.