Skip to content

fix(snippets): preserve all-hosts scope in snippet import/export - #3636

Open
netcatty-bot wants to merge 2 commits into
mainfrom
ai/issue-3635-38173106143
Open

netcatty-bot wants to merge 2 commits into
mainfrom
ai/issue-3635-38173106143

Conversation

@netcatty-bot

Copy link
Copy Markdown
Collaborator

Summary

  • Add optional targetsAllHosts?: boolean to SnippetExportItem so the portable "apply to all hosts" scope survives snippet toolkit export/import.
  • toExportItem now writes targetsAllHosts: true and, when the flag is set, omits group scope so exported JSON is never ambiguous.
  • sanitizeImportItem accepts the flag only when it is exactly true and drops targetGroups in that case, so an all-hosts import always wins the unambiguous way (matching save-time semantics).
  • toImportedSnippet restores targetsAllHosts on the imported snippet, keeps targets: [], and only applies targetGroups when the flag is absent.
  • Concrete host-ID bindings (targets) remain intentionally omitted from exports, so imports stay portable across machines.

Why

Importing a portable snippet toolkit JSON preserved targetGroups but silently dropped targetsAllHosts: true, so after importing a shared toolkit with 20+ snippets each one had to be reopened and re-scoped to all hosts by hand. The boolean does not depend on local host IDs or group paths, so it is safe to round-trip.

Changes

  • domain/snippetTransfer.ts: export type + toExportItem, sanitizeImportItem, toImportedSnippet.
  • domain/snippetTransfer.test.ts: new tests covering export → parse → merge round-trip of targetsAllHosts and conflict resolution against targetGroups (all-hosts wins; explicit false stays unscoped).

No version bump: the field is additive and optional, and legacy version-1 payloads go through the same sanitizer.

Testing

  • node --test --import tsx domain/snippetTransfer.test.ts — 12/12 pass, including the two new tests.
  • node --test --import tsx domain/snippetTargets.test.ts domain/snippetAgentOps.test.ts — still pass.
  • npx tsc --noEmit -p tsconfig.json — no errors in the touched files.
  • npx eslint domain/snippetTransfer.ts domain/snippetTransfer.test.ts — clean.

Fixes #3635

Automation

  • Automated implement pass
  • Review gate: @codex review (own/bot PRs only)
  • Draft until Codex reports clean findings

@netcatty-bot netcatty-bot added automation:bot-pr PR created or owned by Cursor automation automation:codex-loop Own/bot PR waiting on Codex review↔fix loop triage Touched by Cursor automation labels Oct 11, 2026
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T21:30:55.594150Z 0537417 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86c3419210

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

Comment thread domain/snippetTransfer.ts
tags?: string[];
package?: string;
targetGroups?: string[];
targetsAllHosts?: boolean;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bump the export version for the new scope field

When a toolkit produced here is imported by a pre-change Netcatty release, the payload still advertises version 2, so that release accepts it but silently discards targetsAllHosts; an all-host onConnect script is then stored without targets or groups and is excluded from getGlobalConnectScripts, disabling its automation. Use a new export version while continuing to accept versions 1 and 2, or provide another compatibility representation rather than reusing version 2.

AGENTS.md reference: AGENTS.md:L153-L155

Useful? React with 👍 / 👎.

@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Oct 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0537417793

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

@netcatty-bot
netcatty-bot marked this pull request as ready for review October 11, 2026 21:29
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Oct 11, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator Author

Codex reported no major issues. This PR is marked ready for human review/merge.

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

Labels

automation:bot-pr PR created or owned by Cursor automation automation:codex-clean Last Codex review reported clean triage Touched by Cursor automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Preserve targetsAllHosts in snippet import/export

2 participants