dsh-github-copilot 0.1.0-alpha.10.dsh.0.2.2.rc.3 → 0.1.0-alpha.11.dsh.0.2.2.rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -54,15 +54,18 @@ readback; never migrate or interpret the old `searchModel` as this choice.
54
54
  The former plugin routing UI and managed Auto remain retired. Supplier calls,
55
55
  live installation and restarts are separate from synthetic CI acceptance.
56
56
 
57
- The user-authorized native model sync (#466) is a narrow exception to the
58
- no-settings-rewrite rule: after an explicit preview and confirmation, one
57
+ The user-authorized native model sync (#466, #479) is a narrow exception to the
58
+ no-settings-rewrite rule: after a visible preview and one explicit confirmation, one
59
59
  revision-checked write may replace only
60
60
  `llm-pi-ai.providers.github-copilot.models` in an existing canonical profile.
61
61
  Prove current canonical-account metadata and the native adapter-owned catalog;
62
62
  skip unrepresentable or uncertain model capabilities. Disclose additions,
63
63
  updates, removals, skipped models and configured output request defaults.
64
- Recheck account/catalog/preferences and Settings evidence before the one-shot
65
- write, then read back both user and effective values. Never create a profile,
64
+ Prepare the preview without forced discovery from existing verified evidence.
65
+ An existing `compat.supportsStrictMode: false` may be preserved only when at
66
+ least one synced Responses or Completions model supports it; block other unproven
67
+ compatibility overrides. Recheck account/catalog/preferences and Settings evidence
68
+ before the one-shot write, then read back both user and effective values. Never create a profile,
66
69
  change other paths or perform this sync automatically.
67
70
 
68
71
  The user-confirmed direction on 2026-11-14 supersedes conflicting legacy feature
package/CHANGELOG.md CHANGED
@@ -1,11 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0-alpha.10.dsh.0.2.2.rc.3 (prepared)
3
+ ## 0.1.0-alpha.11.dsh.0.2.2.rc.3 (prepared)
4
+
5
+ - Show native model-list changes and output defaults automatically from current verified account metadata; one **Sync models** action explicitly confirms the write (#479).
6
+ - Preserve an existing disabled native strict-mode override when the synced list contains a supporting Responses or Completions model; unproven overrides remain blocked.
7
+ - Recheck account, catalog, preference and plan-expiry evidence immediately before writing; keep revision and readback fences.
8
+ - Preparation does not force discovery, and sync, profile installation and Desktop restart remain explicit.
9
+
10
+ ## 0.1.0-alpha.10.dsh.0.2.2.rc.3 (published)
4
11
 
5
12
  - Allow an explicit native Copilot hosted-search model in plugin settings, with account and native catalog filtering (#478).
6
13
  - Preserve automatic selection by default, require the existing search capability proof, and fail without switching if a chosen model is unavailable.
7
14
 
8
- ## 0.1.0-alpha.9.dsh.0.2.2.rc.3 (prepared)
15
+ ## 0.1.0-alpha.9.dsh.0.2.2.rc.3 (published)
9
16
 
10
17
  - Apply confirmed account switches to DSH's existing native `github-copilot` credential, preserving the replaced grant and protecting observable in-progress native Agent turns.
11
18
  - Allow #466 native model sync for a saved-account selection only when its normalized grant matches the native canonical credential; mismatches and unavailable credentials remain blocked.
package/README.md CHANGED
@@ -67,15 +67,15 @@ After the exact compatible release is available and verified, download its
67
67
  original asset and checksum in an empty directory:
68
68
 
69
69
  ```sh
70
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.10.dsh.0.2.2.rc.3.tgz
71
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/SHA256SUMS
70
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.11.dsh.0.2.2.rc.3.tgz
71
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/SHA256SUMS
72
72
  sha256sum --check SHA256SUMS
73
73
  ```
74
74
 
75
75
  For the `web` profile, install the same Release asset:
76
76
 
77
77
  ```sh
78
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.10.dsh.0.2.2.rc.3.tgz
78
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.11.dsh.0.2.2.rc.3.tgz
79
79
  ```
80
80
 
81
81
  Choose the intended profile explicitly. Then:
@@ -93,10 +93,12 @@ The plugin's account-discovered models and capabilities apply to the
93
93
  own bundled or configured catalog; the two routes do not automatically share
94
94
  model discovery.
95
95
 
96
- To copy enabled models from the current canonical account into an existing
97
- native provider, use **Manage → Model preferences → Preview enabled models**,
98
- review the additions, updates, removals, skipped models and per-request output
99
- defaults, then choose **Apply sync**. This one-time snapshot replaces only
96
+ To copy enabled models from the verified account used by the native provider into an existing
97
+ native provider, open **Manage → Model preferences**, review the displayed
98
+ additions, updates, removals, skipped models and per-request output defaults,
99
+ then choose **Sync models**. Preparing the display uses the current verified
100
+ account snapshot without forcing discovery; if it is unavailable, use
101
+ **Refresh models**. This one-time snapshot replaces only
100
102
  `llm-pi-ai.providers.github-copilot.models` with Settings CAS and readback.
101
103
  The nonempty saved list replaces the native built-in catalog and remains after
102
104
  the plugin is unloaded or uninstalled. Copying model settings does not transfer
@@ -109,8 +111,10 @@ New Completions and Anthropic models without a native catalog compatibility
109
111
  baseline are also skipped; catalog-backed models retain native compatibility.
110
112
  Image models are included only when the account explicitly supports all four
111
113
  native request formats: PNG, JPEG, WebP, and GIF. Custom native authentication,
112
- endpoints, headers, nonempty model overrides, or route compatibility overrides
113
- block sync rather than changing those settings. An existing native default
114
+ endpoints, headers, nonempty model overrides, or unproven route compatibility
115
+ overrides block sync rather than changing those settings. An existing
116
+ `compat.supportsStrictMode: false` is preserved when at least one synced
117
+ Responses or Completions model supports that native override. An existing native default
114
118
  reasoning effort must also be supported by each synced model. Core uses each
115
119
  configured `maxTokens` as that model's per-request output default. The sync does
116
120
  not change credentials, select a model, alter history, or automatically follow
package/README.zh.md CHANGED
@@ -55,15 +55,15 @@ node scripts/select-core-release.mjs 0.2.2-rc.3
55
55
  精确兼容版本发布且通过验证后,在空目录下载原始制品并校验:
56
56
 
57
57
  ```sh
58
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.10.dsh.0.2.2.rc.3.tgz
59
- curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/SHA256SUMS
58
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.11.dsh.0.2.2.rc.3.tgz
59
+ curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/SHA256SUMS
60
60
  sha256sum --check SHA256SUMS
61
61
  ```
62
62
 
63
63
  例如安装到 `web` profile:
64
64
 
65
65
  ```sh
66
- dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.10.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.10.dsh.0.2.2.rc.3.tgz
66
+ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.11.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.11.dsh.0.2.2.rc.3.tgz
67
67
  ```
68
68
 
69
69
  请明确选择目标 profile,然后:
@@ -77,17 +77,20 @@ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/release
77
77
  插件自动发现的账号模型及能力适用于 `github-copilot-preview` 路线;DSH 原生
78
78
  `github-copilot` 路线使用自己的内置或用户配置目录,两条路线不会自动共享模型发现结果。
79
79
 
80
- 如需将当前 canonical 账号的已启用模型复制到已配置的原生 provider,请选择
81
- **Manage → Model preferences → Preview enabled models**,检查新增、更新、移除、
82
- 跳过项和每次请求的输出默认值,然后选择 **Apply sync**。此显式单次快照只通过
80
+ 如需将原生 provider 所用的已验证账号的启用模型复制到已配置的原生 provider,请打开
81
+ **Manage → Model preferences**,查看显示的新增、更新、移除、跳过项和每次请求的输出
82
+ 默认值,然后选择 **Sync models**。页面使用当前已验证的账号快照准备这些信息,不强制
83
+ 重新发现;如果快照不可用,请使用 **Refresh models**。此显式单次快照只通过
83
84
  Settings CAS 和回读替换 `llm-pi-ai.providers.github-copilot.models`。原生 profile
84
85
  中保存的非空列表会替代原生内置目录,卸载或停用插件后仍然保留。复制模型设置不会将
85
86
  托管路线的图像准入检查或工具 schema 过滤迁移到原生请求,也不能证明供应商调用成功。
86
87
  无法证明或与原生目录不兼容的协议、未知或更窄的服务端输入上限、未知上下文或图像支持,
87
88
  以及未知或不支持的推理控制会被跳过,不会猜测。缺少原生目录兼容性基线的新 Completions 和
88
89
  Anthropic 模型也会被跳过;已有目录模型保留原生兼容性。只有账号明确支持 PNG、JPEG、WebP、GIF 四种原生请求图像格式时,
89
- 才会同步图像模型。原生 provider 存在自定义认证、端点、请求头、非空模型覆盖或路线兼容性覆盖时,
90
- 同步会停止,不会修改这些设置;已有的原生默认推理级别也必须受模型支持。Core 会将配置的
90
+ 才会同步图像模型。原生 provider 存在自定义认证、端点、请求头、非空模型覆盖或无法验证的
91
+ 路线兼容性覆盖时,同步会停止,不会修改这些设置。已有的 `compat.supportsStrictMode: false`
92
+ 会保留,但至少一个同步模型必须使用支持该设置的 Responses 或 Completions 协议。已有的
93
+ 原生默认推理级别也必须受模型支持。Core 会将配置的
91
94
  `maxTokens` 同时作为模型的单次请求输出默认值。同步不修改凭据、选择或历史,也不会自动
92
95
  跟随后续账号变化。
93
96
 
@@ -8,14 +8,14 @@
8
8
  },
9
9
  "package": {
10
10
  "name": "dsh-github-copilot",
11
- "version": "0.1.0-alpha.10.dsh.0.2.2.rc.3"
11
+ "version": "0.1.0-alpha.11.dsh.0.2.2.rc.3"
12
12
  },
13
13
  "releaseLines": [
14
14
  { "core": "0.2.0-rc.2", "version": "0.4.2-alpha.15", "status": "published" },
15
15
  { "core": "0.2.1-alpha.4", "version": "0.4.2-alpha.16", "status": "published" },
16
16
  { "core": "0.2.1-alpha.5", "version": "0.1.0-alpha.2.dsh.0.2.1.alpha.5", "status": "published" },
17
17
  { "core": "0.2.1-rc.3", "version": "0.1.0-alpha.5.dsh.0.2.1.rc.3", "status": "published" },
18
- { "core": "0.2.2-rc.3", "version": "0.1.0-alpha.10.dsh.0.2.2.rc.3", "status": "pending" }
18
+ { "core": "0.2.2-rc.3", "version": "0.1.0-alpha.11.dsh.0.2.2.rc.3", "status": "pending" }
19
19
  ],
20
20
  "evidence": {
21
21
  "kind": "source-and-synthetic-test-inventory",
@@ -750,13 +750,14 @@
750
750
  {
751
751
  "id": "confirmed-native-model-sync",
752
752
  "required": true,
753
- "activation": "explicit-preview-and-one-shot-confirmation",
753
+ "activation": "visible-nonforcing-preview-and-one-shot-confirmation",
754
754
  "evidenceScope": "tagged-native-settings-and-resolution-with-synthetic-catalog-proof-plus-separate-adapter-ownership-tests-not-live-provider",
755
755
  "sourceMarkers": [
756
756
  {"file": "src/native-model-sync.ts", "marker": "NATIVE_INHERITED_API_MISMATCH"},
757
757
  {"file": "src/native-copilot-access.ts", "marker": "captureNativeCopilotCatalog"},
758
758
  {"file": "src/authorization-controller.ts", "marker": "path: ['providers', GITHUB_COPILOT_PROVIDER_ID, 'models']"},
759
- {"file": "src/model-preferences-card.ts", "marker": "Preview enabled models"},
759
+ {"file": "src/model-preferences-card.ts", "marker": "Sync models"},
760
+ {"file": "src/authorization-controller.ts", "marker": "nativeSyncSupportsRouteCompatibility"},
760
761
  {"file": "src/remote.ts", "marker": "GitHubCopilotNativeModelSyncPreviewSchema"}
761
762
  ],
762
763
  "tests": [
@@ -772,9 +773,15 @@
772
773
  {"file": "tests/native-copilot-access.spec.ts", "name": "exposes the proven unfiltered adapter catalog independently of the configured model list"},
773
774
  {"file": "tests/native-copilot-access.spec.ts", "name": "revokes a catalog snapshot when its native Loader entry is removed"},
774
775
  {"file": "tests/authorization-controller.spec.ts", "name": "previews enabled canonical models and applies only the confirmed native models path with CAS/readback"},
776
+ {"file": "tests/authorization-controller.spec.ts", "name": "prepares from existing account proof without discovery or credential reads"},
777
+ {"file": "tests/authorization-controller.spec.ts", "name": "preserves the native disabled strict-mode override while syncing supported protocols"},
778
+ {"file": "tests/authorization-controller.spec.ts", "name": "blocks disabled strict-mode compatibility if no synced model has a supporting protocol"},
779
+ {"file": "tests/authorization-controller.spec.ts", "name": "rejects a preference change while checking the native credential before writing"},
780
+ {"file": "tests/authorization-controller.spec.ts", "name": "rejects a plan that expires while checking the native credential before writing"},
775
781
  {"file": "tests/authorization-controller.spec.ts", "name": "reports an uncertain commit if the proven native catalog changes during the write"},
776
- {"file": "tests/model-preferences-card.spec.ts", "name": "previews a native model sync and applies it only after the explicit confirmation action"},
777
- {"file": "tests/model-preferences-card.spec.ts", "name": "does not dispatch duplicate preview or apply actions before React renders the busy state"},
782
+ {"file": "tests/model-preferences-card.spec.ts", "name": "shows sync changes beside the model list and applies them with one explicit action"},
783
+ {"file": "tests/model-preferences-card.spec.ts", "name": "does not dispatch duplicate sync actions before React renders the busy state"},
784
+ {"file": "tests/model-preferences-card.spec.ts", "name": "allows model edits while preparing and ignores the superseded plan"},
778
785
  {"file": "tests/remote-codec.spec.ts", "name": "accepts named native-sync safety diagnostics without accepting extra fields"},
779
786
  {"file": "tests/fixtures/remote-core.fixture.ts", "name": "binds native model sync through actual Client and %s Host gateways"},
780
787
  {"file": "tests/fixtures/native-model-sync-core.fixture.ts", "name": "syncs a confirmed snapshot through real native Settings and model resolution across restart using synthetic catalog proof"}
package/lib/client.js CHANGED
@@ -7703,6 +7703,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7703
7703
  }],
7704
7704
  result: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelPreferencesView", GitHubCopilotModelPreferencesViewSchema)
7705
7705
  },
7706
+ {
7707
+ id: "dsh-github-copilot:githubCopilot.prepareNativeModelSync",
7708
+ service: "githubCopilotAuthorization",
7709
+ namespace: "githubCopilot",
7710
+ method: "prepareNativeModelSync",
7711
+ invocation: direct,
7712
+ parameters: [],
7713
+ result: strictRemoteCodec("dsh-github-copilot#GitHubCopilotNativeModelSyncPreview", GitHubCopilotNativeModelSyncPreviewSchema)
7714
+ },
7706
7715
  {
7707
7716
  id: "dsh-github-copilot:githubCopilot.previewNativeModelSync",
7708
7717
  service: "githubCopilotAuthorization",
@@ -7749,7 +7758,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7749
7758
  };
7750
7759
  //#endregion
7751
7760
  //#region package.json
7752
- var version = "0.1.0-alpha.10.dsh.0.2.2.rc.3";
7761
+ var version = "0.1.0-alpha.11.dsh.0.2.2.rc.3";
7753
7762
  //#endregion
7754
7763
  //#region lib/types/diagnostics-client.js
7755
7764
  let owner;
@@ -13283,10 +13292,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13283
13292
  }
13284
13293
  function nativeSyncMessage(code) {
13285
13294
  switch (code) {
13286
- case "NATIVE_MODEL_SYNC_ACCOUNT_MISMATCH": return "Switch the global Copilot account to the canonical account used by the native provider, then preview again.";
13295
+ case "NATIVE_MODEL_SYNC_ACCOUNT_MISMATCH": return "Could not confirm the selected Copilot account matches the native provider. Review the account before syncing.";
13287
13296
  case "NATIVE_MODEL_SYNC_ACCOUNT_UNAVAILABLE": return "Could not verify the current Copilot account. No native settings were changed.";
13288
13297
  case "NATIVE_MODEL_SYNC_DISCOVERY_UNAVAILABLE":
13289
- case "NATIVE_MODEL_SYNC_MODELS_UNAVAILABLE": return "Could not verify a fresh account model list. No native settings were changed.";
13298
+ case "NATIVE_MODEL_SYNC_MODELS_UNAVAILABLE": return "Could not verify the current account model list. Use Refresh models before syncing.";
13290
13299
  case "NATIVE_MODEL_SYNC_NATIVE_CATALOG_UNAVAILABLE": return "Could not verify the native provider and its model catalog. No native settings were changed.";
13291
13300
  case "NATIVE_MODEL_SYNC_PREFERENCES_UNAVAILABLE": return "Could not verify the enabled-model preferences. No native settings were changed.";
13292
13301
  case "NATIVE_MODEL_SYNC_SETTINGS_UNAVAILABLE": return "Could not read native provider settings. No changes were made.";
@@ -13298,8 +13307,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13298
13307
  case "NATIVE_MODEL_SYNC_ROUTE_COMPAT_UNPROVEN": return "Native route compatibility overrides cannot be verified for the new model list. Review them before syncing.";
13299
13308
  case "NATIVE_MODEL_SYNC_NO_SYNCABLE_MODELS": return "No enabled account models can be represented by the native provider configuration.";
13300
13309
  case "NATIVE_MODEL_SYNC_PLAN_EXPIRED":
13301
- case "NATIVE_MODEL_SYNC_PLAN_STALE": return "The preview is no longer current. Preview the model list again before syncing.";
13302
- case "NATIVE_MODEL_SYNC_SETTINGS_CONFLICT": return "Native settings changed elsewhere. Review the current settings and preview again.";
13310
+ case "NATIVE_MODEL_SYNC_PLAN_STALE": return "The model list changed or expired. Review the refreshed changes before syncing again.";
13311
+ case "NATIVE_MODEL_SYNC_SETTINGS_CONFLICT": return "Native settings changed elsewhere. Review the refreshed changes before syncing again.";
13303
13312
  case "NATIVE_MODEL_SYNC_READBACK_FAILED":
13304
13313
  case "NATIVE_MODEL_SYNC_SAVE_FAILED": return "Could not confirm the native settings update. Read the saved settings before trying again.";
13305
13314
  default: return "Native model sync is unavailable. No settings were changed.";
@@ -13330,8 +13339,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13330
13339
  const [queuedModels, setQueuedModels] = (0, react.useState)([]);
13331
13340
  const [error, setError] = (0, react.useState)();
13332
13341
  const [errorModel, setErrorModel] = (0, react.useState)();
13342
+ const [expanded, setExpanded] = (0, react.useState)(false);
13333
13343
  const [syncPreview, setSyncPreview] = (0, react.useState)();
13334
- const [syncBusy, setSyncBusy] = (0, react.useState)(false);
13344
+ const [syncPreparing, setSyncPreparing] = (0, react.useState)(false);
13345
+ const [syncApplying, setSyncApplying] = (0, react.useState)(false);
13346
+ const [syncNeedsReadback, setSyncNeedsReadback] = (0, react.useState)(false);
13347
+ const [syncCheckEpoch, setSyncCheckEpoch] = (0, react.useState)(0);
13335
13348
  const [syncError, setSyncError] = (0, react.useState)();
13336
13349
  const [syncResult, setSyncResult] = (0, react.useState)();
13337
13350
  const request = (0, react.useRef)({
@@ -13343,22 +13356,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13343
13356
  active: ""
13344
13357
  });
13345
13358
  const syncPending = (0, react.useRef)(false);
13359
+ const syncGeneration = (0, react.useRef)(0);
13360
+ const mounted = (0, react.useRef)(true);
13346
13361
  const metadata = (0, react.useRef)(props.models);
13347
13362
  metadata.current = props.models;
13348
13363
  const preferenceKey = JSON.stringify(props.preferences);
13364
+ (0, react.useEffect)(() => {
13365
+ mounted.current = true;
13366
+ return () => {
13367
+ mounted.current = false;
13368
+ };
13369
+ }, []);
13349
13370
  (0, react.useEffect)(() => {
13350
13371
  const scope = request.current;
13351
13372
  scope.generation++;
13352
13373
  scope.pending = false;
13353
13374
  scope.failed = scope.cancelled;
13354
13375
  scope.active = "";
13355
- syncPending.current = false;
13356
13376
  setPreferences(props.preferences);
13357
13377
  setError(scope.cancelled ? "COPILOT_MODEL_PREFERENCE_EDITS_CANCELLED" : void 0);
13358
13378
  setSyncPreview(void 0);
13359
- setSyncError(void 0);
13360
13379
  setSyncResult(void 0);
13361
- setSyncBusy(false);
13380
+ if (!syncNeedsReadback) setSyncError(void 0);
13362
13381
  scope.cancelled = false;
13363
13382
  setErrorModel(void 0);
13364
13383
  setBusyModel(void 0);
@@ -13379,75 +13398,122 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13379
13398
  const excluded = new Set(preferences?.excludedModelIds ?? []);
13380
13399
  const diagnostic = error ?? preferences?.error ?? (preferences === void 0 ? "COPILOT_MODEL_PREFERENCES_UNAVAILABLE" : void 0);
13381
13400
  const writable = preferences?.writable === true && settingsKnown;
13382
- const nativeSyncDisabled = !writable || request.current.failed || busyModel !== void 0 || queuedModels.length > 0 || syncBusy;
13383
- const previewNativeSync = async () => {
13401
+ const modelKey = JSON.stringify(models);
13402
+ const incomingModelKey = JSON.stringify(props.models);
13403
+ const localPreferenceKey = JSON.stringify(preferences);
13404
+ const syncInputKey = JSON.stringify([
13405
+ props.models,
13406
+ models,
13407
+ props.preferences,
13408
+ preferences
13409
+ ]);
13410
+ const syncInputs = (0, react.useRef)(syncInputKey);
13411
+ const previewInputs = (0, react.useRef)();
13412
+ syncInputs.current = syncInputKey;
13413
+ const nativeSyncDisabled = !writable || !availabilityKnown || request.current.failed || busyModel !== void 0 || queuedModels.length > 0 || syncPreparing || syncApplying || syncNeedsReadback || syncPreview?.state !== "ready" || syncPreview.planId === void 0 || previewInputs.current !== syncInputKey;
13414
+ (0, react.useEffect)(() => {
13415
+ let active = true;
13384
13416
  const scope = request.current;
13385
- if (nativeSyncDisabled || syncPending.current || scope.pending) return;
13386
13417
  const generation = scope.generation;
13387
- const current = () => scope.generation === generation;
13388
- syncPending.current = true;
13389
- setSyncBusy(true);
13390
- setSyncError(void 0);
13391
- setSyncResult(void 0);
13418
+ const preparation = ++syncGeneration.current;
13419
+ const current = () => active && scope.generation === generation && syncGeneration.current === preparation && syncInputs.current === syncInputKey && !scope.pending && !syncPending.current;
13392
13420
  setSyncPreview(void 0);
13393
- try {
13394
- const result = await props.remote.previewNativeModelSync();
13395
- if (!current()) return;
13396
- if (!result.ok) {
13397
- setSyncError("NATIVE_MODEL_SYNC_DISCOVERY_UNAVAILABLE");
13398
- return;
13399
- }
13400
- const parsed = GitHubCopilotNativeModelSyncPreviewSchema.safeParse(result.value);
13401
- if (!parsed.success) {
13402
- setSyncError("NATIVE_MODEL_SYNC_SAVE_FAILED");
13403
- return;
13404
- }
13405
- setSyncPreview(parsed.data);
13406
- if (parsed.data.state !== "ready") setSyncError(parsed.data.code ?? "NATIVE_MODEL_SYNC_SAVE_FAILED");
13407
- } catch {
13408
- if (current()) setSyncError("NATIVE_MODEL_SYNC_DISCOVERY_UNAVAILABLE");
13409
- } finally {
13410
- if (current()) {
13411
- syncPending.current = false;
13412
- setSyncBusy(false);
13413
- }
13421
+ if (!expanded || !writable || !availabilityKnown || scope.failed || scope.pending || busyModel !== void 0 || queuedModels.length > 0 || syncApplying || syncNeedsReadback) {
13422
+ setSyncPreparing(false);
13423
+ return () => {
13424
+ active = false;
13425
+ };
13414
13426
  }
13415
- };
13427
+ setSyncPreparing(true);
13428
+ setSyncError(void 0);
13429
+ (async () => {
13430
+ try {
13431
+ const result = await props.remote.prepareNativeModelSync();
13432
+ if (!current()) return;
13433
+ if (!result.ok) {
13434
+ setSyncError("NATIVE_MODEL_SYNC_DISCOVERY_UNAVAILABLE");
13435
+ return;
13436
+ }
13437
+ const parsed = GitHubCopilotNativeModelSyncPreviewSchema.safeParse(result.value);
13438
+ if (!parsed.success || parsed.data.state === "ready" && parsed.data.planId === void 0) {
13439
+ setSyncError("NATIVE_MODEL_SYNC_SETTINGS_INVALID");
13440
+ return;
13441
+ }
13442
+ if (parsed.data.state === "ready" || parsed.data.code === "NATIVE_MODEL_SYNC_NO_SYNCABLE_MODELS") {
13443
+ previewInputs.current = syncInputKey;
13444
+ setSyncPreview(parsed.data);
13445
+ }
13446
+ if (parsed.data.state !== "ready") setSyncError(parsed.data.code ?? "NATIVE_MODEL_SYNC_SETTINGS_INVALID");
13447
+ } catch {
13448
+ if (current()) setSyncError("NATIVE_MODEL_SYNC_DISCOVERY_UNAVAILABLE");
13449
+ } finally {
13450
+ if (current()) setSyncPreparing(false);
13451
+ }
13452
+ })();
13453
+ return () => {
13454
+ active = false;
13455
+ };
13456
+ }, [
13457
+ expanded,
13458
+ writable,
13459
+ availabilityKnown,
13460
+ modelKey,
13461
+ incomingModelKey,
13462
+ localPreferenceKey,
13463
+ preferenceKey,
13464
+ syncInputKey,
13465
+ props.remote,
13466
+ busyModel,
13467
+ queuedModels.length,
13468
+ syncApplying,
13469
+ syncNeedsReadback,
13470
+ syncCheckEpoch
13471
+ ]);
13416
13472
  const applyNativeSync = async () => {
13417
13473
  const planId = syncPreview?.planId;
13418
13474
  const scope = request.current;
13419
- if (planId === void 0 || syncBusy || busyModel !== void 0 || syncPending.current || scope.pending) return;
13475
+ if (planId === void 0 || nativeSyncDisabled || syncPending.current || scope.pending) return;
13420
13476
  const generation = scope.generation;
13421
- const current = () => scope.generation === generation;
13477
+ const current = () => scope.generation === generation && syncInputs.current === syncInputKey;
13422
13478
  syncPending.current = true;
13423
- setSyncBusy(true);
13479
+ syncGeneration.current++;
13480
+ setSyncApplying(true);
13424
13481
  setSyncError(void 0);
13425
13482
  setSyncResult(void 0);
13426
13483
  setSyncPreview(void 0);
13484
+ const uncertain = () => {
13485
+ setSyncNeedsReadback(true);
13486
+ setSyncError("NATIVE_MODEL_SYNC_SAVE_FAILED");
13487
+ };
13427
13488
  try {
13428
13489
  const result = await props.remote.applyNativeModelSync(planId);
13429
13490
  if (!current()) return;
13430
13491
  if (!result.ok) {
13431
- setSyncError("NATIVE_MODEL_SYNC_SAVE_FAILED");
13492
+ uncertain();
13432
13493
  return;
13433
13494
  }
13434
13495
  const parsed = GitHubCopilotNativeModelSyncResultSchema.safeParse(result.value);
13435
13496
  if (!parsed.success) {
13436
- setSyncError("NATIVE_MODEL_SYNC_SAVE_FAILED");
13497
+ uncertain();
13437
13498
  return;
13438
13499
  }
13439
13500
  if (parsed.data.state !== "ready") {
13440
- setSyncError(parsed.data.code ?? "NATIVE_MODEL_SYNC_SAVE_FAILED");
13501
+ const code = parsed.data.code ?? "NATIVE_MODEL_SYNC_SAVE_FAILED";
13502
+ if (code === "NATIVE_MODEL_SYNC_SAVE_FAILED" || code === "NATIVE_MODEL_SYNC_READBACK_FAILED") {
13503
+ setSyncNeedsReadback(true);
13504
+ setSyncError(code);
13505
+ } else setSyncResult(nativeSyncMessage(code));
13441
13506
  return;
13442
13507
  }
13443
- setSyncPreview(void 0);
13444
13508
  setSyncResult(`Synced ${parsed.data.modelCount} models to the native provider settings. This does not select a model.`);
13445
13509
  } catch {
13446
- if (current()) setSyncError("NATIVE_MODEL_SYNC_SAVE_FAILED");
13510
+ if (current()) uncertain();
13447
13511
  } finally {
13448
- if (current()) {
13449
- syncPending.current = false;
13450
- setSyncBusy(false);
13512
+ syncPending.current = false;
13513
+ if (mounted.current) {
13514
+ setSyncApplying(false);
13515
+ if (!current()) uncertain();
13516
+ setSyncCheckEpoch((value) => value + 1);
13451
13517
  }
13452
13518
  }
13453
13519
  };
@@ -13525,11 +13591,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13525
13591
  const current = () => scope.generation === generation;
13526
13592
  if (modelId === void 0) {
13527
13593
  if (scope.pending) return;
13594
+ syncGeneration.current++;
13595
+ setSyncPreview(void 0);
13596
+ setSyncResult(void 0);
13528
13597
  scope.pending = true;
13529
13598
  const succeeded = await save();
13530
13599
  if (current()) {
13531
13600
  scope.pending = false;
13532
13601
  scope.failed = !succeeded;
13602
+ setSyncCheckEpoch((value) => value + 1);
13533
13603
  }
13534
13604
  return;
13535
13605
  }
@@ -13539,6 +13609,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13539
13609
  setErrorModel(modelId);
13540
13610
  return;
13541
13611
  }
13612
+ syncGeneration.current++;
13613
+ setSyncPreview(void 0);
13614
+ setSyncResult(void 0);
13542
13615
  const completed = new Promise((resolve) => {
13543
13616
  scope.queue.push({
13544
13617
  modelId,
@@ -13565,13 +13638,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13565
13638
  break;
13566
13639
  }
13567
13640
  }
13568
- if (current()) scope.pending = false;
13641
+ if (current()) {
13642
+ scope.pending = false;
13643
+ setSyncCheckEpoch((value) => value + 1);
13644
+ }
13569
13645
  })();
13570
13646
  }
13571
13647
  await completed;
13572
13648
  };
13573
13649
  return (0, react.createElement)("details", {
13574
13650
  "data-dsh-github-copilot-model-preferences": true,
13651
+ onToggle: (event) => setExpanded(event.currentTarget.open),
13575
13652
  "data-copilot-native-ui": true,
13576
13653
  style: nativeSettingsStyle
13577
13654
  }, (0, react.createElement)("style", null, nativeSettingsCss), (0, react.createElement)("summary", null, settingsKnown ? `Model preferences · ${visibleCount} enabled · ${excluded.size} excluded` : "Model preferences · Read-only"), (0, react.createElement)("p", { style: {
@@ -13588,15 +13665,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13588
13665
  }, (0, react.createElement)("strong", null, "Native provider model list"), (0, react.createElement)("p", { style: {
13589
13666
  ...nativeCaptionStyle,
13590
13667
  margin: 0
13591
- } }, "Preview a one-time sync of enabled models from the current canonical account. The sync replaces only the native model list, skips entries the native route cannot represent, and never changes credentials, model selection, or conversation history. Core also uses each configured maxTokens as that model’s per-request default; review the exact output values before applying."), (0, react.createElement)("button", {
13592
- type: "button",
13593
- style: controlStyle,
13594
- disabled: nativeSyncDisabled,
13595
- onClick: () => void previewNativeSync(),
13596
- "data-dsh-github-copilot-native-model-sync-preview": true
13597
- }, syncBusy ? "Preparing sync…" : "Preview enabled models"), syncPreview === void 0 ? null : (0, react.createElement)("div", {
13668
+ } }, "Sync enabled models from the verified account used by the native provider. The native provider’s built-in catalog is replaced by this saved list, which remains after the plugin is unloaded or uninstalled. Credentials, model selection, and conversation history do not change; managed image admission checks and tool-schema filtering do not transfer."), syncPreparing ? (0, react.createElement)("p", {
13669
+ role: "status",
13670
+ style: {
13671
+ ...nativeCaptionStyle,
13672
+ margin: 0
13673
+ }
13674
+ }, "Checking the current model list…") : !availabilityKnown ? (0, react.createElement)("p", {
13675
+ role: "status",
13676
+ style: {
13677
+ ...nativeCaptionStyle,
13678
+ margin: 0
13679
+ }
13680
+ }, "Use Refresh models to verify the current account model list before syncing.") : null, syncPreview === void 0 ? null : (0, react.createElement)("div", {
13598
13681
  role: "region",
13599
- "aria-label": "Native model sync preview",
13682
+ "aria-label": "Native model sync changes",
13600
13683
  "data-dsh-github-copilot-native-model-sync-preview-result": true,
13601
13684
  style: {
13602
13685
  display: "grid",
@@ -13605,28 +13688,40 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13605
13688
  }, (0, react.createElement)("p", { style: {
13606
13689
  ...nativeCaptionStyle,
13607
13690
  margin: 0
13608
- } }, "Applying replaces the native provider’s built-in catalog with this saved list, which remains after the plugin is unloaded or uninstalled. The managed route’s image admission checks and tool-schema filtering do not transfer to the native route."), (0, react.createElement)("p", { style: {
13609
- ...nativeCaptionStyle,
13610
- margin: 0
13611
- } }, `${syncPreview.syncableCount} of ${syncPreview.enabledCount} enabled models will be written; ${syncPreview.addedIds.length} added, ${syncPreview.updatedIds.length} updated, ${syncPreview.removedIds.length} removed from the native list, ${syncPreview.skipped.length} skipped.`), syncPreview.addedIds.length === 0 ? null : (0, react.createElement)("details", null, (0, react.createElement)("summary", null, "Models to add"), (0, react.createElement)("ul", null, ...syncPreview.addedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.updatedIds.length === 0 ? null : (0, react.createElement)("details", null, (0, react.createElement)("summary", null, "Models to update"), (0, react.createElement)("ul", null, ...syncPreview.updatedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.outputTokenDefaults.length === 0 ? null : (0, react.createElement)("details", null, (0, react.createElement)("summary", null, `Per-request output defaults (${syncPreview.outputTokenDefaults.length})`), (0, react.createElement)("ul", null, ...syncPreview.outputTokenDefaults.map((item) => (0, react.createElement)("li", { key: item.id }, (0, react.createElement)("code", null, item.id), ` — ${item.maxTokens.toLocaleString()} max output tokens`)))), syncPreview.skipped.length === 0 ? null : (0, react.createElement)("details", null, (0, react.createElement)("summary", null, "Models skipped by native compatibility checks"), (0, react.createElement)("ul", null, ...syncPreview.skipped.map((item) => (0, react.createElement)("li", { key: item.id }, (0, react.createElement)("code", null, item.id), ` — ${nativeSyncSkipMessage(item.code)} (${item.code})`)))), syncPreview.removedIds.length === 0 ? null : (0, react.createElement)("details", null, (0, react.createElement)("summary", null, "Native models that will be removed"), (0, react.createElement)("ul", null, ...syncPreview.removedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.state === "ready" ? (0, react.createElement)("div", { style: {
13612
- display: "flex",
13613
- flexWrap: "wrap",
13614
- gap: "8px"
13615
- } }, (0, react.createElement)("button", {
13691
+ } }, `${syncPreview.syncableCount} of ${syncPreview.enabledCount} enabled models will be written; ${syncPreview.addedIds.length} added, ${syncPreview.updatedIds.length} updated, ${syncPreview.removedIds.length} removed from the native list, ${syncPreview.skipped.length} skipped.`), (0, react.createElement)("div", {
13692
+ role: "region",
13693
+ "aria-label": "Model changes and output defaults",
13694
+ tabIndex: 0,
13695
+ style: {
13696
+ maxHeight: "240px",
13697
+ overflowY: "auto",
13698
+ ...nativeCaptionStyle
13699
+ }
13700
+ }, syncPreview.removedIds.length === 0 ? null : (0, react.createElement)("div", null, (0, react.createElement)("strong", null, "Native models that will be removed"), (0, react.createElement)("ul", null, ...syncPreview.removedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.skipped.length === 0 ? null : (0, react.createElement)("div", null, (0, react.createElement)("strong", null, "Models skipped by native compatibility checks"), (0, react.createElement)("ul", null, ...syncPreview.skipped.map((item) => (0, react.createElement)("li", { key: item.id }, (0, react.createElement)("code", null, item.id), ` — ${nativeSyncSkipMessage(item.code)} (${item.code})`)))), syncPreview.addedIds.length === 0 ? null : (0, react.createElement)("div", null, (0, react.createElement)("strong", null, "Models to add"), (0, react.createElement)("ul", null, ...syncPreview.addedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.updatedIds.length === 0 ? null : (0, react.createElement)("div", null, (0, react.createElement)("strong", null, "Models to update"), (0, react.createElement)("ul", null, ...syncPreview.updatedIds.map((id) => (0, react.createElement)("li", { key: id }, (0, react.createElement)("code", null, id))))), syncPreview.outputTokenDefaults.length === 0 ? null : (0, react.createElement)("div", null, (0, react.createElement)("strong", null, `Per-request output defaults (${syncPreview.outputTokenDefaults.length})`), (0, react.createElement)("ul", null, ...syncPreview.outputTokenDefaults.map((item) => (0, react.createElement)("li", { key: item.id }, (0, react.createElement)("code", null, item.id), ` — ${item.maxTokens.toLocaleString()} max output tokens`)))))), (0, react.createElement)("button", {
13616
13701
  type: "button",
13617
- style: controlStyle,
13618
- disabled: syncBusy || busyModel !== void 0,
13702
+ style: {
13703
+ ...controlStyle,
13704
+ justifySelf: "start"
13705
+ },
13706
+ disabled: nativeSyncDisabled,
13619
13707
  onClick: () => void applyNativeSync(),
13620
13708
  "data-dsh-github-copilot-native-model-sync-apply": true
13621
- }, syncBusy ? "Syncing…" : "Apply sync"), (0, react.createElement)("button", {
13622
- type: "button",
13623
- style: controlStyle,
13624
- disabled: syncBusy,
13625
- onClick: () => setSyncPreview(void 0)
13626
- }, "Cancel")) : null), syncError === void 0 ? null : (0, react.createElement)("p", {
13709
+ }, syncApplying ? "Syncing…" : "Sync models"), syncError === void 0 ? null : (0, react.createElement)("p", {
13627
13710
  role: "alert",
13628
13711
  "data-dsh-github-copilot-native-model-sync-error": syncError
13629
- }, nativeSyncMessage(syncError)), syncResult === void 0 ? null : (0, react.createElement)("p", {
13712
+ }, nativeSyncMessage(syncError)), syncError === void 0 || syncPreparing || syncApplying ? null : (0, react.createElement)("button", {
13713
+ type: "button",
13714
+ style: {
13715
+ ...controlStyle,
13716
+ justifySelf: "start"
13717
+ },
13718
+ onClick: () => {
13719
+ setSyncError(void 0);
13720
+ setSyncNeedsReadback(false);
13721
+ setSyncCheckEpoch((value) => value + 1);
13722
+ },
13723
+ "data-dsh-github-copilot-native-model-sync-recheck": true
13724
+ }, syncNeedsReadback ? "Check saved settings" : "Retry check"), syncResult === void 0 ? null : (0, react.createElement)("p", {
13630
13725
  role: "status",
13631
13726
  "aria-live": "polite"
13632
13727
  }, syncResult)), availabilityKnown ? null : (0, react.createElement)("p", { role: "status" }, "Current account availability unconfirmed. Shown models reflect the last metadata snapshot and saved preferences, not a current availability check."), diagnostic === void 0 ? null : (0, react.createElement)("div", {
@@ -13639,7 +13734,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13639
13734
  }, (0, react.createElement)("p", null, preferenceMessage(diagnostic)), (0, react.createElement)("code", { style: { overflowWrap: "anywhere" } }, diagnostic), (0, react.createElement)("div", { style: { marginTop: "8px" } }, (0, react.createElement)("button", {
13640
13735
  type: "button",
13641
13736
  style: controlStyle,
13642
- disabled: busyModel !== void 0 || syncBusy,
13737
+ disabled: busyModel !== void 0 || syncApplying,
13643
13738
  onClick: () => update(),
13644
13739
  "data-dsh-github-copilot-preferences-retry": true
13645
13740
  }, busyModel === "" ? "Reading settings…" : "Retry"))), (0, react.createElement)("label", { style: {
@@ -13696,7 +13791,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13696
13791
  }
13697
13792
  }, filtered.map((model) => {
13698
13793
  const isExcluded = excluded.has(model.id);
13699
- const disabled = !writable || request.current.failed || syncBusy || busyModel === "" || busyModel === model.id || queuedModels.includes(model.id);
13794
+ const disabled = !writable || request.current.failed || syncApplying || busyModel === "" || busyModel === model.id || queuedModels.includes(model.id);
13700
13795
  return (0, react.createElement)("li", {
13701
13796
  key: model.id,
13702
13797
  style: {