dsh-github-copilot 0.4.0-alpha.66 → 0.4.0-alpha.69

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/lib/client.js CHANGED
@@ -7052,6 +7052,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7052
7052
  };
7053
7053
  }, [load]);
7054
7054
  const usesCopilot = draft.primary === GITHUB_COPILOT_SEARCH_PROVIDER || draft.provider === GITHUB_COPILOT_SEARCH_PROVIDER;
7055
+ (0, react.useEffect)(() => {
7056
+ const revision = props.settingsRevision;
7057
+ if (!revision) return;
7058
+ setDraft((value) => value.routingRevision === revision.previous ? {
7059
+ ...value,
7060
+ routingRevision: revision.next
7061
+ } : value);
7062
+ setOverride((value) => value.revision === revision.previous ? {
7063
+ ...value,
7064
+ revision: revision.next
7065
+ } : value);
7066
+ }, [props.settingsRevision]);
7055
7067
  const disabled = loading || saving !== void 0 || !writable || draft.routingRevision === void 0 || !catalogReady;
7056
7068
  const primaryKnown = draft.primary === "auto" || draft.primary === "none" || providers.includes(draft.primary);
7057
7069
  const fallbackKnown = draft.provider === "none" || providers.includes(draft.provider);
@@ -7293,6 +7305,207 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7293
7305
  }, message));
7294
7306
  }
7295
7307
  //#endregion
