Skip to content

feat(environments): explain policy and sign-in failures in Settings and offer only configured channels - #166

Draft
romulorosa wants to merge 11 commits into
kilo/implement-policy-channel-error-handling-and-nfrom
kilo/policy-settings-states
Draft

romulorosa wants to merge 11 commits into
kilo/implement-policy-channel-error-handling-and-nfrom
kilo/policy-settings-states

Conversation

@romulorosa

Copy link
Copy Markdown
Collaborator

Stacked on #163 (policy error codes and the 0.1.23 bridge payload). Review that first; this PR's base is its branch.

What and why

Settings → Conda Environments explained policy and Anaconda sign-in failures badly: a refused search looked like "No results… check the spelling or choose other channels", the Python picker kept made-up versions, a failed update check looked like "up to date", and most dialogs and toasts showed one generic line. The channel chooser also always added conda-forge and defaults, so a person whose org configured only policy channels still got an unfiltered conda-forge, and configured channels showed up as raw per-subdir URLs.

This PR, all in kilo.environments:

  • Configured channels only. prefixOptions().channels now comes from conda_tools.list_channels (canonical names, in configured order) instead of conda.info's per-subdir URLs. Create environment and Add packages offer exactly those channels, all selected; defaults and conda-forge are offered only when no channel is configured. No Anaconda alias is folded into defaults any more (isAnacondaChannel is presentation only). While the list loads, search and preview wait; if it fails, the dialogs say so with "Try again" and never fall back to fixed channels. An install link's channel is still offered and selected first.
  • Failures explained, not hidden.
    • Package search keeps its error. NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED show a "Sign in to Anaconda" state naming the refused channel (signing in searches again); other failures show the message with "Try again". The no-results copy only says "Check the spelling."
    • The Python picker has no made-up versions: on failure it offers only "Latest" and shows why (with sign-in for auth errors).
    • Environment detail says "Couldn't check for updates" (with sign-in) instead of looking up to date.
    • The Add packages footer, clone, remove and bulk-remove dialogs and the install link's check step show PolicyErrorDetails under the message. Signing in from a removal dialog retries the removal.
    • Job toasts (create, import, install, update, backup, delete) show a one-line summary and a "Details" action that opens the full explanation, the blocked list and sign-in.
    • Copy for gaps without a bridge explanation: a removal refused while signed out asks to sign in to change the environment; clone and backup failures are no longer called a dependency conflict; Import from file notes that the file's own channels and its pip: section are not covered by the org's policy.
    • These catch paths report environment-policy-blocked (surface: "ui"), once per shown failure. The footer error skips it because its toast already reports it.
  • "May hide packages" hint. There is a new kilo.environments/conda.channelPolicies read over the bridge's auth.channel_policies. It is cached like findRepodata, allowMissingMethod keeps older bridges silent, and it is not an agent tool. Under the search it says "Your organization's package policy may hide some packages on ." It is only a "may", never holds results, and stays out of the chooser.
  • Caches follow the Anaconda account. A new public JobQueue.clearReadCache(provider?) drops cached reads and, like a write, keeps reads already in flight out of the cache. Main calls it on kilo.anaconda/account's changed. Settings keys package search on the account and refreshes its account-filtered reads when the account changes.

