Repository navigation
[Profiles 3/4] Dashboard: see and switch profiles - #903
salmonumbrella wants to merge 84 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afd8b437f4
ℹ️ 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".
| link = evalOrClean(link) | ||
| if utils.PathHasPrefix(link, strings.TrimSuffix(root, string(filepath.Separator))+string(filepath.Separator)) { |
There was a problem hiding this comment.
Preserve ownership of links through followed source directories
With follow_source_links enabled, a merge target can legitimately contain a manifest-recorded link to source/_repo/skill, where _repo points at an external checkout. evalOrClean(link) resolves that destination into the checkout, so this physical-prefix test reclassifies skillshare's own link as unmanaged. After the target has been synced, profile switches retaining that skill fail with profile_blocked, while switches excluding it leave it deployed. Recognize links through sanctioned followed source directories rather than requiring every resolved destination to reside physically beneath SourceRoot.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| } | ||
| out.Profile = candidate.Info(discovery.Skills) | ||
| out.Selection.Active = req.Name | ||
| planned, err := execute(ctx, candidate, targets, discovery, true, false, true, nil, nil) |
There was a problem hiding this comment.
Model root conversion before classifying preview entries
When a previously synced symlink-mode target is changed to merge or copy through target settings, its root still points at the source until synchronization converts it. This dry-run leaves that link intact because ensureRealTargetDir does not perform the conversion, then the ownership checks in both SyncTargetMergeWithPolicy and SyncTargetCopyWithSkillsOptions inspect source directories through the linked root and classify them as unmanaged. Apply consequently returns profile_blocked before performing the safe conversion, preventing both CLI and dashboard activation directly after this supported mode change. Both planners need to model the post-conversion root as empty.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| path, err = create(v.BackupDir, keys[entry.Dir], entry.Dir) | ||
| if err != nil || path == "" || filepath.Base(path) != keys[entry.Dir] { | ||
| return saved, nil, fmt.Errorf("snapshot %s failed (no edits discarded): %v", entry.Target, err) |
There was a problem hiding this comment.
Resolve target-root aliases before creating discard snapshots
For a merge/copy target whose configured skills directory is a symlink or junction, such as a dotfiles-manager alias, EntryChange.Dir remains the lexical alias because cleanEntryDir only makes it absolute. Passing it unchanged to backup.CreateInDir makes that function return an empty path without an error for the link root, so snapshot-first discard always fails here even though the writers support configured directory aliases. This affects both profile switching and ordinary profile-aware sync. Resolve the operation root for snapshot creation while retaining the logical directory identity used by discard grants.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
Codex Review Summary: ✅ CompletedThis 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. |
|
Thanks for all the work you've put into these. A lot of large PRs have arrived at once, more than I can take in right now, so I need to go through them slowly. I can't promise a date, but I'll get to them. |
|
Current-main audit matches the Profiles stack dependency audit for #893. Main covers the shared YAML comment-preservation and junction traversal foundations, but does not contain the profile-preservation, alias/inventory, target naming and Windows canonicalization behavior this stack depends on. No ready claim. |
3ed9bcf to
ee60e06
Compare
ee60e06 to
fd08cf0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd08cf025f
ℹ️ 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".
| } | ||
| out.Profile = candidate.Info(discovery.Skills) | ||
| out.Selection.Active = req.Name | ||
| planned, err := execute(ctx, candidate, targets, discovery, true, false, true, nil) |
There was a problem hiding this comment.
Apply the active profile in the shared skill-selection path
With enabled source skills alpha and beta, a CLI-created profile including only alpha still deploys both and records a completed activation, contrary to the documented purpose to “switch the skills deployed to your tools” (website/docs/reference/commands/profile.md:7). Both Apply and WithSkillSync pass the full discovery to the executor, but selectTargetSkills never consults the new ResourceTargetConfig.Profile; resolved project targets also never receive that selector. Consequently profile exclusions do not affect writing or pruning, and profile show target counts and diff remain unrestricted. Wire the selector into shared selection/pruning and project target resolution, rather than applying it only to Info and Preview.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| ProfileAware bool | ||
| Discard []DiscardEntry |
There was a problem hiding this comment.
Enforce edit protection before profile-aware target writes
For a managed copy edited locally and subsequently changed in source, activating a profile that retains that skill reaches copy.go's legacy overwrite branch and deletes the authored destination without --discard-edits. These new options are never consumed by ExecuteTargets or forwarded through SyncSkillTarget, and neither KeptModified nor Blocked is populated, so both Apply and WithSkillSync bypass refusal and verified snapshots. This violates the documented edited-copy behavior that a switch “refuses and lists its reason” (website/docs/reference/commands/profile.md:53). Implement and forward the profile-aware writer policy before either adapter executes destructive operations.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| for _, row := range executed.Results { | ||
| state := "applied" | ||
| if sourceIncomplete || len(row.KeptModified)+len(row.Blocked)+len(row.FailedRemovals) > 0 || row.PruneError != "" { |
There was a problem hiding this comment.
Propagate prune failures before settling profile state
If pruning a stale managed copy fails, for example because a Windows tool has a file locked, pruneOrphanCopiesWithConfig and SkillTargetResult.addPrune only produce warnings; ExecuteTargets never populates the new FailedRemovals or PruneError fields. This check therefore still classifies the target as applied, and both Apply and WithSkillSync clear pending while the stale skill remains deployed. Activation also exits successfully, contrary to the documented “partially applied switch exits nonzero” contract (website/docs/reference/commands/profile.md:61). Forward structured prune failures into the result and retain pending state when removal fails.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
Make target filter matching available to profile selection without creating a dependency cycle, while retaining the existing filter behavior.
Preserve named selections in both configuration scopes and centralize their validation and edits so later commands can share the same rules under the profile lock.
Let users switch named skill selections without replacing authored target content. Share locked reload, verified snapshots and existing skill execution between profile activation and ordinary CLI/API sync, with pending recovery. Expose definition transactions for later API consumers and document the scope, recovery and compatibility rules. Add acceptance fixtures and hosted baseline comparison without claiming local runtime validation.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1899507bda
ℹ️ 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".
| if ignorePatterns == nil { | ||
| ignorePatterns = DefaultFileIgnorePatterns() | ||
| } | ||
| sum, _ := DirChecksumWithIgnore(in.Path, ignorePatterns) |
There was a problem hiding this comment.
Include custom-ignored files in preservation fingerprints
With ignore: [notes.md], copy a skill, add an authored notes.md to its target, then switch to a profile excluding that skill. Hashing the target with the full copy-ignore list makes it equal the recorded checksum, so planning classifies it as clean and application deletes the authored file without refusal or a discard snapshot. The refresh check in copy.go:241 has the same problem; sync.go:749 and internal/profileapply/snapshot.go:44 also reuse these filtering rules for edit verification. Use preservation fingerprints that include target-only files matched by custom ignores, following the existing copyHashPatterns policy, rather than reusing source-copy filtering.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| if mode == modeProject && kind != kindAgents && !projectConfigExists(cwd) { | ||
| return fmt.Errorf("restore is not supported in project mode (except for agents)") |
There was a problem hiding this comment.
Keep project restores out of the global restore picker
When a project config exists, skillshare restore -p without a target now passes this guard and enters restoreTUIDispatch. That function loads the global config and global backup directory (backup.go:512-549), and the picker ultimately calls RestoreToPath with those global target paths and Force: true (restore_tui.go:507-521). Consequently, an explicitly project-scoped recovery can overwrite a global tool directory instead of restoring the project's snapshot. Route the no-target picker/listing through the project config and backup directory, or retain the rejection for no-target project restores until that path honors project mode.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| if naming == "prefixed" { | ||
| manifest.OutputChecksums[activeName] = outputChecksum | ||
| } |
There was a problem hiding this comment.
Invalidate fingerprints when leaving prefixed naming
For a tracked-repo skill copied with prefixed naming, change the target to standard or flat naming and run ordinary sync without an active or pending profile. renameManifestEntry carries the old rewritten output checksum to the new entry, but this write replaces the contents with unrewritten source bytes without clearing that checksum; the clearing logic only runs inside the profile-aware branch. A subsequent profile activation therefore refuses an unedited copy, and automatic copy-to-merge conversion also stops recognizing it as clean. Update or clear the output fingerprint in all three copy-write paths (copy.go:206-213, 324-327, and 371-374) whenever rewriting stops.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| pluginArgs = append(pluginArgs, arg) | ||
| } | ||
| } | ||
| if err := cmdPlugin(pluginArgs); err != nil { |
There was a problem hiding this comment.
Use the shared plugin runner for global text sync
In the global, non-JSON sync --all --plugins path, forwarding the original sync arguments to cmdPlugin makes --force, --quiet, or --discard-edits fail as an unknown plugin argument in parsePluginOptions after earlier resources have already been synchronized. Without those flags, an interactive terminal enters pluginWizard instead of applying automatically. The documented contract says “It never opens the plugin TUI” and that --force and --quiet do not apply to the plugin step (website/docs/reference/commands/sync.md:586-587); the existing runSyncPlugins wrapper enforces this for project and JSON runs. Use that wrapper for this branch too.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad15457969
ℹ️ 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".
| } | ||
| executed, err := ssync.ExecuteTargets(context.Background(), s.cfg, runTargets, ssync.ExecuteOptions{ | ||
| Kinds: kinds, DryRun: dryRun, Force: force, ProjectMode: s.IsProjectMode(), ProjectRoot: s.projectRoot, | ||
| Kinds: kinds, DryRun: dryRun, Force: force, ProfileAware: true, ProjectMode: s.IsProjectMode(), ProjectRoot: s.projectRoot, |
There was a problem hiding this comment.
Scope profile-aware writes to active or pending selections
For a dashboard copy-mode sync with no active or pending profile, this hard-coded flag enables edit preservation anyway. If a managed target copy was edited and its source changes, the dashboard now skips the refresh; edited orphan copies also stop being pruned. Ordinary CLI sync enables this policy only when State.Active != "" || State.Pending, and website/docs/reference/commands/profile.md:67 promises unchanged no-profile behavior. Derive the policy from the applicable profile state instead of enabling it for every dashboard target.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| if profileErr := profileView.ActiveProfileError(); profileErr != nil { | ||
| return nil, http.StatusConflict, profileErr |
There was a problem hiding this comment.
Keep agent-only sync outside the active-skill-profile guard
When an active definition has been removed through the dashboard config editor, POST /api/sync with {"kind":"agent"} now returns HTTP 409 here before syncing any agents. Profiles select skills only, and website/docs/reference/commands/sync.md:787 explicitly keeps resource-only sync available when the active profile is unavailable. Put the new profile loading and validation inside the existing kind != kindAgent boundary so an unavailable skill selection does not block unrelated agent synchronization.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| } | ||
| executed, err := ssync.ExecuteTargets(context.Background(), s.cfg, runTargets, ssync.ExecuteOptions{ | ||
| Kinds: kinds, DryRun: dryRun, Force: force, ProjectMode: s.IsProjectMode(), ProjectRoot: s.projectRoot, | ||
| Kinds: kinds, DryRun: dryRun, Force: force, ProfileAware: true, ProjectMode: s.IsProjectMode(), ProjectRoot: s.projectRoot, |
There was a problem hiding this comment.
Surface preserved copies through dashboard sync warnings
With an active profile, editing a managed copied skill and then changing its source makes this newly enabled policy preserve the target and return its reason in kept_modified. The current client does not consume that field: syncView.ts:604–606 extracts only failed rows, and SyncPage.tsx:367–371 consequently announces success and counts pending changes as written. These preserved-copy entries also produce no executed.Warnings, leaving users without an explanation for the unapplied update. Translate kept/blocked entries into the existing warnings payload, as profileSyncRun.results does for CLI sync.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 996d346ea6
ℹ️ 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".
| return | ||
| } | ||
|
|
||
| s.mu.Lock() |
There was a problem hiding this comment.
Release the server mutex on project-validation errors
If a project is removed after the dashboard loads its sync preview, submitting that preview reaches the unknown-project return while s.mu is still locked. Both project-validation error branches return before the explicit unlock, and the previous deferred unlock has been removed. Subsequent API requests block in withConfigAutoReload, leaving the dashboard unusable until the server restarts. Ensure both validation failures release the mutex.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| if len(syncOut.skills) > 0 { | ||
| if contextCost := s.computeContextCost(syncOut.skills); contextCost != nil { |
There was a problem hiding this comment.
Protect shared configuration while assembling the sync response
When another dashboard tab adds or edits a target during response assembly, the Run callback has already released s.mu, but computeContextCost still iterates s.cfg.Targets. handleAddTarget writes to that map under the mutex, so this newly unlocked reader can race with it and terminate the server with a concurrent map iteration/write error. The subsequent agentsSource() call also reads shared configuration without its required lock. Snapshot these response inputs under the mutex or protect both helper calls with a read lock.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| if !req.DryRun && req.Targets == nil && out.Complete && v.State.Pending { | ||
| state := v.State | ||
| state.Pending = false |
There was a problem hiding this comment.
Settle pending state only after a complete skill sync
After profile use work --no-sync, an agent-only dashboard sync or a sync restricted to one declared project still enters this branch with req.Targets == nil. A successful callback therefore clears the owning configuration's pending flag even though its skill targets were not reconciled. Incomplete followed-source traversal has the same false-completion outcome because out.outcome(executed, false) discards SourceIncomplete, although the executor skips pruning in that case. Carry actual skill coverage and source completeness into settlement, and retain pending state for these partial runs.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
| Run: func(ctx context.Context, _ *profileapply.View) (ssync.ExecuteResult, error) { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| out, code, err := s.syncResources(start, body.DryRun, body.Force, body.Kind, body.Project) |
There was a problem hiding this comment.
Execute sync using the configuration loaded under the profile lock
If a CLI profile use ... --no-sync finishes after withConfigAutoReload populates s.cfg but before this transaction acquires the profile lock, the supplied view contains the new selection while s.cfg retains the old per-target selectors. This callback discards that freshly loaded view, and syncResources executes against s.cfg; the new settlement path then clears the new profile's pending flag even though it deployed the old selection. Reload the execution configuration after acquiring the profile lock or execute from the supplied view.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Profiles #202 slice 4, stacked on #902 and #893. This PR adds profile-aware activation and sync through the existing profile application owner, including selector filtering, pending/incomplete outcomes, modified-copy preservation, snapshot-before-discard, and project/global restore routing.
Main already supplies target naming, manifest ownership, sync traversal, and diff APIs. The dashboard routes, editor, diagnostics, and documentation are reserved for #904 and are not part of this PR.
Validation at exact head 3268dec passed in Docker with go build, internal/sync, internal/profileapply, internal/profile, internal/server profile tests, cmd/skillshare profile tests, and TestProfiles_Agreement plus TestProfiles_PreservationAndDiscard.
Refs #202
Stacks on #902