7308
+ //#region lib/types/parent-model-follow-card.js
7309
+ const ns = "github-copilot";
7310
+ const button$1 = {
7311
+ font: "inherit",
7312
+ color: "inherit",
7313
+ background: "transparent",
7314
+ padding: "8px 14px",
7315
+ border: "1px solid currentColor",
7316
+ borderRadius: "6px",
7317
+ minHeight: "40px"
7318
+ };
7319
+ async function readParentFollowSettings(settings) {
7320
+ const result = await settings.describe();
7321
+ if (!result.ok) throw new Error("Could not load subagent settings. Reload to retry.");
7322
+ const entry = result.value.namespaces.find((value) => value.ns === ns);
7323
+ const value = entry?.value;
7324
+ if (!entry || !Number.isSafeInteger(entry.revision) || entry.revision < 0 || typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("Subagent settings are unavailable. Reload after the plugin is active.");
7325
+ const enabled = Reflect.get(value, "followParentModel");
7326
+ const legacy = Reflect.get(value, "parentModelFollow");
7327
+ if (enabled !== void 0 && typeof enabled !== "boolean" || legacy !== void 0 && !Array.isArray(legacy)) throw new Error("Subagent settings are invalid. Review the saved configuration before editing.");
7328
+ return {
7329
+ enabled: enabled === true,
7330
+ revision: entry.revision,
7331
+ writable: result.value.writable === true,
7332
+ legacy: Array.isArray(legacy) && legacy.length > 0
7333
+ };
7334
+ }
7335
+ async function saveParentFollowSettings(settings, saved, enabled) {
7336
+ const current = await readParentFollowSettings(settings);
7337
+ if (!current.writable) throw new Error("Subagent settings are read-only in this deployment.");
7338
+ if (current.enabled !== saved.enabled) throw new Error("This setting changed elsewhere. Reload and review it before saving.");
7339
+ const result = await settings.mutate(ns, [{
7340
+ op: "set",
7341
+ path: ["followParentModel"],
7342
+ value: enabled
7343
+ }], current.revision);
7344
+ if (!result.ok) throw new Error("Could not confirm the save. Reload to check saved settings before retrying.");
7345
+ if (!Number.isSafeInteger(result.value.revision) || result.value.revision <= current.revision) throw new Error("Save returned no valid revision. Reload before editing again.");
7346
+ return {
7347
+ snapshot: {
7348
+ ...current,
7349
+ enabled,
7350
+ revision: result.value.revision
7351
+ },
7352
+ revision: {
7353
+ previous: current.revision,
7354
+ next: result.value.revision
7355
+ }
7356
+ };
7357
+ }
7358
+ function ParentModelFollowCard({ settings, onSaved }) {
7359
+ const [saved, setSaved] = (0, react.useState)();
7360
+ const [enabled, setEnabled] = (0, react.useState)(false);
7361
+ const [busy, setBusy] = (0, react.useState)(true);
7362
+ const [message, setMessage] = (0, react.useState)("");
7363
+ const [failed, setFailed] = (0, react.useState)(false);
7364
+ const lifecycle = (0, react.useRef)({
7365
+ active: false,
7366
+ generation: 0,
7367
+ busy: false
7368
+ });
7369
+ const descriptionId = (0, react.useId)();
7370
+ const load = async () => {
7371
+ const owner = lifecycle.current;
7372
+ if (!owner.active || owner.busy) return;
7373
+ const generation = owner.generation;
7374
+ owner.busy = true;
7375
+ setBusy(true);
7376
+ try {
7377
+ const next = await readParentFollowSettings(settings);
7378
+ if (!owner.active || owner.generation !== generation) return;
7379
+ setSaved(next);
7380
+ setEnabled(next.enabled);
7381
+ setFailed(false);
7382
+ setMessage(next.writable ? "" : "Subagent settings are read-only in this deployment.");
7383
+ } catch {
7384
+ if (owner.active && owner.generation === generation) {
7385
+ setFailed(true);
7386
+ setMessage("Could not load subagent settings. Reload to retry.");
7387
+ }
7388
+ } finally {
7389
+ if (owner.active && owner.generation === generation) {
7390
+ owner.busy = false;
7391
+ setBusy(false);
7392
+ }
7393
+ }
7394
+ };
7395
+ (0, react.useEffect)(() => {
7396
+ const owner = lifecycle.current;
7397
+ owner.active = true;
7398
+ load();
7399
+ return () => {
7400
+ owner.active = false;
7401
+ owner.generation++;
7402
+ owner.busy = false;
7403
+ };
7404
+ }, [settings]);
7405
+ const disabled = busy || failed || !saved?.writable;
7406
+ const save = async () => {
7407
+ const owner = lifecycle.current;
7408
+ if (disabled || !saved || owner.busy || enabled === saved.enabled) return;
7409
+ const generation = owner.generation;
7410
+ owner.busy = true;
7411
+ setBusy(true);
7412
+ setMessage("Saving…");
7413
+ try {
7414
+ const next = await saveParentFollowSettings(settings, saved, enabled);
7415
+ if (!owner.active || owner.generation !== generation) return;
7416
+ setSaved(next.snapshot);
7417
+ onSaved?.(next.revision);
7418
+ setMessage("Saved. Applies from each child’s next turn.");
7419
+ } catch {
7420
+ if (owner.active && owner.generation === generation) {
7421
+ setFailed(true);
7422
+ setMessage("Could not confirm the save. Reload to check for conflicts or read-only settings before retrying. Your choice has been kept.");
7423
+ }
7424
+ } finally {
7425
+ if (owner.active && owner.generation === generation) {
7426
+ owner.busy = false;
7427
+ setBusy(false);
7428
+ }
7429
+ }
7430
+ };
7431
+ return (0, react.createElement)("section", {
7432
+ "data-dsh-parent-model-follow": true,
7433
+ "aria-busy": busy,
7434
+ style: {
7435
+ padding: "18px",
7436
+ marginTop: "16px",
7437
+ display: "grid",
7438
+ gap: "14px",
7439
+ minWidth: 0
7440
+ }
7441
+ }, (0, react.createElement)("h3", { style: {
7442
+ margin: 0,
7443
+ fontSize: "16px"
7444
+ } }, "Subagent models"), (0, react.createElement)("label", { style: {
7445
+ display: "flex",
7446
+ gap: "12px",
7447
+ alignItems: "center",
7448
+ minHeight: "40px"
7449
+ } }, (0, react.createElement)("input", {
7450
+ type: "checkbox",
7451
+ role: "switch",
7452
+ checked: enabled,
7453
+ disabled,
7454
+ "aria-describedby": descriptionId,
7455
+ onChange: (event) => {
7456
+ setEnabled(event.currentTarget.checked);
7457
+ setMessage("Unsaved change.");
7458
+ }
7459
+ }), (0, react.createElement)("strong", null, "Follow parent model")), (0, react.createElement)("div", {
7460
+ id: descriptionId,
7461
+ style: {
7462
+ fontSize: "13px",
7463
+ lineHeight: 1.6,
7464
+ maxWidth: "70ch"
7465
+ }
7466
+ }, (0, react.createElement)("p", { style: { margin: 0 } }, "Apply to existing and new supported Copilot subagents and Team mates."), (0, react.createElement)("p", { style: { margin: "6px 0 0" } }, "Fixed parent: follow its model next turn. Auto parent: each child chooses using its own context."), (0, react.createElement)("p", { style: { margin: "6px 0 0" } }, "Running turns stay unchanged. Replaces creation-time model choices; a child’s own manual selection still wins.")), saved?.legacy ? (0, react.createElement)("p", {
7467
+ role: "note",
7468
+ style: {
7469
+ margin: 0,
7470
+ fontSize: "13px"
7471
+ }
7472
+ }, "Existing per-child bindings remain active even when this switch is off. They have not been changed.") : null, (0, react.createElement)("div", { style: {
7473
+ display: "flex",
7474
+ flexWrap: "wrap",
7475
+ gap: "12px"
7476
+ } }, (0, react.createElement)("button", {
7477
+ type: "button",
7478
+ style: {
7479
+ ...button$1,
7480
+ opacity: disabled || enabled === saved?.enabled ? .5 : 1
7481
+ },
7482
+ disabled: disabled || enabled === saved?.enabled,
7483
+ onClick: () => {
7484
+ save();
7485
+ }
7486
+ }, busy ? "Please wait…" : "Save"), (0, react.createElement)("button", {
7487
+ type: "button",
7488
+ style: {
7489
+ ...button$1,
7490
+ opacity: busy ? .5 : 1
7491
+ },
7492
+ disabled: busy,
7493
+ title: "Reload saved values and discard unsaved edits",
7494
+ onClick: () => {
7495
+ load();
7496
+ }
7497
+ }, "Reload")), (0, react.createElement)("p", {
7498
+ role: "status",
7499
+ "aria-live": "polite",
7500
+ "aria-atomic": true,
7501
+ style: {
7502
+ margin: 0,
7503
+ fontSize: "13px",
7504
+ lineHeight: 1.6
7505
+ }
7506
+ }, message || (busy ? "Loading subagent settings…" : "")));
7507
+ }
7508
+ //#endregion
7296
7509
  //#region lib/types/external-link.js
7297
7510
  /** Use Desktop's public v1 navigation handoff instead of WebView popup creation. */
7298
7511
  function externalLinkTarget() {
@@ -8987,6 +9200,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
8987
9200
  disposeFallback?.();
8988
9201
  };
8989
9202
  }