Docs: docs/plugins/schema.md (new method), open follow-ups in docs/plugin-architecture.md, and docs/security-architecture-overview.md 1.6 (the bridge's policy lookups use the same key).

Behaviour change (release note)

Settings → Conda Environments now offers only the conda channels you have configured. conda-forge and Anaconda's defaults are no longer added automatically, except when no channel is configured at all. To search or install from another channel, add it to your conda channels.

Deviations from the plan

Tests

  • pnpm lint (oxlint, boundaries, schema doc, React Compiler) and pnpm format:check pass.
  • pnpm check passes for all 28 packages.
  • pnpm --filter @kilo-desktop/plugin-environments coverage passes: 46 files and 1010 tests across unit, integration and browser. Coverage: statements 96.2%, branches 87.9%, functions 92.4%, lines 97.2%.
  • New and changed tests:
    • Unit: selectableChannels (empty fallback, ["defaults"], ["conda-forge","bioconda"], org channels only, aliases kept); SidecarCondaBackend prefixOptions from list_channels, and channelPolicies mapping plus the missing-method fallback; JobQueue.clearReadCache (per provider, all, in-flight read not cached); friendly copy for remove and clone; the backup toast using clone copy.
    • Main: an Anaconda account change clears the read cache (entry.test.ts). Integration: the channelPolicies read caching.
    • Browser: useChannelSelection loading, empty, failed and link-first. AddPackage and Create request only configured channels, and a failed channel list holds the search until "Try again". Also covered:
      • search sign-in state and retry, generic search error, "Check the spelling.";
      • Python picker with only Latest;
      • "Couldn't check for updates" with sign-in;
      • the toast "Details" dialog;
      • removal sign-in copy and retry, clone failure copy, the import note;
      • the policy hint and that it never holds results;
      • search refreshing on an account switch, and the account key hook.

Live checks still to do (payload 0.1.23, environments-feature on, an API key scoped to a policy org)

  • With channels: [defaults] on repo.anaconda.cloud, the chooser shows only "Anaconda Main" (no conda-forge, no raw subdir URLs), and a version the policy blocks (e.g. pillow 8.4.0) is not offered.
  • With no channels in any condarc, the chooser shows conda-forge and defaults, both preselected.
  • With channels: [conda-forge, bioconda], it shows exactly those two.
  • Signed out: search shows the sign-in state, not "no results"; the Python picker offers only "Latest"; the environment detail shows "Couldn't check for updates".
  • With only defaults selected, the blocked version is missing from the version menu, and an install link for it shows the policy card in its preview.
  • A failed background update's toast opens the blocked list from "Details".
  • Switching the Anaconda account refreshes search results.
  • The "may hide some packages" hint appears for a policy channel and not for conda-forge.

Create environment and Add packages now offer exactly the configured
channels, by their canonical names from conda_tools.list_channels, in
configured order. defaults and conda-forge are offered only when no
channel is configured, and no Anaconda alias is folded into defaults.
While the channel list loads, search and preview wait; when it fails the
dialogs say so with Try again instead of falling back to fixed channels.
An install link's channel is still offered and selected first.
… changes

repo.anaconda.cloud filters repodata for the Anaconda account whose key
the bridge sends, so a cached lookup may belong to the previous account.
Main now clears the conda read cache on kilo.anaconda's account changed
event through a new JobQueue.clearReadCache, which also keeps reads that
started before the clear out of the cache. Settings keys package search
on the account and refreshes its account-filtered reads when it changes.
A failed package search is no longer shown as 'No results': an Anaconda
sign-in refusal names the refused channel and offers Sign in to Anaconda,
which searches again; other failures say what went wrong with Try again.
The no-results copy only says to check the spelling. The Python picker
no longer starts from made-up versions: when the lookup fails it offers
only Latest and shows why. An environment whose update check failed says
'Couldn't check for updates' instead of looking up to date. Each failure
is reported as environment-policy-blocked (surface ui) when it is one.
Add a channelPolicies read to kilo.environments/conda over the bridge's
auth.channel_policies (cached like findRepodata, cleared by writes and
Anaconda account changes; older bridges report no channels). Under the
package search, Create environment and Add packages say 'Your
organization's package policy may hide some packages on <channel>' for
selected channels with a policy. It is only a 'may', never waits before
results, and stays out of the channel chooser.
…ailure

The Add packages footer error, the clone, remove and bulk-remove dialogs
and the install link's check step now show the blocked packages, the
policy note and Sign in to Anaconda under their message (a sign-in in a
removal dialog retries the removal). Job failure toasts show a one-line
summary and a Details action that opens the full explanation. A removal
refused while signed out asks to sign in to change the environment, a
failed clone or backup is no longer called a dependency conflict, and
Import from file notes that the file's own channels and its pip: section
are not covered by the organization's policy.
…ount changes

Cover the account key and the refresh of account-filtered reads, which
also found channelPolicies missing from them. Invalidate them in
parallel rather than one after another.
…ror-handling-and-n' into kilo/policy-settings-states

# Conflicts:
#	plugins/environments/src/web/providers/conda/CreateEnvironmentDialog.tsx
#	plugins/environments/src/web/providers/conda/environments-toasts.tsx
…ror-handling-and-n' into kilo/policy-settings-states
…ror-handling-and-n' into kilo/policy-settings-states

# Conflicts:
#	plugins/environments/src/web/providers/conda/PolicyErrorDetails.tsx

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant