Skip to content

refactor(uninstall): run the CLI and dashboard through one operation - #455

Merged
runkids merged 4 commits into
mainfrom
runkids/arch-442-uninstall
Oct 6, 2026
Merged

runkids merged 4 commits into
mainfrom
runkids/arch-442-uninstall

Conversation

@runkids

@runkids runkids commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Architecture refactor from #442. It is larger than "minor" and carries the intended behaviour changes listed below.

Linked Issue

Closes #442

What moved where

New package internal/uninstall:

Function Does Callers
Run(items, opts) Per resolved item: sourcefs.CheckSkillMoveOut → git.IsDirty for tracked repos unless forced → trash.MoveToTrash. Then for everything removed: .gitignore cleanup, MetadataStore.RemoveByNames, save. Returns a result per item. CLI runUninstallSkills, handleBatchUninstallSkills, handleUninstallRepo, handleUninstallSkill
Preflight(items, opts) The same two checks without changing anything, dirty checks in parallel. CLI, which warns and confirms between check and execution
Agents(...) Move the agent file and legacy sidecar to trash, drop its metadata entry, save once. CLI uninstall agents, both dashboard agent paths
  • MetadataStore.RemoveByNames is the single prune rule set. The two inline rule sets in handler_skills.go and handler_uninstall.go are gone.
  • The CLI keeps glob / --group / --all parsing, path-based resolution, prompts, output and oplog. Handlers keep request parsing, flat-name resolution, JSON, status codes and oplog. Which names resolve is unchanged.
  • Errors are typed (ErrDirty, *StatusError, *TrashError) so each caller keeps its wording.

Intentional behaviour changes

  1. DELETE /api/repos/{name} refuses a tracked repo with uncommitted changes, or whose git status cannot be read, with 409. ?force=true skips the check. Before: always removed. These two refusals carry their own error_code (repo_dirty, repo_status_failed). The Dashboard page sends the first request without force; on either code its confirmation dialog says why (uncommitted changes, or git status could not be read) and offers Retry with Force, which repeats the request with force=true. Cancel leaves the repo. Any other refusal is shown as an error with no override.
  2. DELETE /api/repos/{name} refuses a followed source link whose folder is itself a skill (409, "use unlink to remove the link"), like the CLI and the other routes. Before: the link was moved to trash.
  3. DELETE /api/resources/{name} prunes the skill's metadata entry and target overrides. Before: both stayed in .metadata.json until a later install, update or batch uninstall reconciled.
  4. CLI: removing top-level foo no longer prunes the metadata of the still-installed frontend/foo (the old basename rule).
  5. Dashboard batch: removing repo _team no longer prunes the untracked group team/… that is still installed (the old legacy-group match had no Tracked check).
  6. CLI prunes two stale cases it used to leave: a group-less full-path key below a removed repo, and legacy tracked-group entries (team/… for _team).

Smaller, visible only in edge cases:

  • A repo that fails both checks in a batch request now reports the move-out refusal, not the dirty state.
  • A batch request naming the same repo or agent twice words the second failure differently (all names resolve before anything is removed).
  • uninstall agents --dry-run no longer rewrites the agents .metadata.json.

Open questions for the maintainer

  • Resources page offers force for every failure. UninstallDialog shows "Retry with Force" after any failed item, including refusals force cannot override; the batch response has no per-item code. Not changed here.
  • Single routes do not reconcile. Only the batch route calls reconcileSkillsConfig, as before. Putting it in the shared server helper made DELETE /api/repos drop every entry whose directory is missing and rewrite project config, which existing tests pin against. In project mode the skills: config entry and lock pin stay until the next reconcile after a single-route uninstall.
  • Trash entry name still differs. CLI uses the full relative path; the dashboard uses the basename (relative path only below a followed link), so a nested skill removed from the dashboard restores to the top level. Kept per caller.
  • .gitignore cleanup still differs. CLI project mode drops the entry of every removed item; the dashboard only for tracked repos. Kept per caller.
  • Options.Force in the CLI. The CLI calls Run with Force: true after applying its own Preflight, so the field means "skip the dirty check", not "the user passed --force".
  • Pre-existing, unchanged: on Windows resolveTrackedRepo returns a backslash name for nested repos, which does not match slash metadata keys; CLI agent uninstall ignores a metadata save error.