9203
+ function CopilotPluginSettingsPage(props) {
9204
+ const [revision, setRevision] = (0, react.useState)();
9205
+ return (0, react.createElement)("div", null, (0, react.createElement)(ParentModelFollowCard, {
9206
+ settings: props.settings,
9207
+ onSaved: setRevision
9208
+ }), (0, react.createElement)(WebSearchRoutingCard, {
9209
+ ...props,
9210
+ settingsRevision: revision
9211
+ }));
9212
+ }
8990
9213
  /** Optional search settings must never hold account authorization UI in waiting. */
8991
9214
  function registerSearchUi(ctx) {
8992
9215
  let active = true;
@@ -9039,7 +9262,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9039
9262
  dispose = ctx.slots.register({
9040
9263
  name: "plugins.bundle.config",
9041
9264
  key: "dsh-github-copilot"
9042
- }, ({ view }) => view === "page" ? render() : null);
9265
+ }, ({ view }) => view === "page" ? (0, react.createElement)(CopilotPluginSettingsPage, {
9266
+ settings,
9267
+ routing
9268
+ }) : null);
9043
9269
  } catch {
9044
9270
  ctx.logger.warn("[github-copilot] WEB_SEARCH_ROUTING_BUNDLE_UNAVAILABLE");
9045
9271
  return () => {};
@@ -9128,6 +9354,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9128
9354
  };
9129
9355
  }
9130
9356
  //#endregion
9357
+ exports.CopilotPluginSettingsPage = CopilotPluginSettingsPage;
9131
9358
  exports.CopilotUsageCard = CopilotUsageCard;
9132
9359
  exports.GitHubCopilotAccountModelsPanel = GitHubCopilotAccountModelsPanel;
9133
9360
  exports.GitHubCopilotAccountModelsSummary = GitHubCopilotAccountModelsSummary;
@@ -9140,6 +9367,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9140
9367
  exports.GitHubCopilotProviderCard = GitHubCopilotProviderCard;
9141
9368
  exports.GitHubCopilotSettingsSection = GitHubCopilotSettingsSection;
9142
9369
  exports.HostedSearchSettingsCard = HostedSearchSettingsCard;
9370
+ exports.ParentModelFollowCard = ParentModelFollowCard;
9143
9371
  exports.WebSearchRoutingCard = WebSearchRoutingCard;
9144
9372
  exports.activeAuthorizationNotice = activeAuthorizationNotice;
9145
9373
  exports.apply = apply;