dsh-github-copilot 0.4.0-alpha.26 → 0.4.0-alpha.28

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
@@ -5113,7 +5113,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5113
5113
  return required(ZodNonOptional, this, args[0]);
5114
5114
  }
5115
5115
  });
5116
- function object(shape, params) {
5116
+ function object$1(shape, params) {
5117
5117
  const def = {
5118
5118
  type: "object",
5119
5119
  shape: shape ?? {},
@@ -5380,36 +5380,36 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5380
5380
  //#region lib/types/dual-model-remote.js
5381
5381
  const id = string().min(1).max(512);
5382
5382
  const revision = number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
5383
- const DualModelConfigSchema = object({
5383
+ const DualModelConfigSchema = object$1({
5384
5384
  enabled: boolean(),
5385
5385
  plannerModel: string().max(512),
5386
5386
  executorModel: string().max(512)
5387
5387
  }).strict();
5388
- const DualModelViewSchema = object({
5388
+ const DualModelViewSchema = object$1({
5389
5389
  supported: boolean(),
5390
5390
  diagnostic: string().min(1).max(128).optional(),
5391
5391
  writable: boolean(),
5392
5392
  revision: revision.nullable(),
5393
5393
  configuration: DualModelConfigSchema,
5394
- models: array(object({
5394
+ models: array(object$1({
5395
5395
  id,
5396
5396
  name: string().min(1).max(1024)
5397
5397
  }).strict()).max(512),
5398
- workspaces: array(object({
5398
+ workspaces: array(object$1({
5399
5399
  id,
5400
5400
  name: string().min(1).max(1024)
5401
5401
  }).strict()).max(1024)
5402
5402
  }).strict();
5403
- const DualModelSaveSchema = object({
5403
+ const DualModelSaveSchema = object$1({
5404
5404
  configuration: DualModelConfigSchema,
5405
5405
  expectedRevision: revision
5406
5406
  }).strict();
5407
- const DualModelCreateSchema = object({
5407
+ const DualModelCreateSchema = object$1({
5408
5408
  requestId: string().uuid(),
5409
5409
  workspaceId: id,
5410
5410
  expectedRevision: revision
5411
5411
  }).strict();
5412
- const DualModelCreateResultSchema = object({ sessionId: id }).strict();
5412
+ const DualModelCreateResultSchema = object$1({ sessionId: id }).strict();
5413
5413
  const contribution$2 = {
5414
5414
  package: "dsh-github-copilot",
5415
5415
  descriptors: [
@@ -5454,9 +5454,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5454
5454
  };
5455
5455
  //#endregion
5456
5456
  //#region lib/types/search-routing-remote.js
5457
- const SearchProviderCatalogSchema = object({
5457
+ const SearchProviderCatalogSchema = object$1({
5458
5458
  supported: boolean(),
5459
- providers: array(object({ id: string().min(1).max(512) }).strict()).max(512)
5459
+ providers: array(object$1({ id: string().min(1).max(512) }).strict()).max(512)
5460
5460
  }).strict();
5461
5461
  const contribution$1 = {
5462
5462
  package: "dsh-github-copilot",
@@ -5477,7 +5477,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5477
5477
  */
5478
5478
  const direct = { kind: "direct" };
5479
5479
  const GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotAuthorizationView";
5480
- const GitHubCopilotAuthorizationViewSchema = object({
5480
+ const GitHubCopilotAuthorizationViewSchema = object$1({
5481
5481
  phase: _enum([
5482
5482
  "signed-out",
5483
5483
  "authorizing",
@@ -5487,12 +5487,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5487
5487
  configured: boolean(),
5488
5488
  writable: boolean(),
5489
5489
  inFlight: boolean(),
5490
- notices: array(object({
5490
+ notices: array(object$1({
5491
5491
  message: string(),
5492
5492
  url: string().optional(),
5493
5493
  code: string().optional()
5494
5494
  }).strict()),
5495
- catalog: object({
5495
+ catalog: object$1({
5496
5496
  state: _enum([
5497
5497
  "current",
5498
5498
  "partially-outdated",
@@ -5504,7 +5504,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5504
5504
  temporarilyUnavailableModelIds: array(string()).optional(),
5505
5505
  previewModelIds: array(string()).optional()
5506
5506
  }).strict().optional(),
5507
- accountModels: object({
5507
+ accountModels: object$1({
5508
5508
  state: _enum([
5509
5509
  "idle",
5510
5510
  "loading",
@@ -5515,23 +5515,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5515
5515
  "unconfigured",
5516
5516
  "unavailable"
5517
5517
  ]),
5518
- models: array(object({
5518
+ models: array(object$1({
5519
5519
  id: string(),
5520
5520
  name: string(),
5521
5521
  api: string()
5522
5522
  }).strict()).max(512),
5523
- rejected: array(object({
5523
+ rejected: array(object$1({
5524
5524
  id: string().optional(),
5525
5525
  code: string()
5526
5526
  }).strict()).max(1024),
5527
- warnings: array(object({
5527
+ warnings: array(object$1({
5528
5528
  id: string(),
5529
5529
  code: string()
5530
5530
  }).strict()).max(1024).optional(),
5531
5531
  discoveredAt: number().int().nonnegative().optional(),
5532
5532
  error: string().optional()
5533
5533
  }).strict().optional(),
5534
- route: object({
5534
+ route: object$1({
5535
5535
  state: _enum([
5536
5536
  "ready",
5537
5537
  "needs-repair",
@@ -5549,34 +5549,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5549
5549
  }).strict();
5550
5550
  const result = strictRemoteCodec(GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL, GitHubCopilotAuthorizationViewSchema);
5551
5551
  const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
5552
- const selectionSchema = object({
5552
+ const selectionSchema = object$1({
5553
5553
  provider: string().min(1).max(512),
5554
5554
  model: string().min(1).max(512),
5555
5555
  reasoningEffort: string().min(1).max(512).optional()
5556
5556
  }).strict();
5557
5557
  /** Independent Ops result: strict at every object level; no account or private Session data. */
5558
- const GitHubCopilotMigrationStatusSchema = object({
5559
- plugin: object({
5558
+ const GitHubCopilotMigrationStatusSchema = object$1({
5559
+ plugin: object$1({
5560
5560
  name: literal("dsh-github-copilot"),
5561
5561
  version: string().min(1).max(512)
5562
5562
  }).strict(),
5563
5563
  protocolVersion: literal(1),
5564
5564
  historyScope: literal("live-agents-only"),
5565
5565
  observedAt: number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
5566
- capabilities: object({
5566
+ capabilities: object$1({
5567
5567
  agentsList: boolean(),
5568
5568
  sessionProjections: boolean(),
5569
5569
  settingsCas: boolean(),
5570
5570
  providerRegistry: boolean(),
5571
5571
  defaultSelection: boolean()
5572
5572
  }).strict(),
5573
- complete: object({
5573
+ complete: object$1({
5574
5574
  sessions: boolean(),
5575
5575
  defaultSelection: boolean(),
5576
5576
  routes: boolean()
5577
5577
  }).strict(),
5578
5578
  defaultSelection: selectionSchema.nullable(),
5579
- sessions: array(object({
5579
+ sessions: array(object$1({
5580
5580
  id: string().min(1).max(512),
5581
5581
  status: _enum(["idle", "running"]),
5582
5582
  effectiveSelection: selectionSchema.nullable(),
@@ -5588,7 +5588,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5588
5588
  ]),
5589
5589
  activeRequestSelection: selectionSchema.nullable()
5590
5590
  }).strict()).max(1024),
5591
- routes: object({
5591
+ routes: object$1({
5592
5592
  nativeConfigured: boolean().nullable(),
5593
5593
  nativeRegistered: boolean().nullable(),
5594
5594
  managedRegistered: boolean().nullable()
@@ -6305,7 +6305,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6305
6305
  en: {
6306
6306
  title: "Model roles",
6307
6307
  description: "The planning model plans and reviews acceptance. The execution model changes code and runs tests.",
6308
- scope: "Only new dual-model sessions use this configuration. Existing sessions and the global default stay unchanged. Models are never substituted automatically.",
6308
+ scope: "These role settings are profile-global, not workspace-specific. They apply only when you explicitly create a dedicated dual-model session. Ordinary and existing sessions, history, and the global default stay unchanged. Models are never substituted automatically.",
6309
6309
  enabled: "Enable dual-model sessions",
6310
6310
  planner: "Planning model",
6311
6311
  executor: "Execution model",
@@ -6313,9 +6313,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6313
6313
  selectModel: "Select an available model",
6314
6314
  unavailable: "unavailable",
6315
6315
  modelsMissing: "Choose two available account models to save an enabled configuration. An unavailable saved model is kept, not replaced.",
6316
- workspace: "Workspace for the new session",
6317
- selectWorkspace: "Select a workspace",
6318
- noWorkspaces: "No accessible workspaces are available. Reload settings after opening a workspace.",
6316
+ newSession: "New dedicated session",
6317
+ sessionScope: "Create a new session in the current workspace using the saved role settings.",
6318
+ workspace: "New session destination",
6319
+ originalWorkspace: "Original destination (retained for this request)",
6320
+ noWorkspace: "No current workspace. Open a workspace to create a session; you can still save role settings.",
6321
+ currentWorkspaceUnavailable: "The current workspace is unavailable. Open an accessible workspace and reload settings before creating a session.",
6319
6322
  save: "Save configuration",
6320
6323
  saving: "Saving…",
6321
6324
  create: "Create session with this configuration",
@@ -6332,7 +6335,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6332
6335
  revision: "A settings revision is unavailable. Reload settings before saving or creating a session.",
6333
6336
  conflict: "These settings changed elsewhere. Reload settings to review the saved configuration before trying again.",
6334
6337
  modelUnavailable: "A selected model is unavailable. Reload settings and choose available account models. No model was substituted.",
6335
- workspaceUnavailable: "The selected workspace is unavailable. Reload settings and choose an accessible workspace.",
6338
+ workspaceUnavailable: "The creation workspace is unavailable. Open an accessible workspace and reload settings before creating a new session.",
6336
6339
  loadError: "Could not load model roles. Reload settings to retry.",
6337
6340
  saveError: "The save was not confirmed. Reload settings to check the saved configuration before trying again.",
6338
6341
  uncertain: "Session creation is not confirmed. Retry the same request to recover its result without creating a duplicate. Workspace and configuration are held until confirmation.",
@@ -6345,7 +6348,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6345
6348
  zh: {
6346
6349
  title: "模型分工",
6347
6350
  description: "主模型负责规划与验收;执行模型负责修改代码和运行测试。",
6348
- scope: "仅对新建的双模型会话生效。已有会话和全局默认模型保持不变。不会自动替换模型。",
6351
+ scope: "模型分工设置适用于整个配置档案,不按工作区保存;仅在显式新建专用双模型会话时生效。普通会话、已有会话、历史记录和全局默认模型保持不变。不会自动替换模型。",
6349
6352
  enabled: "启用双模型会话",
6350
6353
  planner: "主模型(规划)",
6351
6354
  executor: "执行模型",
@@ -6353,9 +6356,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6353
6356
  selectModel: "选择可用模型",
6354
6357
  unavailable: "不可用",
6355
6358
  modelsMissing: "启用时须选择两个当前账号可用的模型才能保存。已保存但不可用的模型会保留,不会自动替换。",
6356
- workspace: "新会话的工作区",
6357
- selectWorkspace: "选择工作区",
6358
- noWorkspaces: "暂无可访问的工作区。打开工作区后重新加载设置。",
6359
+ newSession: "新建专用会话",
6360
+ sessionScope: "使用已保存的模型分工设置,在当前工作区新建会话。",
6361
+ workspace: "新会话目标工作区",
6362
+ originalWorkspace: "原目标工作区(为此请求保留)",
6363
+ noWorkspace: "当前没有工作区。请打开工作区后新建会话;仍可保存模型分工设置。",
6364
+ currentWorkspaceUnavailable: "当前工作区不可用。请打开可访问的工作区并重新加载设置后,再新建会话。",
6359
6365
  save: "保存配置",
6360
6366
  saving: "正在保存…",
6361
6367
  create: "用此配置新建会话",
@@ -6372,7 +6378,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6372
6378
  revision: "无法获取设置版本。请重新加载设置后,再保存或新建会话。",
6373
6379
  conflict: "设置已在其他位置修改。请重新加载,检查已保存的配置后再重试。",
6374
6380
  modelUnavailable: "所选模型当前不可用。请重新加载设置并选择可用模型。未自动替换任何模型。",
6375
- workspaceUnavailable: "所选工作区当前不可用。请重新加载设置并选择可访问的工作区。",
6381
+ workspaceUnavailable: "创建会话的目标工作区不可用。请打开可访问的工作区并重新加载设置后,再新建会话。",
6376
6382
  loadError: "无法加载模型分工。请重新加载设置以重试。",
6377
6383
  saveError: "尚未确认保存结果。请重新加载并检查已保存的配置后再重试。",
6378
6384
  uncertain: "尚未确认会话创建结果。请重试同一请求以获取结果,避免重复创建。确认前将保持原工作区和配置不变。",
@@ -6464,7 +6470,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6464
6470
  const id = (0, react.useId)();
6465
6471
  const [view, setView] = (0, react.useState)();
6466
6472
  const [draft, setDraft] = (0, react.useState)(off);
6467
- const [workspace, setWorkspace] = (0, react.useState)("");
6468
6473
  const [phase, setPhase] = (0, react.useState)("loading");
6469
6474
  const [message, setMessage] = (0, react.useState)();
6470
6475
  const [needsReload, setNeedsReload] = (0, react.useState)(false);
@@ -6485,7 +6490,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6485
6490
  setNeedsReload(true);
6486
6491
  const creation = creations.get(props.remote);
6487
6492
  setPending(creation);
6488
- if (creation) setWorkspace(creation.input.workspaceId);
6489
6493
  try {
6490
6494
  const result = await props.remote.view();
6491
6495
  if (!current()) return;
@@ -6515,7 +6519,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6515
6519
  owner.active = true;
6516
6520
  setView(void 0);
6517
6521
  setDraft(off);
6518
- setWorkspace("");
6519
6522
  load();
6520
6523
  return () => {
6521
6524
  owner.active = false;
@@ -6529,7 +6532,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6529
6532
  const validModels = models.some((model) => model.id === draft.plannerModel) && models.some((model) => model.id === draft.executorModel);
6530
6533
  const disabled = busy || !!pending || needsReload || !view?.supported || !view.writable || !validRevision(view.revision);
6531
6534
  const saveDisabled = disabled || draft.enabled && !validModels;
6532
- const createDisabled = pending ? busy : disabled || dirty || !draft.enabled || !validModels || !view?.workspaces.some((item) => item.id === workspace);
6535
+ const workspaceId = pending?.input.workspaceId ?? props.currentWorkspaceId;
6536
+ const destination = view?.workspaces.find((item) => item.id === workspaceId);
6537
+ const createDisabled = pending ? busy : disabled || dirty || !draft.enabled || !validModels || !destination;
6533
6538
  const save = async () => {
6534
6539
  const owner = lifecycle.current;
6535
6540
  if (!owner.active || owner.busy || saveDisabled || !view || !validRevision(view.revision)) return;
@@ -6569,11 +6574,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6569
6574
  if (!owner.active || owner.busy || createDisabled) return;
6570
6575
  let creation = creations.get(props.remote);
6571
6576
  if (!creation) {
6572
- if (!view || !validRevision(view.revision)) return;
6577
+ if (!view || !validRevision(view.revision) || !props.currentWorkspaceId || !view.workspaces.some((item) => item.id === props.currentWorkspaceId)) return;
6573
6578
  try {
6574
6579
  creation = { input: {
6575
6580
  requestId: globalThis.crypto.randomUUID(),
6576
- workspaceId: workspace,
6581
+ workspaceId: props.currentWorkspaceId,
6577
6582
  expectedRevision: view.revision
6578
6583
  } };
6579
6584
  } catch {
@@ -6670,7 +6675,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6670
6675
  };
6671
6676
  const viewNotice = !view ? void 0 : !view.supported ? diagnostic(view.diagnostic) ?? "unsupported" : !view.writable ? "readonly" : !validRevision(view.revision) ? "revision" : void 0;
6672
6677
  const status = phase === "loading" ? t.loading : message ? t[message] : "";
6673
- const shownWorkspace = pending?.input.workspaceId ?? workspace;
6678
+ const workspaceLabel = destination?.name || (pending ? pending.input.workspaceId : destination ? t.workspace : workspaceId ? t.currentWorkspaceUnavailable : t.noWorkspace);
6674
6679
  return (0, react.createElement)("section", {
6675
6680
  style: cardStyle,
6676
6681
  "data-dsh-dual-model-card": true,
@@ -6717,32 +6722,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6717
6722
  }, t.enabled)), field("planner", t.planner, draft.plannerModel), field("executor", t.executor, draft.executorModel), (0, react.createElement)("p", {
6718
6723
  id: `${id}-model-help`,
6719
6724
  style: textStyle
6720
- }, t.acceptance, view && draft.enabled && !validModels ? ` ${t.modelsMissing}` : ""), (0, react.createElement)("div", { style: fieldStyle }, (0, react.createElement)("label", {
6721
- htmlFor: `${id}-workspace`,
6722
- style: labelStyle
6723
- }, t.workspace), (0, react.createElement)("select", {
6724
- id: `${id}-workspace`,
6725
- style: nativeSelectStyle(disabled),
6726
- disabled,
6727
- value: shownWorkspace,
6728
- "data-dsh-dual-model-workspace": true,
6729
- onChange: (event) => {
6730
- const value = event.currentTarget.value;
6731
- if (!disabled && view?.workspaces.some((item) => item.id === value)) setWorkspace(value);
6732
- }
6733
- }, (0, react.createElement)("option", {
6734
- value: "",
6735
- disabled: true,
6736
- style: nativeOptionStyle(true)
6737
- }, t.selectWorkspace), shownWorkspace && !view?.workspaces.some((item) => item.id === shownWorkspace) ? (0, react.createElement)("option", {
6738
- value: shownWorkspace,
6739
- disabled: true,
6740
- style: nativeOptionStyle(true)
6741
- }, `${shownWorkspace} (${t.unavailable})`) : null, ...(view?.workspaces ?? []).map((item) => (0, react.createElement)("option", {
6742
- key: item.id,
6743
- value: item.id,
6744
- style: nativeOptionStyle()
6745
- }, item.name || item.id))), view && view.workspaces.length === 0 ? (0, react.createElement)("p", { style: textStyle }, t.noWorkspaces) : null), viewNotice ? (0, react.createElement)("p", { style: textStyle }, t[viewNotice]) : null, !pending && view && !viewNotice ? (0, react.createElement)("p", { style: textStyle }, dirty ? t.dirty : !draft.enabled ? t.disabled : "") : null, (0, react.createElement)("div", { style: {
6725
+ }, t.acceptance, view && draft.enabled && !validModels ? ` ${t.modelsMissing}` : ""), viewNotice ? (0, react.createElement)("p", { style: textStyle }, t[viewNotice]) : null, (0, react.createElement)("div", { style: {
6746
6726
  display: "flex",
6747
6727
  gap: "12px",
6748
6728
  flexWrap: "wrap",
@@ -6758,7 +6738,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6758
6738
  }
6759
6739
  }, phase === "saving" ? t.saving : t.save), (0, react.createElement)("button", {
6760
6740
  type: "button",
6761
- style: styleForButton(createDisabled),
6741
+ style: styleForButton(busy || !!pending),
6742
+ disabled: busy || !!pending,
6743
+ title: t.reloadTitle,
6744
+ "data-dsh-dual-model-reload": true,
6745
+ onClick: () => {
6746
+ if (!creations.has(props.remote)) load();
6747
+ }
6748
+ }, t.reload)), (0, react.createElement)("div", {
6749
+ role: "group",
6750
+ "aria-labelledby": `${id}-new-session`,
6751
+ style: {
6752
+ ...fieldStyle,
6753
+ gap: "8px",
6754
+ borderTop: "1px solid color-mix(in srgb, currentColor 20%, transparent)",
6755
+ paddingTop: "14px"
6756
+ }
6757
+ }, (0, react.createElement)("h4", {
6758
+ id: `${id}-new-session`,
6759
+ style: {
6760
+ ...labelStyle,
6761
+ margin: 0
6762
+ }
6763
+ }, t.newSession), !pending ? (0, react.createElement)("p", { style: textStyle }, t.sessionScope) : null, (0, react.createElement)("div", { style: fieldStyle }, (0, react.createElement)("span", {
6764
+ id: `${id}-workspace-label`,
6765
+ style: labelStyle
6766
+ }, pending ? t.originalWorkspace : t.workspace), (0, react.createElement)("p", {
6767
+ id: `${id}-workspace`,
6768
+ style: textStyle,
6769
+ "aria-labelledby": `${id}-workspace-label`,
6770
+ "data-dsh-dual-model-workspace": true,
6771
+ "data-workspace-id": workspaceId
6772
+ }, workspaceLabel)), !pending && view && !viewNotice ? (0, react.createElement)("p", { style: textStyle }, dirty ? t.dirty : !draft.enabled ? t.disabled : "") : null, (0, react.createElement)("button", {
6773
+ type: "button",
6774
+ style: {
6775
+ ...styleForButton(createDisabled),
6776
+ justifySelf: "start"
6777
+ },
6762
6778
  disabled: createDisabled,
6763
6779
  "data-dsh-dual-model-create": true,
6764
6780
  onClick: () => {
@@ -6769,30 +6785,112 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6769
6785
  "aria-live": "polite",
6770
6786
  "aria-atomic": true,
6771
6787
  style: textStyle
6772
- }, status), (0, react.createElement)("button", {
6773
- type: "button",
6774
- style: {
6775
- ...styleForButton(busy || !!pending),
6776
- justifySelf: "start"
6788
+ }, status));
6789
+ }
6790
+ //#endregion
6791
+ //#region lib/types/current-workspace.js
6792
+ const object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6793
+ function listOf(value) {
6794
+ if (!object(value) || !object(value.list)) return void 0;
6795
+ const list = value.list;
6796
+ return typeof list.getSnapshot === "function" && typeof list.subscribe === "function" ? list : void 0;
6797
+ }
6798
+ function selectedSession(selection) {
6799
+ if (!object(selection) || selection.phase !== "ready") return void 0;
6800
+ if (Object.hasOwn(selection, "current")) return typeof selection.current === "string" && selection.current ? selection.current : void 0;
6801
+ if (!object(selection.byId)) return void 0;
6802
+ let selected;
6803
+ for (const row of Object.values(selection.byId)) {
6804
+ if (!object(row) || !object(row.retainedBy)) continue;
6805
+ const count = row.retainedBy.mainView;
6806
+ if (count === void 0 || count === 0) continue;
6807
+ if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0 || typeof row.id !== "string" || !row.id || selected !== void 0) return void 0;
6808
+ selected = row.id;
6809
+ }
6810
+ return selected;
6811
+ }
6812
+ function selectedWorkspace(sessions, workspaces) {
6813
+ try {
6814
+ const sessionId = selectedSession(sessions.getSnapshot()), registry = workspaces.getSnapshot();
6815
+ if (sessionId === void 0 || !object(registry) || registry.phase !== "ready" || registry.state === "error" || !Array.isArray(registry.items)) return void 0;
6816
+ let match;
6817
+ for (const item of registry.items) {
6818
+ if (!object(item) || typeof item.workspaceId !== "string" || !item.workspaceId || !Array.isArray(item.sessionIds)) return void 0;
6819
+ if (!item.sessionIds.includes(sessionId)) continue;
6820
+ if (match !== void 0) return void 0;
6821
+ match = item.workspaceId;
6822
+ }
6823
+ return match;
6824
+ } catch {
6825
+ return;
6826
+ }
6827
+ }
6828
+ /** Observe only current membership. Do not call navigation/create or use a recent-workspace fallback. */
6829
+ function createCurrentWorkspaceSource(ctx) {
6830
+ const listeners = /* @__PURE__ */ new Set();
6831
+ let active = true;
6832
+ let current;
6833
+ const notify = () => {
6834
+ if (active) for (const listener of listeners) listener();
6835
+ };
6836
+ const injection = ctx.inject(["sessions", "workspaces"], (scope) => {
6837
+ if (!active) return;
6838
+ const sessions = listOf(scope.get("sessions")), workspaces = listOf(scope.get("workspaces"));
6839
+ if (!sessions || !workspaces) return;
6840
+ const binding = {
6841
+ sessions,
6842
+ workspaces
6843
+ };
6844
+ let stopSessions, stopWorkspaces;
6845
+ try {
6846
+ stopSessions = sessions.subscribe(notify);
6847
+ stopWorkspaces = workspaces.subscribe(notify);
6848
+ } catch {
6849
+ stopSessions?.();
6850
+ stopWorkspaces?.();
6851
+ return;
6852
+ }
6853
+ current = binding;
6854
+ scope.effect(() => () => {
6855
+ stopSessions?.();
6856
+ stopWorkspaces?.();
6857
+ if (current === binding) {
6858
+ current = void 0;
6859
+ notify();
6860
+ }
6861
+ });
6862
+ notify();
6863
+ });
6864
+ return {
6865
+ getSnapshot: () => active && current ? selectedWorkspace(current.sessions, current.workspaces) : void 0,
6866
+ subscribe(listener) {
6867
+ if (!active) return () => {};
6868
+ listeners.add(listener);
6869
+ return () => {
6870
+ listeners.delete(listener);
6871
+ };
6777
6872
  },
6778
- disabled: busy || !!pending,
6779
- title: t.reloadTitle,
6780
- "data-dsh-dual-model-reload": true,
6781
- onClick: () => {
6782
- if (!creations.has(props.remote)) load();
6873
+ dispose() {
6874
+ if (!active) return;
6875
+ active = false;
6876
+ current = void 0;
6877
+ listeners.clear();
6878
+ injection.dispose();
6783
6879
  }
6784
- }, t.reload));
6880
+ };
6785
6881
  }
6786
6882
  //#endregion
6787
6883
  //#region lib/types/dual-model-ui.js
6788
6884
  const emptySubscribe = () => () => {};
6789
- function DualModelSurface({ ctx, close }) {
6885
+ function DualModelSurface({ ctx, remote, workspaceSource, close }) {
6790
6886
  const locale = ctx.get("locale");
6791
6887
  const navigation = ctx.get("uiWorkspace");
6792
6888
  const language = (0, react.useSyncExternalStore)(locale === void 0 ? emptySubscribe : (listener) => locale.subscribe(listener), () => locale?.getLocale().active ?? "en", () => "en");
6889
+ const currentWorkspaceId = (0, react.useSyncExternalStore)(workspaceSource.subscribe, workspaceSource.getSnapshot, () => void 0);
6793
6890
  return (0, react.createElement)(DualModelCard, {
6794
- remote: ctx.remote.githubCopilotDualModel,
6891
+ remote,
6795
6892
  locale: language,
6893
+ currentWorkspaceId,
6796
6894
  onOpenSession: navigation === void 0 ? void 0 : (id) => {
6797
6895
  navigation.openSession(id);
6798
6896
  close?.();
@@ -6801,7 +6899,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6801
6899
  }
6802
6900
  /** A single visible seat under Models, with a section fallback on older Clients. */
6803
6901
  function registerDualModelUi(ctx) {
6804
- if (ctx.remote.githubCopilotDualModel === void 0) return () => {};
6902
+ const remote = ctx.remote.githubCopilotDualModel;
6903
+ if (remote === void 0) return () => {};
6904
+ const workspaceSource = createCurrentWorkspaceSource(ctx);
6805
6905
  let active = true, footerActive = false, sectionActive = false;
6806
6906
  let fallback;
6807
6907
  const syncFallback = () => {
@@ -6812,6 +6912,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6812
6912
  label: "Copilot · Model roles"
6813
6913
  }, (props) => (0, react.createElement)(DualModelSurface, {
6814
6914
  ctx,
6915
+ remote,
6916
+ workspaceSource,
6815
6917
  close: props.close
6816
6918
  }));
6817
6919
  else {
@@ -6829,7 +6931,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6829
6931
  name: "settings.models.footer",
6830
6932
  id: "github-copilot-dual-model",
6831
6933
  order: 15
6832
- }, () => (0, react.createElement)(DualModelSurface, { ctx }));
6934
+ }, () => (0, react.createElement)(DualModelSurface, {
6935
+ ctx,
6936
+ remote,
6937
+ workspaceSource
6938
+ }));
6833
6939
  footerActive = true;
6834
6940
  syncFallback();
6835
6941
  let removed = false;
@@ -6858,6 +6964,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6858
6964
  });
6859
6965
  return () => {
6860
6966
  active = false;
6967
+ workspaceSource.dispose();
6861
6968
  footer();
6862
6969
  section();
6863
6970
  fallback?.();