Checks

Run in a Linux container from the devcontainer image:

  • make check (docs-check, fmt-check, go vet ./..., unit and integration tests): exit 0, 35 packages ok, on the final commit.

  • New tests were run against the old code first and failed where expected (stale metadata on the single route, 200 for a dirty repo, the two over-pruning cases, link trashed by the repo route).

  • python3 scripts/ai-context.py check: ok.

  • UI (same container): pnpm run lint 0 errors, pnpm run build ok, pnpm run test 969 passed, 2 failed. The 2 failures (MemoryNotes.test.tsx "reloads the note list and content from disk on refresh", MCPServerList.test.tsx "shows a server's Pi exposure on its row…") fail the same way on the unmodified parent commit and are in files this PR does not touch. The new DashboardPage tests and the locale parity test pass.

Not run: rendered screenshots of the new dialog states, website build, E2E runbooks, Windows locally (CI covers Windows).

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes (make check passes; 2 pre-existing UI test failures noted above)
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

The uninstall sequence (move-out check, dirty check, move to trash,
.gitignore cleanup, metadata prune) lived in the CLI and in three
dashboard handlers, and the copies had drifted: three different prune
rule sets, no dirty check on DELETE /api/repos, and no metadata prune
at all on DELETE /api/resources, which left the removed skill's entry
and target overrides in .metadata.json.

internal/uninstall now owns the sequence for resolved items. Callers
keep name resolution, prompts, output, HTTP status and oplog.
MetadataStore.RemoveByNames is the single prune rule set: an entry goes
when it is a removed path or lies below one, by key or by Group, plus
the tracked legacy group of a top-level repo.

Behaviour changes, all intended:
- DELETE /api/repos/{name} refuses a dirty tracked repo, or one whose
  git status cannot be read, with 409 unless ?force=true.
- DELETE /api/repos/{name} refuses a followed link whose folder is
  itself a skill, like every other uninstall path.
- DELETE /api/resources/{name} prunes the skill's metadata.
- Removing top-level "foo" no longer prunes "frontend/foo" (CLI), and
  removing repo "_team" no longer prunes the untracked group "team"
  (dashboard batch); both dropped metadata of skills still installed.

Refs #442
Review of the shared uninstall operation found that RemoveByNames still
matched a bare key: removing top-level "foo" pruned the legacy entry
"foo" with Group "frontend", which belongs to the installed
frontend/foo. Entries are now matched by their full path only.

Also from review: a dry run no longer runs git status for tracked
repos (it reports no git state), the unused Outcome.Removed is gone,
the two single-item handlers share one status mapping, and the CLI
reports a single target in one place instead of three flag checks.

Refs #442
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T16:39:37.270859Z 2e9f14d Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@runkids runkids added the architecture Deepening opportunity: restructure modules for locality and testability label Oct 6, 2026
DELETE /api/repos/{name} now refuses a repo with uncommitted changes or
unreadable git status, and the Dashboard page never sent force, so those
repos could not be removed from it at all.

The two refusals force overrides now carry their own error code. The
page still sends the first request without force; on either code the
confirmation says why and retries with force only when the user
confirms. Other refusals, such as a linked folder that is itself a
skill, keep the plain error because force does not change them.

Refs #442
@runkids

runkids commented Oct 6, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 2e9f14da49

ℹ️ 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".

@runkids
runkids merged commit 696e9fd into main Oct 6, 2026
8 checks passed
@runkids
runkids deleted the runkids/arch-442-uninstall branch October 6, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture Deepening opportunity: restructure modules for locality and testability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uninstall: the CLI and three dashboard handlers each implement the uninstall sequence

1 participant