dsh-codex-subscription 3.1.6 → 3.1.8

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
@@ -7147,6 +7147,21 @@ window.__ModuleLoader__.load({
7147
7147
  //#endregion
7148
7148
  //#region src/client-locales.js
7149
7149
  const zh = {
7150
+ voiceMediaHint: "窗口不支持 WebRTC 时,可在浏览器中继续同一会话。音色试听不受影响,仍使用当前订阅,无需 API Key。",
7151
+ voiceBrowserContinue: "在浏览器继续此会话",
7152
+ voiceBrowserCall: "在浏览器继续语音通话",
7153
+ voiceBrowserCopy: "复制会话链接",
7154
+ voiceBrowserCopied: "已复制",
7155
+ voiceBrowserCopyFailed: "复制失败,请手动复制链接",
7156
+ voicePreviewSignIn: "试听需要重新登录 ChatGPT,请登录后再试。",
7157
+ voiceCatalogFailed: "语音目录加载失败,请检查网络后重试;这不表示该音色没有样本。",
7158
+ voiceDownloadFailed: "试听音频下载失败,请重试。",
7159
+ voicePlaybackFailed: "音频已取得,但播放失败。请检查浏览器的声音权限后重试。",
7160
+ voicePreviewFailed: "试听加载失败,请检查连接后重试。",
7161
+ voiceWebRTCUnavailable: "此窗口不支持语音通话所需的 WebRTC。请在支持 WebRTC 的浏览器中打开同一 DSH 会话;音色试听仍可使用。",
7162
+ voiceInsecure: "语音需要安全连接。请通过 HTTPS 或本机 localhost 打开 DSH。",
7163
+ voiceMicUnavailable: "此窗口无法使用麦克风。请在支持麦克风的浏览器中打开 DSH。",
7164
+ voiceMicMissing: "未找到可用麦克风,请检查设备连接。",
7150
7165
  "diagnosticsSnapshotTime": "报告快照时间:",
7151
7166
  "diagnosticsUnresolved": "仍有其他未恢复的失败记录,见上方摘要。",
7152
7167
  "diagnosticSeverity_warning": "需关注",
@@ -7213,8 +7228,8 @@ window.__ModuleLoader__.load({
7213
7228
  storageTitle: "存储与缓存",
7214
7229
  storageForecast: "额度预测缓存",
7215
7230
  storageClear: "清除预测历史",
7216
- storageHint: "只清理本地预测历史;原图、草稿、登录信息和共享依赖不受影响。子任务组件在“联网与工具”中管理。",
7217
- storageConfirm: "清除所有已登录账号的本地预测历史后,需要重新积累采样。服务端额度不变,后续查询会重新生成缓存。",
7231
+ storageHint: "仅清除本地预测历史,不影响订阅额度。",
7232
+ storageConfirm: "清除所有已登录账号的本地预测历史?预测需重新积累采样;订阅额度、图片、草稿和登录信息不受影响。",
7218
7233
  storageFailed: "未能读取或清除预测缓存,请重试。",
7219
7234
  runtimeIncompatible: "检测到不兼容的 Codex 子任务组件,请卸载后重启,再安装受支持版本。",
7220
7235
  runtimeManagedElsewhere: "此组件由宿主或其他依赖管理,请在 DSH 插件管理中查看;这里不能直接卸载。",
@@ -7274,6 +7289,16 @@ window.__ModuleLoader__.load({
7274
7289
  connectors_read: "只读",
7275
7290
  connectors_ask: "询问后写入",
7276
7291
  connectors_write: "直接写入",
7292
+ defaultReasoningEffort: "默认推理等级",
7293
+ defaultReasoningEffortHint: "未手动选档时使用;模型不支持时跟随该模型默认值。",
7294
+ defaultReasoningEffort_auto: "模型默认",
7295
+ defaultReasoningEffort_off: "关闭推理",
7296
+ defaultReasoningEffort_minimal: "极低",
7297
+ defaultReasoningEffort_low: "低",
7298
+ defaultReasoningEffort_medium: "中",
7299
+ defaultReasoningEffort_high: "高",
7300
+ defaultReasoningEffort_xhigh: "超高",
7301
+ defaultReasoningEffort_max: "最高",
7277
7302
  reasoningSummary: "推理摘要",
7278
7303
  reasoningSummaryHint: "让模型在会话的“思考”部分给出推理摘要。自动由模型决定;简洁更短;详细更完整;关闭则不要摘要。",
7279
7304
  reasoningCache: "切换推理强度时复用缓存",
@@ -7579,6 +7604,8 @@ window.__ModuleLoader__.load({
7579
7604
  searchDomainCount: "个域名",
7580
7605
  catalogRefresh: "刷新模型",
7581
7606
  catalogOnline: "已加载账户在线模型目录",
7607
+ catalogCached: "正在使用本地保存的账户模型目录",
7608
+ catalogCachedFailed: "正在使用本地模型目录,在线更新失败。",
7582
7609
  catalogSignedOut: "登录后显示账户可用的模型。",
7583
7610
  catalogLoading: "正在读取账户模型目录…",
7584
7611
  catalogFailed: "无法读取账户模型目录,请检查网络后重试。",
@@ -7711,7 +7738,7 @@ window.__ModuleLoader__.load({
7711
7738
  historyPeriods: "额度周期",
7712
7739
  historyUsed: "这个周期已用 {value}% 的额度",
7713
7740
  historyPartial: "(统计尚未完成)",
7714
- historyApproximate: "数据来自官方用量报告,是近似值,统计会落后几天。",
7741
+ historyApproximate: "数据来自官方用量报告,可能不完整或延迟更新。",
7715
7742
  historyBy_model: "按模型",
7716
7743
  historyBy_surface: "按入口",
7717
7744
  historyBy_thread_source: "按来源",
@@ -7799,7 +7826,7 @@ window.__ModuleLoader__.load({
7799
7826
  quickQuotaBeta: "Beta",
7800
7827
  autoQuotaRetry: "额度重置后自动重试",
7801
7828
  autoQuotaRetryHint: "开启后,等待已确认的短时额度重置;对话会显示等待原因且可停止,等待期间切换账号会立即重试。",
7802
- quickQuotaForecastHint: "按最近两小时的消耗估算;消耗不足或速度突变时重新校准,详情显示估计范围。仅供参考,历史保存在本机。",
7829
+ quickQuotaForecastHint: "输入框仅显示剩余额度,悬浮或点击查看预测。按最近两小时用量估算何时用完;未来用量变化会影响结果,仅供参考。历史保存在本机。",
7803
7830
  contextTitle: "上下文窗口",
7804
7831
  contextStandard: "标准",
7805
7832
  contextStandardHint: "使用模型目录默认值;官方 Agent 预设会自动管理上下文。",
@@ -7855,8 +7882,8 @@ window.__ModuleLoader__.load({
7855
7882
  diagnosticsAdvanced: "完整诊断(高级)",
7856
7883
  historyAsOf: "数据截至 {date}",
7857
7884
  historyPending: "还在统计中",
7858
- historyPendingCurrent: "这一周期还没结束,官方要等它结束后才给出用量。",
7859
- historyPendingPast: "官方还没统计出这一周期的用量(统计会晚几天,目前只更新到 {date}),稍后再来看。",
7885
+ historyPendingCurrent: "官方尚未提供这一周期的统计结果,稍后可刷新查看。",
7886
+ historyPendingPast: "官方尚未统计出这一周期的用量;报告数据截至 {date},稍后可刷新查看。",
7860
7887
  triggerSketchName: "草图 · Beta",
7861
7888
  triggerSketchHint: "让 Agent 画图或改图",
7862
7889
  triggerImageName: "生图",
@@ -7924,11 +7951,29 @@ window.__ModuleLoader__.load({
7924
7951
  quickQuotaForecastIdle: "用量稳定",
7925
7952
  quickQuotaForecastIdleStatus: "Codex 剩余额度 {value}%,当前没有可测量的消耗速度",
7926
7953
  quickQuotaForecastUntilReset: "够用到重置",
7927
- quickQuotaForecastUntilResetStatus: "Codex 剩余额度 {value}%,按当前速度足够用到重置",
7954
+ quickQuotaForecastUntilResetStatus: "Codex 剩余额度 {value}%,按最近用量,预计可用到重置",
7928
7955
  quotaForecast: "按当前速度 {symbol}{duration}",
7956
+ quotaForecastAt: "按最近用量,预计{when}用完",
7957
+ quotaForecastRoughAt: "按最近用量,粗估{when}左右用完",
7958
+ quotaExhausted: "额度已用尽",
7959
+ pacePart_early: "凌晨",
7960
+ quotaWhenToday: "{day}{part}",
7961
+ quotaWhenTonight: "{day}{part}",
7962
+ quotaWhenEarlyToday: "{day}{part}",
7963
+ quotaWhenEarly: "{day}{part}",
7964
+ quotaWhenRangeEnd: "{part}",
7965
+ quotaWhenRange: "{from}至{to}",
7966
+ quotaWhenEarlyMorningRange: "{from}至{to}",
7967
+ historyRefresh: "刷新",
7968
+ historyNoBreakdown: "官方尚未提供此周期的明细",
7969
+ historyPendingPastUnknown: "官方尚未统计出此周期用量",
7970
+ fetchTitle: "网页读取来源",
7971
+ fetchDshHint: "使用 DSH 当前配置的网页读取服务;与上面的搜索来源分别设置。",
7972
+ fetchCodexHint: "通过 Codex 订阅读取可访问的网页文本。失败会直接提示,不会转到 DeepSeek API。",
7973
+ fetchUnavailableHint: "当前 DSH 不支持切换到 Codex 网页读取,请先升级宿主。",
7929
7974
  quotaForecastCalibrating: "续航正在校准",
7930
7975
  quotaForecastIdle: "当前用量稳定",
7931
- quotaForecastUntilReset: "按当前速度足够用到重置",
7976
+ quotaForecastUntilReset: "按最近用量,预计可用到重置",
7932
7977
  runwayDaysHours: "{days} 天 {hours}h",
7933
7978
  runwayDays: "{days} 天",
7934
7979
  runwayHours: "{hours}h",
@@ -7997,6 +8042,21 @@ window.__ModuleLoader__.load({
7997
8042
  imageRemoveAnnotation: "删除标注"
7998
8043
  };
7999
8044
  const en = {
8045
+ voiceMediaHint: "If this window does not support WebRTC, continue the same conversation in a browser. Voice samples remain available. Your existing subscription is used; no API key is needed.",
8046
+ voiceBrowserContinue: "Continue this conversation in a browser",
8047
+ voiceBrowserCall: "Continue voice in a browser",
8048
+ voiceBrowserCopy: "Copy conversation link",
8049
+ voiceBrowserCopied: "Copied",
8050
+ voiceBrowserCopyFailed: "Copy failed; copy the link manually",
8051
+ voicePreviewSignIn: "Sign in to ChatGPT again to load voice samples.",
8052
+ voiceCatalogFailed: "The voice catalog could not load. Check the connection and retry; this does not mean the voice has no sample.",
8053
+ voiceDownloadFailed: "The voice sample could not download. Please retry.",
8054
+ voicePlaybackFailed: "The audio loaded but could not play. Check browser sound permissions and retry.",
8055
+ voicePreviewFailed: "The voice sample could not load. Check the connection and retry.",
8056
+ voiceWebRTCUnavailable: "This window does not support WebRTC voice calls. Open the same DSH conversation in a WebRTC-capable browser. Voice samples remain available.",
8057
+ voiceInsecure: "Voice requires a secure connection. Open DSH over HTTPS or local localhost.",
8058
+ voiceMicUnavailable: "Microphone access is unavailable in this window. Open DSH in a browser with microphone support.",
8059
+ voiceMicMissing: "No microphone was found. Check the device connection.",
8000
8060
  "diagnosticsSnapshotTime": "Report captured at:",
8001
8061
  "diagnosticsUnresolved": "Other failures remain without a later success; see the summary.",
8002
8062
  "diagnosticSeverity_warning": "Attention",
@@ -8063,8 +8123,8 @@ window.__ModuleLoader__.load({
8063
8123
  storageTitle: "Storage and cache",
8064
8124
  storageForecast: "Quota forecast cache",
8065
8125
  storageClear: "Clear forecast history",
8066
- storageHint: "Clears local forecast history only; original images, drafts, sign-in data and shared dependencies are untouched. Subtask components are managed under Web & tools.",
8067
- storageConfirm: "This clears local forecast samples for all signed-in accounts. Forecasts will need new samples. Server quotas stay unchanged; subsequent checks recreate the cache.",
8126
+ storageHint: "Clears local forecast history only. Subscription quota is unchanged.",
8127
+ storageConfirm: "Clear local forecast history for all signed-in accounts? Forecasts will need new samples. Subscription quota, images, drafts and sign-in data are unaffected.",
8068
8128
  storageFailed: "Could not read or clear the forecast cache. Try again.",
8069
8129
  runtimeIncompatible: "An incompatible Codex subtask component was found. Uninstall it, restart DSH, then install the supported version.",
8070
8130
  runtimeManagedElsewhere: "This component is managed by the host or another dependency. Check DSH plugin management; it cannot be removed here.",
@@ -8124,6 +8184,16 @@ window.__ModuleLoader__.load({
8124
8184
  connectors_read: "Read-only",
8125
8185
  connectors_ask: "Write after asking",
8126
8186
  connectors_write: "Write directly",
8187
+ defaultReasoningEffort: "Default reasoning effort",
8188
+ defaultReasoningEffortHint: "Used when no effort is selected manually. Unsupported levels fall back to the model default.",
8189
+ defaultReasoningEffort_auto: "Model default",
8190
+ defaultReasoningEffort_off: "Off",
8191
+ defaultReasoningEffort_minimal: "Minimal",
8192
+ defaultReasoningEffort_low: "Low",
8193
+ defaultReasoningEffort_medium: "Medium",
8194
+ defaultReasoningEffort_high: "High",
8195
+ defaultReasoningEffort_xhigh: "Extra high",
8196
+ defaultReasoningEffort_max: "Maximum",
8127
8197
  reasoningSummary: "Reasoning summary",
8128
8198
  reasoningSummaryHint: "Shows a summary of the reasoning in the Thinking section of the conversation. Auto lets the model decide; concise is shorter; detailed is fuller; off asks for none.",
8129
8199
  reasoningCache: "Reuse cache when changing effort",
@@ -8429,6 +8499,8 @@ window.__ModuleLoader__.load({
8429
8499
  searchDomainCount: "domains",
8430
8500
  catalogRefresh: "Refresh models",
8431
8501
  catalogOnline: "Account model catalog loaded",
8502
+ catalogCached: "Using the locally saved account model catalog",
8503
+ catalogCachedFailed: "Using the local model catalog; the online update failed.",
8432
8504
  catalogSignedOut: "Sign in to show the models your account can use.",
8433
8505
  catalogLoading: "Reading the account model catalog…",
8434
8506
  catalogFailed: "Could not read the account model catalog. Check the network and try again.",
@@ -8561,7 +8633,7 @@ window.__ModuleLoader__.load({
8561
8633
  historyPeriods: "Allowance periods",
8562
8634
  historyUsed: "{value}% of this period's allowance used",
8563
8635
  historyPartial: "(still being counted)",
8564
- historyApproximate: "From the official usage report; values are approximate and the report lags by a few days.",
8636
+ historyApproximate: "From the official usage report; data may be incomplete or delayed.",
8565
8637
  historyBy_model: "By model",
8566
8638
  historyBy_surface: "By surface",
8567
8639
  historyBy_thread_source: "By source",
@@ -8649,7 +8721,7 @@ window.__ModuleLoader__.load({
8649
8721
  quickQuotaBeta: "Beta",
8650
8722
  autoQuotaRetry: "Retry after quota reset",
8651
8723
  autoQuotaRetryHint: "Wait for confirmed short quota resets. The turn shows why it is waiting and can be stopped; switching accounts retries immediately.",
8652
- quickQuotaForecastHint: "Estimates recent two-hour consumption; recalibrates with insufficient data or changing pace. Details show a range. Indicative only; history stays local.",
8724
+ quickQuotaForecastHint: "Shows remaining quota in the composer; hover or click for the forecast. Estimates run-out time from recent two-hour usage. Future usage affects the result. History stays local.",
8653
8725
  contextTitle: "Context window",
8654
8726
  contextStandard: "Standard",
8655
8727
  contextStandardHint: "Use the model catalog default; official agent presets manage context automatically.",
@@ -8681,7 +8753,7 @@ window.__ModuleLoader__.load({
8681
8753
  pacePart_morning: "morning",
8682
8754
  pacePart_afternoon: "afternoon",
8683
8755
  pacePart_evening: "evening",
8684
- pacePart_night: "at night",
8756
+ pacePart_night: "night",
8685
8757
  state_otherModels_on: "Now: on. Conversations on DeepSeek and other models can also use the subscription for search, images and connectors. Turning it off limits that to GPT / Codex conversations; DeepSeek and others keep DSH search and cannot generate images or use connectors.",
8686
8758
  state_otherModels_off: "Now: off. Only GPT / Codex conversations use the subscription for search, images and connectors; DeepSeek and others keep DSH search and cannot generate images or use connectors. Turning it on lets them use these too.",
8687
8759
  state_imageGeneration_on: "Now: on. The model can draw new pictures with your subscription. Turning it off stops the model from drawing in conversations.",
@@ -8705,8 +8777,8 @@ window.__ModuleLoader__.load({
8705
8777
  diagnosticsAdvanced: "Full report (advanced)",
8706
8778
  historyAsOf: "Data as of {date}",
8707
8779
  historyPending: "Still being counted",
8708
- historyPendingCurrent: "This period has not ended yet; the official report only gives its usage once it has.",
8709
- historyPendingPast: "The official report has not counted this period yet (it runs a few days behind, currently up to {date}); check back later.",
8780
+ historyPendingCurrent: "The official report has not provided figures for this period yet. Refresh later to check.",
8781
+ historyPendingPast: "The official report has not counted this period yet. Data is as of {date}; refresh later to check.",
8710
8782
  triggerSketchName: "Sketch · Beta",
8711
8783
  triggerSketchHint: "Ask the Agent to draw or edit a sketch",
8712
8784
  triggerImageName: "Image",
@@ -8776,9 +8848,27 @@ window.__ModuleLoader__.load({
8776
8848
  quickQuotaForecastUntilReset: "Enough until reset",
8777
8849
  quickQuotaForecastUntilResetStatus: "Codex quota: {value}% remaining; enough until reset at the current pace",
8778
8850
  quotaForecast: "At current pace {symbol}{duration}",
8851
+ quotaForecastAt: "At recent usage, estimated to run out {when}",
8852
+ quotaForecastRoughAt: "Rough estimate at recent usage: around {when}",
8853
+ quotaExhausted: "Quota exhausted",
8854
+ pacePart_early: "early morning",
8855
+ quotaWhenToday: "this {part}",
8856
+ quotaWhenTonight: "tonight",
8857
+ quotaWhenEarlyToday: "early this morning",
8858
+ quotaWhenEarly: "early {day} morning",
8859
+ quotaWhenRangeEnd: "{label}",
8860
+ quotaWhenRange: "{from}–{to}",
8861
+ quotaWhenEarlyMorningRange: "{latest}",
8862
+ historyRefresh: "Refresh",
8863
+ historyNoBreakdown: "Official breakdown not yet available for this period",
8864
+ historyPendingPastUnknown: "Official usage for this period is not available yet",
8865
+ fetchTitle: "Webpage reading source",
8866
+ fetchDshHint: "Use the webpage reader configured in DSH, independently of the search source above.",
8867
+ fetchCodexHint: "Read accessible webpage text with your Codex subscription. Failures are reported directly, without falling back to the DeepSeek API.",
8868
+ fetchUnavailableHint: "This DSH version cannot switch to the Codex webpage reader. Update DSH first.",
8779
8869
  quotaForecastCalibrating: "Runway calibrating",
8780
8870
  quotaForecastIdle: "Usage currently stable",
8781
- quotaForecastUntilReset: "Enough until reset at current pace",
8871
+ quotaForecastUntilReset: "Estimated to last until reset at recent usage",
8782
8872
  runwayDaysHours: "{days}d {hours}h",
8783
8873
  runwayDays: "{days}d",
8784
8874
  runwayHours: "{hours}h",
@@ -8970,6 +9060,8 @@ window.__ModuleLoader__.load({
8970
9060
  .codexSubscriptionRefresh *{white-space:nowrap!important;word-break:keep-all!important;writing-mode:horizontal-tb!important}
8971
9061
  .codexSubscriptionEmpty{padding:18px;border:1px dashed var(--dsw-alias-border-l3);border-radius:10px;text-align:center;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
8972
9062
  .codexSubscriptionHistory{margin-top:10px;border-top:1px solid var(--dsw-alias-border-l3);padding-top:8px}
9063
+ .codexSubscriptionHistoryRefresh{margin:6px 0;padding:3px 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
9064
+ .codexSubscriptionHistoryRefresh:disabled{opacity:.5;cursor:default}
8973
9065
  .codexSubscriptionHistory>summary{cursor:pointer;font-size:13px;font-weight:500;color:var(--dsw-alias-label-secondary)}
8974
9066
  .codexSubscriptionHistoryPeriods{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
8975
9067
  .codexSubscriptionHistoryPeriods button{height:26px;padding:0 10px;border:1px solid var(--dsw-alias-border-l3);border-radius:13px;background:transparent;color:inherit;font-size:12px;cursor:pointer}
@@ -9068,7 +9160,8 @@ window.__ModuleLoader__.load({
9068
9160
  .codexComposerQuota:focus-visible{outline:1px solid var(--dsw-alias-border-l3);outline-offset:2px}
9069
9161
  .codexComposerQuota{display:inline-flex;align-items:center;gap:9px;flex:0 0 auto;height:28px;box-sizing:border-box;padding:0 5px;border:0;border-radius:6px;background:transparent;cursor:pointer;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:12px;line-height:20px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap}
9070
9162
  .codexComposerQuota:hover,.codexComposerQuota[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}
9071
- .codexQuotaCompactWindow{display:inline-flex;align-items:center;gap:5px}
9163
+ .codexQuotaCompactWindow{display:inline-flex;align-items:center;gap:5px;min-width:0;max-width:min(380px,55vw)}
9164
+ .codexQuotaCompactWindow>span:last-child{overflow:hidden;text-overflow:ellipsis}
9072
9165
  .codexQuotaPopover{position:fixed;z-index:1000;width:max-content;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);overflow:auto;box-sizing:border-box;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 4px 16px #0002;font-size:12px;line-height:20px;outline:none}
9073
9166
  .codexQuotaDetail+ .codexQuotaDetail{margin-top:5px;padding-top:5px;border-top:1px solid var(--dsw-alias-border-l2)}
9074
9167
  .codexQuotaDetail>div{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
@@ -9151,8 +9244,9 @@ window.__ModuleLoader__.load({
9151
9244
  .codexSubscriptionDiagnostics .codexSubscriptionSectionTitle{display:flex;flex-direction:column;gap:5px}
9152
9245
  .codexSubscriptionRemotePair{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin-top:8px}.codexSubscriptionRemoteQr{width:168px;height:168px;flex:none;border-radius:12px;overflow:hidden;background:#fff}.codexSubscriptionRemoteQr svg{display:block;width:100%;height:100%}.codexSubscriptionRemoteCode{margin:6px 0;font:600 20px/28px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.08em;user-select:all}
9153
9246
  .codexSubscriptionStorageMeter{display:flex;flex-direction:column;gap:9px;padding:12px;border-radius:10px;background:var(--dsw-alias-bg-module-platform)}
9154
- .codexSubscriptionStorageMeter>div{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;font-size:12px;line-height:18px}
9155
- .codexSubscriptionStorageMeter output{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
9247
+ .codexSubscriptionStorageHead{display:flex;align-items:center;justify-content:space-between;gap:8px 16px;flex-wrap:wrap}
9248
+ .codexSubscriptionStorageTitle{display:flex;align-items:baseline;gap:6px 12px;flex-wrap:wrap;min-width:0}
9249
+ .codexSubscriptionStorageTitle output{font-size:12px;line-height:18px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
9156
9250
  .codexSubscriptionStorageMeter progress{width:100%;height:4px;border:0;border-radius:4px;overflow:hidden;accent-color:var(--dsw-alias-label-secondary)}
9157
9251
  .codexSubscriptionStorageMeter progress::-webkit-progress-bar{background:var(--dsw-alias-border-l2)}
9158
9252
  .codexSubscriptionStorageMeter progress::-webkit-progress-value{background:var(--dsw-alias-label-secondary)}
@@ -9174,12 +9268,14 @@ window.__ModuleLoader__.load({
9174
9268
  .codexVoiceChoice .codexSubscriptionContextTrigger:first-child:not(:last-child){min-width:0;justify-content:center}
9175
9269
  /* The voice button wears the send button's own classes, so its colours, shape and theme are always the send button's. */
9176
9270
  .codexVoiceCall{position:absolute;z-index:2;margin:0}
9271
+ a.codexVoiceCall{display:flex;align-items:center;justify-content:center;box-sizing:border-box;text-decoration:none}
9177
9272
  /* DSH's send button is the light info colour at rest and darkens on hover. The voice button is an action in its own right, so it keeps the stronger colour all the time and only deepens a little on hover. */
9178
9273
  .codexVoiceCall:not(:disabled){background:var(--dsw-alias-button-info-hover,#4176e6)!important;filter:none}
9179
9274
  .codexVoiceCall:not(:disabled):hover{filter:brightness(.92)}
9180
9275
  .codexVoiceCall:disabled{cursor:progress}
9181
9276
  .codexVoiceCall[data-state=connecting]{animation:codexVoicePulse 1.1s ease-in-out infinite}
9182
9277
  .codexVoiceCallNote{position:absolute;bottom:calc(100% + 8px);z-index:3;width:max-content;max-width:320px;padding:6px 10px;border-radius:8px;background:var(--dsw-alias-surface-elevated,#2a2a2e);color:var(--dsw-alias-label-primary,#fff);font-size:12px;line-height:16px;box-shadow:0 4px 16px rgba(0,0,0,.3);white-space:normal}
9278
+ .codexVoiceBrowserActions{display:flex;gap:12px;flex-wrap:wrap;margin-top:6px}.codexVoiceBrowserActions a,.codexVoiceBrowserActions button{color:inherit;text-decoration:underline;background:none;border:0;padding:0;cursor:pointer;font:inherit}
9183
9279
  @keyframes codexVoicePulse{50%{opacity:.55}}
9184
9280
  @media (prefers-reduced-motion:reduce){.codexVoiceCall{animation:none!important}}
9185
9281
 
@@ -9253,11 +9349,12 @@ window.__ModuleLoader__.load({
9253
9349
  .codexFlat{display:flex;flex-direction:column;gap:0}.codexFlat[hidden]{display:none}
9254
9350
  .codexFlat .codexSubscriptionAdvancedPreferences{gap:0}
9255
9351
  .codexFlat .codexSubscriptionCard,.codexFlat .codexSubscriptionPreferencesCard,.codexFlat .codexImageSettings{border:1px solid var(--dsw-alias-border-l2);background:transparent;box-shadow:none;border-radius:12px;padding:2px 16px;margin:0 0 8px}
9352
+ .codexFlat .codexSubscriptionPreferencesCard,.codexFlat .codexFeatureOverview{gap:0}
9256
9353
  .codexFlat h3,.codexFlat .codexSubscriptionSectionHead h3{margin:10px 0 2px;font-size:14px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}
9257
9354
  .codexFlat .codexSubscriptionPreference,.codexFlat .codexFeatureRow>.codexFeatureMain{box-sizing:border-box;padding:8px 0;min-height:52px;gap:6px 16px;align-items:center}
9258
9355
  .codexFlat .codexSubscriptionPreference,.codexFlat .codexFeatureRow{border-bottom:1px solid var(--dsw-alias-border-l2)}
9259
9356
  .codexFlat .codexFeatureRow,.codexFlat .codexSubscriptionPreference{border-top:0}
9260
- .codexFlat section>.codexSubscriptionPreference:last-child,.codexFlat section>.codexFeatureRow:last-of-type,.codexFlat section>div:last-child>.codexSubscriptionPreference:last-child,.codexFlat .codexAdvancedBody>.codexSubscriptionPreference:last-child{border-bottom:0}
9357
+ .codexFlat section>.codexSubscriptionPreference:last-child,.codexFlat .codexSubscriptionCard>.codexSubscriptionPreference:last-child,.codexFlat section>.codexFeatureRow:last-of-type,.codexFlat section>div:last-child>.codexSubscriptionPreference:last-child,.codexFlat .codexAdvancedBody>.codexSubscriptionPreference:last-child{border-bottom:0}
9261
9358
  .codexFlat .codexSubscriptionPreferenceLabel,.codexFlat .codexFeatureTitle{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:400;line-height:20px;min-height:20px;color:var(--dsw-alias-label-primary)}
9262
9359
  .codexFlat .codexSubscriptionPreferenceLabel small,.codexFlat .codexFeatureTitle small{line-height:16px;height:16px;display:inline-flex;align-items:center}
9263
9360
  .codexFlat .codexSubscriptionPreferenceHint,.codexFlat .codexFeatureSummary,.codexFlat .codexSubscriptionHintText{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
@@ -9280,7 +9377,9 @@ window.__ModuleLoader__.load({
9280
9377
  .codexFlat .codexSubscriptionSearchOptions{margin:0;padding:0}.codexFlat .codexSubscriptionSearchOptions>summary{padding:10px 0;margin:0}
9281
9378
  .codexFlat .codexSubscriptionCard:has(>.codexSubscriptionAccounts),.codexFlat .codexSubscriptionCard:has(>.codexSubscriptionActions),.codexFlat .codexSubscriptionStorage{padding-block:10px}
9282
9379
  .codexFlat .codexSubscriptionCreditSection{display:block}.codexFlat .codexSubscriptionCreditSection[open]>summary{border-bottom:1px solid var(--dsw-alias-border-l2);margin-bottom:8px}
9283
- .codexFlat .codexSubscriptionStorageMeter{background:transparent;padding:6px 0}
9380
+ .codexFlat .codexSubscriptionStorage{gap:6px}
9381
+ .codexFlat .codexSubscriptionStorageTitle h3{margin:0}
9382
+ .codexFlat .codexSubscriptionStorageMeter{background:transparent;padding:0}
9284
9383
  .codexFlat .codexSubscriptionResetBox{border:0;border-radius:0;padding:0}
9285
9384
  .codexFlat :is(button,summary,a):focus-visible,.codexFlat label:has(:focus-visible){outline:2px solid var(--dsw-alias-border-inverted);outline-offset:2px;box-shadow:none}
9286
9385
  .codexSettingsTabs{position:sticky;top:0;z-index:2;background:var(--dsw-alias-bg-layer-1);border-radius:0;padding:6px 0 0;margin-top:-6px;gap:18px;display:flex;overflow-x:auto;scrollbar-width:none;grid-template-columns:none;border-bottom:1px solid var(--dsw-alias-border-l2);margin-bottom:8px}
@@ -9291,6 +9390,7 @@ window.__ModuleLoader__.load({
9291
9390
  .codexSubscriptionNotice{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
9292
9391
  .codexSubscriptionNotices button{margin-left:6px;border:0;background:transparent;padding:0;font:inherit;color:var(--dsw-alias-label-primary);text-decoration:underline;cursor:pointer}
9293
9392
  .codexSubscriptionPace{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-warning-primary,#b45309)}
9393
+ .codexSubscriptionForecast{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
9294
9394
  .codexSubscriptionLimit[data-pace=true] progress{accent-color:var(--dsw-alias-state-warning-primary,#f5a300)}
9295
9395
  .codexSubscriptionLimit[data-pace=true] progress::-webkit-progress-value{background:var(--dsw-alias-state-warning-primary,#f5a300)}
9296
9396
  .codexSubscriptionLimit[data-pace=true] progress::-moz-progress-bar{background:var(--dsw-alias-state-warning-primary,#f5a300)}
@@ -10669,6 +10769,9 @@ window.__ModuleLoader__.load({
10669
10769
  const SEARCH_PROVIDER_AUTO = "auto";
10670
10770
  const SEARCH_PROVIDER_CODEX = "codex";
10671
10771
  const DEFAULT_SEARCH_PROVIDER = SEARCH_PROVIDER_AUTO;
10772
+ const FETCH_PROVIDER_FIELD = "fetchProvider";
10773
+ const FETCH_PROVIDER_CODEX = "codex";
10774
+ const normalizeFetchProvider = (value) => value === "codex" ? FETCH_PROVIDER_CODEX : "dsh";
10672
10775
  const SPEED_MODE_FIELD = "speedMode";
10673
10776
  const SPEED_MODE_STANDARD = "standard";
10674
10777
  const SPEED_MODE_FAST = "fast";
@@ -10724,6 +10827,20 @@ window.__ModuleLoader__.load({
10724
10827
  const normalizeVoiceCall = (value) => value === "on" ? "on" : "off";
10725
10828
  const normalizeVoiceVoice = (value) => VOICE_VOICES.includes(value) ? value : "cove";
10726
10829
  const normalizeVoiceLanguage = (value) => VOICE_LANGUAGES.includes(value) ? value : "auto";
10830
+ const DEFAULT_REASONING_EFFORT_FIELD = "defaultReasoningEffort";
10831
+ const DEFAULT_REASONING_EFFORTS = Object.freeze([
10832
+ "auto",
10833
+ "off",
10834
+ "minimal",
10835
+ "low",
10836
+ "medium",
10837
+ "high",
10838
+ "xhigh",
10839
+ "max"
10840
+ ]);
10841
+ const DEFAULT_REASONING_EFFORT = "auto";
10842
+ const normalizeDefaultReasoningEffort = (value) => DEFAULT_REASONING_EFFORTS.includes(value) ? value : DEFAULT_REASONING_EFFORT;
10843
+ const normalizeDefaultReasoningEffortChoice = normalizeDefaultReasoningEffort;
10727
10844
  const REASONING_SUMMARY_FIELD = "reasoningSummary";
10728
10845
  const REASONING_SUMMARIES = Object.freeze([
10729
10846
  "auto",
@@ -10857,6 +10974,11 @@ window.__ModuleLoader__.load({
10857
10974
  default: "on",
10858
10975
  error: "Invalid reasoning cache preference"
10859
10976
  },
10977
+ [DEFAULT_REASONING_EFFORT_FIELD]: {
10978
+ choices: DEFAULT_REASONING_EFFORTS,
10979
+ default: DEFAULT_REASONING_EFFORT,
10980
+ error: "Invalid default reasoning effort"
10981
+ },
10860
10982
  connectionMode: {
10861
10983
  choices: ["sse", "websocket"],
10862
10984
  default: "sse",
@@ -10900,6 +11022,11 @@ window.__ModuleLoader__.load({
10900
11022
  default: DEFAULT_SEARCH_PROVIDER,
10901
11023
  error: "Invalid search provider preference"
10902
11024
  },
11025
+ [FETCH_PROVIDER_FIELD]: {
11026
+ choices: ["dsh", FETCH_PROVIDER_CODEX],
11027
+ default: "dsh",
11028
+ error: "Invalid fetch provider preference"
11029
+ },
10903
11030
  [SPEED_MODE_FIELD]: {
10904
11031
  choices: [
10905
11032
  SPEED_MODE_STANDARD,
@@ -10992,6 +11119,7 @@ window.__ModuleLoader__.load({
10992
11119
  let disposed = false;
10993
11120
  let subagentBackendAvailable = false;
10994
11121
  let subagentRuntimeInstalled = false;
11122
+ let fetchRoutingAvailable = false;
10995
11123
  let restartRequired = false;
10996
11124
  const sameModels = (left, right) => left.length === right.length && left.every((model, index) => JSON.stringify(model) === JSON.stringify(right[index]));
10997
11125
  const read = () => {
@@ -11011,11 +11139,14 @@ window.__ModuleLoader__.load({
11011
11139
  otherModels: value?.otherModels === "off" ? "off" : "on",
11012
11140
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
11013
11141
  reasoningCache: normalizeReasoningCache(value?.reasoningCache),
11142
+ defaultReasoningEffort: normalizeDefaultReasoningEffort(value?.[DEFAULT_REASONING_EFFORT_FIELD]),
11014
11143
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
11015
11144
  subagentBackendAvailable,
11016
11145
  subagentRuntimeInstalled,
11017
11146
  quickQuotaMode: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
11018
11147
  searchProvider: normalizeSearchProvider(value?.[SEARCH_PROVIDER_FIELD]),
11148
+ fetchProvider: normalizeFetchProvider(value?.[FETCH_PROVIDER_FIELD]),
11149
+ fetchRoutingAvailable,
11019
11150
  speedMode: normalizeSpeedMode(value?.[SPEED_MODE_FIELD]),
11020
11151
  outputVerbosity: normalizeOutputVerbosity(value?.[OUTPUT_VERBOSITY_FIELD]),
11021
11152
  inputImageDetail: normalizeInputImageDetail(value?.[INPUT_IMAGE_DETAIL_FIELD]),
@@ -11058,6 +11189,7 @@ window.__ModuleLoader__.load({
11058
11189
  if (value?.liveSynced === false) restartRequired = true;
11059
11190
  subagentBackendAvailable = value?.subagentBackendAvailable === true;
11060
11191
  subagentRuntimeInstalled = value?.subagentRuntimeInstalled === true;
11192
+ fetchRoutingAvailable = value?.fetchRoutingAvailable === true;
11061
11193
  if (!modelRefreshStarted) {
11062
11194
  contextModels = Array.isArray(value?.contextModels) ? value.contextModels : [];
11063
11195
  availableModels = Array.isArray(value?.availableModels) ? value.availableModels : [];
@@ -11078,10 +11210,12 @@ window.__ModuleLoader__.load({
11078
11210
  otherModels: value?.otherModels === "off" ? "off" : "on",
11079
11211
  compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
11080
11212
  reasoningCache: normalizeReasoningCache(value?.reasoningCache),
11213
+ [DEFAULT_REASONING_EFFORT_FIELD]: normalizeDefaultReasoningEffort(value?.[DEFAULT_REASONING_EFFORT_FIELD]),
11081
11214
  subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
11082
11215
  ...readCapabilitySettings(value),
11083
11216
  [QUICK_QUOTA_MODE_FIELD]: normalizeQuickQuotaMode(value?.[QUICK_QUOTA_MODE_FIELD], value?.[LEGACY_QUICK_QUOTA_FIELD]),
11084
11217
  [SEARCH_PROVIDER_FIELD]: normalizeSearchProvider(value?.[SEARCH_PROVIDER_FIELD]),
11218
+ [FETCH_PROVIDER_FIELD]: normalizeFetchProvider(value?.[FETCH_PROVIDER_FIELD]),
11085
11219
  [SPEED_MODE_FIELD]: normalizeSpeedMode(value?.[SPEED_MODE_FIELD]),
11086
11220
  [OUTPUT_VERBOSITY_FIELD]: normalizeOutputVerbosity(value?.[OUTPUT_VERBOSITY_FIELD]),
11087
11221
  [INPUT_IMAGE_DETAIL_FIELD]: normalizeInputImageDetail(value?.[INPUT_IMAGE_DETAIL_FIELD]),
@@ -11474,42 +11608,8 @@ window.__ModuleLoader__.load({
11474
11608
  dispose
11475
11609
  });
11476
11610
  }
11477
- /** @returns {{runsOutAt:number, resetsAt:number}|undefined} times in ms, only when the window is projected to run out before its reset. */
11478
- function quotaPace({ remainingPercent, windowSeconds, resetsAt, now = Date.now() }) {
11479
- if (!Number.isFinite(remainingPercent) || !Number.isSafeInteger(windowSeconds) || windowSeconds < 86400 || !Number.isSafeInteger(resetsAt)) return void 0;
11480
- const used = Math.floor(Math.min(100, Math.max(0, 100 - remainingPercent)));
11481
- if (used < 10 || used >= 100) return void 0;
11482
- const resetMs = resetsAt * 1e3;
11483
- const elapsed = now - (resetMs - windowSeconds * 1e3);
11484
- if (!(elapsed >= 432e5) || resetMs <= now) return void 0;
11485
- const runsOutAt = now + (100 - used) * elapsed / used;
11486
- return runsOutAt < resetMs ? {
11487
- runsOutAt,
11488
- resetsAt: resetMs
11489
- } : void 0;
11490
- }
11491
- const dayStart = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
11492
- /** Plain words for a moment: the day (today, tomorrow, the weekday, or the date) and, for the run-out time, the part of the day. */
11493
- function paceWords(pace, now, { t, locale }) {
11494
- const today = dayStart(new Date(now));
11495
- const day = (date) => {
11496
- const gap = Math.round((dayStart(date) - today) / 864e5);
11497
- if (gap <= 0) return t("paceDay_today");
11498
- if (gap === 1) return t("paceDay_tomorrow");
11499
- if (gap < 7) return date.toLocaleDateString(locale, { weekday: locale.startsWith("zh") || locale.startsWith("ja") ? "short" : "long" });
11500
- return date.toLocaleDateString(locale, {
11501
- month: "numeric",
11502
- day: "numeric"
11503
- });
11504
- };
11505
- const out = new Date(pace.runsOutAt), reset = new Date(pace.resetsAt);
11506
- const hour = out.getHours();
11507
- const part = hour < 5 ? "night" : hour < 12 ? "morning" : hour < 18 ? "afternoon" : hour < 23 ? "evening" : "night";
11508
- return {
11509
- runOut: t("paceWhen").replace("{day}", day(out)).replace("{part}", t(`pacePart_${part}`)),
11510
- reset: t("paceResetOf").replace("{day}", day(reset))
11511
- };
11512
- }
11611
+ //#endregion
11612
+ //#region src/quota-pace.js
11513
11613
  /**
11514
11614
  * One reading of a runway forecast for every place that shows it (settings card, composer chip, composer details), so the
11515
11615
  * same snapshot always reads the same hours. Raw seconds are rounded to a grid coarser than the percentage quantisation
@@ -11525,7 +11625,7 @@ window.__ModuleLoader__.load({
11525
11625
  /** @returns {{kind:'reset'}|{kind:'range',min:number,max:number}|{kind:'point',seconds:number}|undefined} rounded seconds. */
11526
11626
  function forecastRunway(forecast) {
11527
11627
  if (forecast?.status !== "ready") return void 0;
11528
- if (forecast.survivesReset) return { kind: "reset" };
11628
+ if (forecast.survivesReset && !forecast.provisional) return { kind: "reset" };
11529
11629
  if (!forecast.provisional && Number.isFinite(forecast.runwayMinSeconds) && Number.isFinite(forecast.runwayMaxSeconds)) {
11530
11630
  const min = roundRunwaySeconds(forecast.runwayMinSeconds), max = roundRunwaySeconds(forecast.runwayMaxSeconds);
11531
11631
  if (min > 0 && max > min) return {
@@ -11541,6 +11641,90 @@ window.__ModuleLoader__.load({
11541
11641
  } : void 0;
11542
11642
  }
11543
11643
  //#endregion
11644
+ //#region src/quota-forecast-view.js
11645
+ /** A time estimate is anchored to the reading, never advanced by opening another view later. */
11646
+ function quotaForecastView(forecast, { fetchedAt, now = Date.now(), resetsAt, remainingPercent, refreshError = false } = {}) {
11647
+ if (refreshError || Number.isFinite(fetchedAt) && (fetchedAt > now || now - fetchedAt > 5 * 6e4) || Number.isFinite(resetsAt) && resetsAt * 1e3 <= now) return { kind: "stale" };
11648
+ if (remainingPercent === 0) return { kind: "exhausted" };
11649
+ if (forecast?.status === "calibrating") return { kind: forecast.reason ?? "calibrating" };
11650
+ if (forecast?.status === "idle") return { kind: "idle" };
11651
+ if (!Number.isFinite(fetchedAt)) return { kind: "calibrating" };
11652
+ if (forecast?.status === "ready" && !forecast.provisional && Number.isFinite(forecast.runwayMinSeconds) && forecast.runwayMinSeconds > 0 && Number.isFinite(resetsAt) && fetchedAt + forecast.runwayMinSeconds * 1e3 >= resetsAt * 1e3) return { kind: "reset" };
11653
+ const rawMin = !forecast?.provisional && Number.isFinite(forecast?.runwayMinSeconds) ? forecast.runwayMinSeconds : forecast?.runwaySeconds;
11654
+ if (Number.isFinite(rawMin) && fetchedAt + rawMin * 1e3 <= now) return { kind: "stale" };
11655
+ const runway = forecastRunway({
11656
+ ...forecast,
11657
+ survivesReset: false
11658
+ });
11659
+ if (!runway) return { kind: "calibrating" };
11660
+ const anchor = fetchedAt;
11661
+ const min = runway.kind === "range" ? runway.min : runway.seconds;
11662
+ const max = runway.kind === "range" ? runway.max : runway.seconds;
11663
+ if (anchor + min * 1e3 <= now) return { kind: "stale" };
11664
+ const grid = min < 3600 ? 5 * 6e4 : 36e5;
11665
+ const round = (value) => Math.round(value / grid) * grid;
11666
+ return {
11667
+ kind: "time",
11668
+ earliest: round(anchor + min * 1e3),
11669
+ latest: round(anchor + max * 1e3),
11670
+ provisional: forecast.provisional === true
11671
+ };
11672
+ }
11673
+ function formatQuotaRunout(view, { t, locale, now = Date.now(), timeZone }) {
11674
+ const clock = new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn", {
11675
+ timeZone,
11676
+ year: "numeric",
11677
+ month: "numeric",
11678
+ day: "numeric",
11679
+ hour: "numeric",
11680
+ hourCycle: "h23"
11681
+ });
11682
+ const local = (time) => {
11683
+ const fields = Object.fromEntries(clock.formatToParts(time).filter((part) => part.type !== "literal").map((part) => [part.type, Number(part.value)]));
11684
+ return {
11685
+ day: Date.UTC(fields.year, fields.month - 1, fields.day),
11686
+ hour: fields.hour
11687
+ };
11688
+ };
11689
+ const today = local(now).day;
11690
+ const render = (key, values) => Object.entries(values).reduce((text, [name, value]) => text.replace(`{${name}}`, value), t(key));
11691
+ const when = (time) => {
11692
+ const date = local(time), gap = (date.day - today) / 864e5;
11693
+ const day = gap === 0 ? t("paceDay_today") : gap === 1 ? t("paceDay_tomorrow") : new Intl.DateTimeFormat(locale, gap > 1 && gap < 7 ? {
11694
+ timeZone,
11695
+ weekday: locale?.startsWith("zh") ? "short" : "long"
11696
+ } : {
11697
+ timeZone,
11698
+ month: "numeric",
11699
+ day: "numeric"
11700
+ }).format(time);
11701
+ const part = date.hour < 5 ? "early" : date.hour < 12 ? "morning" : date.hour < 18 ? "afternoon" : date.hour < 23 ? "evening" : "night";
11702
+ const partText = t(`pacePart_${part}`);
11703
+ const key = gap === 0 ? part === "early" ? "quotaWhenEarlyToday" : part === "night" ? "quotaWhenTonight" : "quotaWhenToday" : part === "early" ? "quotaWhenEarly" : "paceWhen";
11704
+ return {
11705
+ day: date.day,
11706
+ period: part,
11707
+ part: partText,
11708
+ label: render(key, {
11709
+ day,
11710
+ part: partText
11711
+ })
11712
+ };
11713
+ };
11714
+ if (view.kind !== "time") return void 0;
11715
+ const from = when(view.earliest), to = when(view.latest);
11716
+ if (from.label === to.label) return from.label;
11717
+ const end = from.day === to.day ? render("quotaWhenRangeEnd", {
11718
+ part: to.part,
11719
+ label: to.label
11720
+ }) : to.label;
11721
+ return render(from.day === to.day && from.period === "early" && to.period === "morning" ? "quotaWhenEarlyMorningRange" : "quotaWhenRange", {
11722
+ from: from.label,
11723
+ to: end,
11724
+ latest: to.label
11725
+ });
11726
+ }
11727
+ //#endregion
11544
11728
  //#region src/client-shared.js
11545
11729
  const NS = "settings.codexSubscription";
11546
11730
  const SUPPORT_ISSUE_URL = "https://github.com/WSL043/dsh-codex-subscription/issues/new?template=install-problem.yml";
@@ -11583,33 +11767,23 @@ window.__ModuleLoader__.load({
11583
11767
  const usePreferenceSnapshot = (preference) => (0, react.useSyncExternalStore)(preference.subscribe, preference.getSnapshot);
11584
11768
  const useAccountStatusSnapshot = (accountStatus) => (0, react.useSyncExternalStore)(accountStatus.subscribe, accountStatus.getSnapshot);
11585
11769
  const notifyQuickQuota = () => window.dispatchEvent(new Event(QUICK_QUOTA_REFRESH_EVENT));
11586
- const formatRunway = (seconds, t) => {
11587
- if (!Number.isFinite(seconds) || seconds <= 0) return void 0;
11588
- const minutes = Math.max(1, Math.round(seconds / 60));
11589
- const days = Math.floor(minutes / 1440);
11590
- const hours = Math.floor(minutes % 1440 / 60);
11591
- if (days > 0) return hours > 0 ? fill(t("runwayDaysHours"), {
11592
- days,
11593
- hours
11594
- }) : fill(t("runwayDays"), { days });
11595
- if (hours > 0) return fill(t("runwayHours"), { hours });
11596
- return fill(t("runwayMinutes"), { minutes });
11597
- };
11598
- const formatQuotaForecast = (forecast, t) => {
11599
- if (forecast?.status === "calibrating") return t({
11770
+ const formatQuotaForecast = (forecast, t, options = {}) => {
11771
+ const view = quotaForecastView(forecast, options);
11772
+ if (view.kind !== "time") return t({
11600
11773
  resolution: "forecastResolution",
11601
11774
  "changing-pace": "forecastChanging",
11602
- stale: "forecastStale"
11603
- }[forecast.reason] ?? "quotaForecastCalibrating");
11604
- if (forecast?.status === "idle") return t("quotaForecastIdle");
11605
- const runway = forecastRunway(forecast);
11606
- if (runway === void 0) return void 0;
11607
- if (runway.kind === "reset") return t("quotaForecastUntilReset");
11608
- const duration = runway.kind === "range" ? `${formatRunway(runway.min, t)}–${formatRunway(runway.max, t)}` : formatRunway(runway.seconds, t);
11609
- return fill(t("quotaForecast"), {
11610
- symbol: "≈",
11611
- duration
11775
+ stale: "forecastStale",
11776
+ idle: "quotaForecastIdle",
11777
+ reset: "quotaForecastUntilReset",
11778
+ exhausted: "quotaExhausted"
11779
+ }[view.kind] ?? "quotaForecastCalibrating");
11780
+ const when = formatQuotaRunout(view, {
11781
+ t,
11782
+ locale: options.locale ?? uiLocale(),
11783
+ now: options.now,
11784
+ timeZone: options.timeZone
11612
11785
  });
11786
+ return fill(t(view.provisional ? "quotaForecastRoughAt" : "quotaForecastAt"), { when });
11613
11787
  };
11614
11788
  //#endregion
11615
11789
  //#region src/sidebar-quota.js
@@ -11636,7 +11810,7 @@ window.__ModuleLoader__.load({
11636
11810
  }
11637
11811
  //#endregion
11638
11812
  //#region src/version.js
11639
- const PACKAGE_VERSION = "3.1.6";
11813
+ const PACKAGE_VERSION = "3.1.8";
11640
11814
  //#endregion
11641
11815
  //#region src/client-recovery.js
11642
11816
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
@@ -11679,63 +11853,178 @@ window.__ModuleLoader__.load({
11679
11853
  return values.length === 0 ? void 0 : Math.max(...values);
11680
11854
  }
11681
11855
  //#endregion
11682
- //#region src/client-quota.jsx
11683
- function useQuickQuota(rpc, enabled, model) {
11684
- const [quota, setQuota] = (0, react.useState)();
11685
- (0, react.useEffect)(() => {
11686
- if (!enabled) {
11687
- setQuota(void 0);
11688
- return;
11856
+ //#region src/usage-controller.js
11857
+ /** One live quota snapshot and polling loop for every mounted view. */
11858
+ function createUsageController({ request, now = Date.now, schedule = setTimeout, cancel = clearTimeout, listen, visible = () => true, onUpdate }) {
11859
+ let snapshot = Object.freeze({
11860
+ usage: void 0,
11861
+ busy: false,
11862
+ error: void 0,
11863
+ now: now()
11864
+ });
11865
+ let generation = 0, consumers = 0, flight, timer, unlisten;
11866
+ const listeners = /* @__PURE__ */ new Set();
11867
+ const publish = (next) => {
11868
+ snapshot = Object.freeze(next);
11869
+ for (const listener of [...listeners]) listener();
11870
+ };
11871
+ const stopTimer = () => {
11872
+ if (timer !== void 0) cancel(timer);
11873
+ timer = void 0;
11874
+ };
11875
+ const queue = () => {
11876
+ stopTimer();
11877
+ if (consumers === 0 || !visible()) return;
11878
+ timer = schedule(() => {
11879
+ timer = void 0;
11880
+ refresh().catch(() => {});
11881
+ }, quotaRefreshMs(highestUsed(snapshot.usage?.rateLimits?.flatMap((limit) => limit.windows) ?? [])));
11882
+ };
11883
+ const refresh = (force = false) => {
11884
+ if (flight) {
11885
+ if (force && !flight.force) {
11886
+ const current = generation;
11887
+ return flight.promise.catch(() => {}).then(() => current === generation ? refresh(true) : void 0);
11888
+ }
11889
+ return flight.promise;
11689
11890
  }
11690
- setQuota(void 0);
11691
- let live = true;
11692
- let loading = false;
11693
- let timer;
11694
- let latest;
11695
- const load = async () => {
11696
- if (loading) return;
11697
- loading = true;
11698
- try {
11699
- const account = await recoveryCall(rpc, "status");
11700
- if (!live) return;
11701
- if (account?.authenticated !== true) {
11702
- setQuota(void 0);
11703
- return;
11704
- }
11705
- const usage = await recoveryCall(rpc, "usage", { force: false });
11706
- const windows = selectModelQuotaWindows(usage, model)?.map((window) => ({
11707
- ...window,
11708
- fetchedAt: usage.fetchedAt
11709
- }));
11710
- latest = windows;
11711
- if (live) setQuota(windows);
11712
- } catch {
11713
- latest = void 0;
11714
- if (live) setQuota(void 0);
11715
- } finally {
11716
- loading = false;
11717
- if (live) {
11718
- window.clearTimeout(timer);
11719
- timer = window.setTimeout(refresh, quotaRefreshMs(highestUsed(latest)));
11720
- }
11891
+ stopTimer();
11892
+ const current = generation;
11893
+ const operation = { force };
11894
+ operation.promise = Promise.resolve().then(() => current === generation ? request(force) : void 0).then((usage) => {
11895
+ if (current === generation) {
11896
+ publish({
11897
+ usage,
11898
+ busy: false,
11899
+ error: void 0,
11900
+ now: now()
11901
+ });
11902
+ onUpdate?.({ force });
11721
11903
  }
11722
- };
11723
- const refresh = () => {
11724
- load();
11725
- };
11726
- load();
11727
- window.addEventListener(QUICK_QUOTA_REFRESH_EVENT, refresh);
11728
- return () => {
11729
- live = false;
11730
- window.clearTimeout(timer);
11731
- window.removeEventListener(QUICK_QUOTA_REFRESH_EVENT, refresh);
11732
- };
11733
- }, [
11734
- rpc,
11735
- enabled,
11736
- model
11737
- ]);
11738
- return quota;
11904
+ return usage;
11905
+ }).catch((error) => {
11906
+ if (current === generation) publish({
11907
+ ...snapshot,
11908
+ busy: false,
11909
+ error: error?.message ?? "Could not read quota",
11910
+ now: now()
11911
+ });
11912
+ throw error;
11913
+ }).finally(() => {
11914
+ if (flight === operation) {
11915
+ flight = void 0;
11916
+ queue();
11917
+ }
11918
+ });
11919
+ flight = operation;
11920
+ publish({
11921
+ ...snapshot,
11922
+ busy: true,
11923
+ now: now()
11924
+ });
11925
+ return operation.promise;
11926
+ };
11927
+ const invalidate = ({ preserveUsage = false } = {}) => {
11928
+ generation += 1;
11929
+ flight = void 0;
11930
+ stopTimer();
11931
+ const usage = preserveUsage && snapshot.usage ? {
11932
+ ...snapshot.usage,
11933
+ rateLimits: snapshot.usage.rateLimits.map((limit) => ({
11934
+ ...limit,
11935
+ windows: limit.windows.map(({ forecast, ...window }) => window)
11936
+ }))
11937
+ } : void 0;
11938
+ publish({
11939
+ usage,
11940
+ busy: false,
11941
+ error: void 0,
11942
+ now: now()
11943
+ });
11944
+ if (consumers > 0 && visible()) refresh().catch(() => {});
11945
+ };
11946
+ return Object.freeze({
11947
+ getSnapshot: () => snapshot,
11948
+ subscribe(listener) {
11949
+ listeners.add(listener);
11950
+ return () => listeners.delete(listener);
11951
+ },
11952
+ refresh,
11953
+ invalidate,
11954
+ retain() {
11955
+ consumers += 1;
11956
+ if (consumers === 1) {
11957
+ unlisten = listen?.({
11958
+ invalidate,
11959
+ wake: () => {
11960
+ if (visible()) refresh().catch(() => {});
11961
+ else stopTimer();
11962
+ }
11963
+ });
11964
+ invalidate();
11965
+ }
11966
+ let released = false;
11967
+ return () => {
11968
+ if (released) return;
11969
+ released = true;
11970
+ consumers -= 1;
11971
+ if (consumers === 0) {
11972
+ generation += 1;
11973
+ flight = void 0;
11974
+ stopTimer();
11975
+ unlisten?.();
11976
+ unlisten = void 0;
11977
+ publish({
11978
+ usage: void 0,
11979
+ busy: false,
11980
+ error: void 0,
11981
+ now: now()
11982
+ });
11983
+ }
11984
+ };
11985
+ }
11986
+ });
11987
+ }
11988
+ //#endregion
11989
+ //#region src/client-quota.jsx
11990
+ const controllers = /* @__PURE__ */ new WeakMap();
11991
+ function quotaUsageController(rpc) {
11992
+ if (!controllers.has(rpc)) controllers.set(rpc, createUsageController({
11993
+ request: async (force) => {
11994
+ return (await recoveryCall(rpc, "status"))?.authenticated === true ? recoveryCall(rpc, "usage", { force }) : void 0;
11995
+ },
11996
+ visible: () => document.visibilityState !== "hidden",
11997
+ onUpdate: ({ force }) => {
11998
+ if (force) window.dispatchEvent(new Event("codex-subscription:usage-loaded"));
11999
+ },
12000
+ listen: ({ invalidate, wake }) => {
12001
+ window.addEventListener(QUICK_QUOTA_REFRESH_EVENT, invalidate);
12002
+ document.addEventListener("visibilitychange", wake);
12003
+ return () => {
12004
+ window.removeEventListener(QUICK_QUOTA_REFRESH_EVENT, invalidate);
12005
+ document.removeEventListener("visibilitychange", wake);
12006
+ };
12007
+ }
12008
+ }));
12009
+ return controllers.get(rpc);
12010
+ }
12011
+ function useQuotaUsage(rpc, enabled) {
12012
+ const controller = quotaUsageController(rpc);
12013
+ const snapshot = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
12014
+ (0, react.useEffect)(() => enabled ? controller.retain() : void 0, [controller, enabled]);
12015
+ return {
12016
+ ...snapshot,
12017
+ refresh: controller.refresh
12018
+ };
12019
+ }
12020
+ function useQuickQuota(rpc, enabled, model) {
12021
+ const snapshot = useQuotaUsage(rpc, enabled);
12022
+ return enabled ? selectModelQuotaWindows(snapshot.usage, model).map((window) => ({
12023
+ ...window,
12024
+ fetchedAt: snapshot.usage.fetchedAt,
12025
+ now: snapshot.now,
12026
+ refreshError: snapshot.error !== void 0
12027
+ })) : void 0;
11739
12028
  }
11740
12029
  //#endregion
11741
12030
  //#region src/client-composer-quota.jsx
@@ -11754,9 +12043,11 @@ window.__ModuleLoader__.load({
11754
12043
  setOpen(true);
11755
12044
  };
11756
12045
  const leave = () => {
12046
+ clearTimeout(dismissTimer.current);
11757
12047
  if (!pinned.current) dismissTimer.current = setTimeout(() => setOpen(false), 150);
11758
12048
  };
11759
12049
  const dismiss = () => {
12050
+ clearTimeout(dismissTimer.current);
11760
12051
  pinned.current = false;
11761
12052
  setOpen(false);
11762
12053
  };
@@ -11773,7 +12064,7 @@ window.__ModuleLoader__.load({
11773
12064
  });
11774
12065
  useDismissOnOutsidePointer(trigger, visible, dismiss, panel);
11775
12066
  (0, react.useEffect)(() => {
11776
- setOpen(false);
12067
+ dismiss();
11777
12068
  }, [current?.model, quotaEnabled]);
11778
12069
  (0, react.useEffect)(() => {
11779
12070
  if (!visible) return;
@@ -11811,6 +12102,7 @@ window.__ModuleLoader__.load({
11811
12102
  onMouseEnter: enter,
11812
12103
  onMouseLeave: leave,
11813
12104
  onClick: () => {
12105
+ clearTimeout(dismissTimer.current);
11814
12106
  if (pinned.current) dismiss();
11815
12107
  else {
11816
12108
  pinned.current = true;
@@ -11821,14 +12113,14 @@ window.__ModuleLoader__.load({
11821
12113
  children: compactQuotas.map((quota, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
11822
12114
  className: "codexQuotaCompactWindow",
11823
12115
  children: [
11824
- Math.abs(quota.windowSeconds - 604800) < 60 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: shortWindow(quota.windowSeconds, t) }),
12116
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: shortWindow(quota.windowSeconds, t) }),
11825
12117
  preferenceSnapshot.quickQuotaMode === "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
11826
12118
  className: "codexComposerQuotaBar",
11827
12119
  max: 100,
11828
12120
  value: quota.remainingPercent,
11829
12121
  "aria-hidden": "true"
11830
12122
  }) : null,
11831
- preferenceSnapshot.quickQuotaMode !== "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [`${percent(quota.remainingPercent)}%`, forecastMode ? ` · ${forecastText(quota, t)}` : ""] }) : null
12123
+ preferenceSnapshot.quickQuotaMode !== "bar" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${percent(quota.remainingPercent)}%` }) : null
11832
12124
  ]
11833
12125
  }, `${quota.windowSeconds}-${index}`))
11834
12126
  }), visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
@@ -11853,7 +12145,7 @@ window.__ModuleLoader__.load({
11853
12145
  className: "codexQuotaReset",
11854
12146
  children: shortReset(quota, t)
11855
12147
  })
11856
- ] }), forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: formatQuotaForecast(quota.forecast, t) }) : null]
12148
+ ] }), forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: formatQuotaForecast(quota.forecast, t, quota) }) : null]
11857
12149
  }, `${quota.windowSeconds}-${index}`))
11858
12150
  }), document.body) : null] });
11859
12151
  }
@@ -11872,19 +12164,6 @@ window.__ModuleLoader__.load({
11872
12164
  });
11873
12165
  return fill(t("resets"), { value });
11874
12166
  }
11875
- function forecastText(quota, t) {
11876
- const forecast = quota.forecast;
11877
- if (forecast?.status === "calibrating") return t({
11878
- "changing-pace": "forecastCompactChanging",
11879
- stale: "forecastCompactStale"
11880
- }[forecast.reason] ?? "forecastCompactPending");
11881
- if (forecast?.status === "idle") return t("quickQuotaForecastIdle");
11882
- const runway = forecastRunway(forecast);
11883
- if (runway?.kind === "reset") return t("quickQuotaForecastUntilReset");
11884
- if (runway?.kind === "range") return `≈${formatRunway(runway.min, t)}–${formatRunway(runway.max, t)}`;
11885
- if (runway?.kind === "point") return `≈${formatRunway(runway.seconds, t)}`;
11886
- return t("forecastCompactPending");
11887
- }
11888
12167
  //#endregion
11889
12168
  //#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/16/solid/esm/BoltIcon.js
11890
12169
  function BoltIcon({ title, titleId, ...props }, svgRef) {
@@ -12403,6 +12682,33 @@ window.__ModuleLoader__.load({
12403
12682
  } };
12404
12683
  }
12405
12684
  //#endregion
12685
+ //#region src/voice-problems.js
12686
+ /** Stable user-facing categories; never render private server error strings. */
12687
+ function voicePreviewProblem(code) {
12688
+ return {
12689
+ "not-found": "voiceNoSample",
12690
+ "voice-auth": "voicePreviewSignIn",
12691
+ "voice-catalog": "voiceCatalogFailed",
12692
+ "voice-download": "voiceDownloadFailed",
12693
+ playback: "voicePlaybackFailed"
12694
+ }[code] ?? "voicePreviewFailed";
12695
+ }
12696
+ function voiceCallProblem(error) {
12697
+ if (error?.name === "NotAllowedError") return "voiceMicBlocked";
12698
+ if (error?.name === "NotFoundError") return "voiceMicMissing";
12699
+ return {
12700
+ "voice-insecure": "voiceInsecure",
12701
+ "voice-no-microphone": "voiceMicUnavailable",
12702
+ "voice-no-webrtc": "voiceWebRTCUnavailable"
12703
+ }[error?.code] ?? "voiceFailed";
12704
+ }
12705
+ function voiceCallCapability(surface = globalThis) {
12706
+ if (surface.isSecureContext === false) return "voice-insecure";
12707
+ if (typeof surface.navigator?.mediaDevices?.getUserMedia !== "function") return "voice-no-microphone";
12708
+ if (surface.__dshWebRtcFallback && Object.getOwnPropertyDescriptor(surface, "RTCPeerConnection")?.get) return "voice-no-webrtc";
12709
+ if (typeof surface.RTCPeerConnection !== "function") return "voice-no-webrtc";
12710
+ }
12711
+ //#endregion
12406
12712
  //#region src/voice-call.js
12407
12713
  const ICE_WAIT_MS = 3e3;
12408
12714
  const waitForCandidates = (connection) => new Promise((resolve) => {
@@ -12456,18 +12762,33 @@ window.__ModuleLoader__.load({
12456
12762
  * plugin's host turns the offer into a call, joins it, and runs what is asked as turns of this conversation.
12457
12763
  * Resolves with a handle once the call is connected; rejects with the reason when it could not start.
12458
12764
  */
12459
- async function openVoiceCall({ rpc, sessionId, onEnd }) {
12460
- if (typeof navigator === "undefined" || !navigator.mediaDevices?.getUserMedia || typeof RTCPeerConnection !== "function") throw new Error("unsupported");
12461
- const stream = await navigator.mediaDevices.getUserMedia({ audio: {
12462
- echoCancellation: true,
12463
- noiseSuppression: true,
12464
- autoGainControl: true
12465
- } });
12466
- const connection = new RTCPeerConnection();
12467
- const sound = new Audio();
12468
- sound.autoplay = true;
12469
- const AudioContextClass = window.AudioContext ?? window.webkitAudioContext;
12470
- const context = AudioContextClass ? new AudioContextClass() : void 0;
12765
+ async function openVoiceCall({ rpc, sessionId, onEnd, signal }) {
12766
+ signal?.throwIfAborted();
12767
+ const unsupported = voiceCallCapability();
12768
+ if (unsupported) throw Object.assign(/* @__PURE__ */ new Error("Voice is not supported in this environment"), { code: unsupported });
12769
+ let connection;
12770
+ try {
12771
+ connection = new RTCPeerConnection();
12772
+ } catch {
12773
+ throw Object.assign(/* @__PURE__ */ new Error("WebRTC could not initialize"), { code: "voice-no-webrtc" });
12774
+ }
12775
+ let stream, sound, context;
12776
+ try {
12777
+ stream = await navigator.mediaDevices.getUserMedia({ audio: {
12778
+ echoCancellation: true,
12779
+ noiseSuppression: true,
12780
+ autoGainControl: true
12781
+ } });
12782
+ signal?.throwIfAborted();
12783
+ sound = new Audio();
12784
+ sound.autoplay = true;
12785
+ const AudioContextClass = window.AudioContext ?? window.webkitAudioContext;
12786
+ context = AudioContextClass ? new AudioContextClass() : void 0;
12787
+ } catch (error) {
12788
+ stream?.getTracks().forEach((track) => track.stop());
12789
+ connection.close();
12790
+ throw error;
12791
+ }
12471
12792
  const analysers = {
12472
12793
  mic: void 0,
12473
12794
  assistant: void 0
@@ -12493,6 +12814,7 @@ window.__ModuleLoader__.load({
12493
12814
  const end = async () => {
12494
12815
  if (ended) return;
12495
12816
  ended = true;
12817
+ signal?.removeEventListener("abort", aborted);
12496
12818
  clearInterval(monitor);
12497
12819
  if (context) chime(context, [740, 520]);
12498
12820
  for (const track of stream.getTracks()) track.stop();
@@ -12508,6 +12830,10 @@ window.__ModuleLoader__.load({
12508
12830
  }, 600);
12509
12831
  onEnd?.();
12510
12832
  };
12833
+ const aborted = () => {
12834
+ end();
12835
+ };
12836
+ signal?.addEventListener("abort", aborted, { once: true });
12511
12837
  connection.addEventListener("connectionstatechange", () => {
12512
12838
  if ([
12513
12839
  "failed",
@@ -12522,7 +12848,8 @@ window.__ModuleLoader__.load({
12522
12848
  const result = await rpc.call(CHANNEL, "voice/start", {
12523
12849
  sessionId,
12524
12850
  sdp: connection.localDescription.sdp
12525
- });
12851
+ }, signal);
12852
+ signal?.throwIfAborted();
12526
12853
  if (!result.ok) throw new Error(result.error?.message ?? "start failed");
12527
12854
  await connection.setRemoteDescription({
12528
12855
  type: "answer",
@@ -12530,6 +12857,7 @@ window.__ModuleLoader__.load({
12530
12857
  });
12531
12858
  } catch (error) {
12532
12859
  ended = true;
12860
+ signal?.removeEventListener("abort", aborted);
12533
12861
  for (const track of stream.getTracks()) track.stop();
12534
12862
  try {
12535
12863
  connection.close();
@@ -12579,6 +12907,41 @@ window.__ModuleLoader__.load({
12579
12907
  };
12580
12908
  }
12581
12909
  //#endregion
12910
+ //#region src/voice-browser.js
12911
+ const PARAM = "codexVoiceSession";
12912
+ const validSession = (value) => typeof value === "string" && /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,255}$/u.test(value);
12913
+ /** A permalink, never an authentication URL or a native-shell URL. */
12914
+ function voiceBrowserUrl(href, sessionId) {
12915
+ if (!validSession(sessionId)) return void 0;
12916
+ try {
12917
+ const url = new URL(href);
12918
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) return void 0;
12919
+ url.search = "";
12920
+ url.hash = "";
12921
+ url.searchParams.set(PARAM, sessionId);
12922
+ return url.href;
12923
+ } catch {
12924
+ return;
12925
+ }
12926
+ }
12927
+ /** Let the host open its own session; consume only after that operation succeeds. */
12928
+ async function restoreVoiceConversation({ href, workspace, history, sessions, signal }) {
12929
+ const url = new URL(href);
12930
+ const sessionId = url.searchParams.get(PARAM);
12931
+ if (!validSession(sessionId) || typeof workspace?.openSession !== "function") return false;
12932
+ const reference = sessions?.retain(sessionId, { source: "controllerOperation" });
12933
+ try {
12934
+ if (reference) await reference.ready;
12935
+ signal?.throwIfAborted();
12936
+ await workspace.openSession(sessionId);
12937
+ url.searchParams.delete(PARAM);
12938
+ history.replaceState(history.state, "", url.href);
12939
+ return true;
12940
+ } finally {
12941
+ reference?.release();
12942
+ }
12943
+ }
12944
+ //#endregion
12582
12945
  //#region src/voice-orb.js
12583
12946
  const VERTEX = "attribute vec2 a;void main(){gl_Position=vec4(a,0.,1.);}";
12584
12947
  const FRAGMENT = `
@@ -13231,15 +13594,25 @@ void main(){
13231
13594
  const snapshot = usePreferenceSnapshot(preference);
13232
13595
  const marker = (0, react.useRef)(null);
13233
13596
  const call = (0, react.useRef)(null);
13597
+ const pendingCall = (0, react.useRef)(null);
13598
+ const alive = (0, react.useRef)(false);
13234
13599
  const [liveCall, setLiveCall] = (0, react.useState)(null);
13235
13600
  const accent = (0, react.useRef)("");
13236
13601
  const button = (0, react.useRef)(null);
13237
13602
  const [place, setPlace] = (0, react.useState)();
13238
13603
  const [state, setState] = (0, react.useState)("idle");
13239
13604
  const [problem, setProblem] = (0, react.useState)("");
13605
+ const [unsupported, setUnsupported] = (0, react.useState)(false);
13606
+ const [browserCopied, setBrowserCopied] = (0, react.useState)(false);
13240
13607
  const [micOff, setMicOff] = (0, react.useState)(false);
13241
13608
  const [speakerOff, setSpeakerOff] = (0, react.useState)(false);
13242
13609
  const enabled = snapshot.status === "ready" && snapshot.voiceCall === "on";
13610
+ const capability = enabled ? voiceCallCapability() : void 0;
13611
+ (0, react.useEffect)(() => {
13612
+ setProblem("");
13613
+ setUnsupported(false);
13614
+ setBrowserCopied(false);
13615
+ }, [sessionId, capability]);
13243
13616
  (0, react.useLayoutEffect)(() => {
13244
13617
  if (!enabled) {
13245
13618
  setPlace(void 0);
@@ -13298,37 +13671,63 @@ void main(){
13298
13671
  activity.setAttribute("data-voice-live", "");
13299
13672
  return () => activity.removeAttribute("data-voice-live");
13300
13673
  }, [place?.activity, live]);
13301
- (0, react.useEffect)(() => () => {
13302
- call.current?.stop();
13303
- }, []);
13304
13674
  (0, react.useEffect)(() => {
13305
- if (!problem) return void 0;
13675
+ alive.current = true;
13676
+ call.current = null;
13677
+ setLiveCall(null);
13678
+ setState("idle");
13679
+ return () => {
13680
+ alive.current = false;
13681
+ pendingCall.current?.abort();
13682
+ call.current?.stop();
13683
+ };
13684
+ }, [sessionId]);
13685
+ (0, react.useEffect)(() => {
13686
+ if (!problem || unsupported) return void 0;
13306
13687
  const timer = setTimeout(() => setProblem(""), 6e3);
13307
13688
  return () => clearTimeout(timer);
13308
- }, [problem]);
13689
+ }, [problem, unsupported]);
13309
13690
  const start = async () => {
13691
+ const controller = new AbortController();
13692
+ pendingCall.current?.abort();
13693
+ pendingCall.current = controller;
13310
13694
  setProblem("");
13695
+ setUnsupported(false);
13696
+ setBrowserCopied(false);
13311
13697
  accent.current = button.current ? getComputedStyle(button.current).backgroundColor : "";
13312
13698
  setMicOff(false);
13313
13699
  setSpeakerOff(false);
13314
13700
  setState("connecting");
13315
13701
  try {
13316
- call.current = await openVoiceCall({
13702
+ const opened = await openVoiceCall({
13317
13703
  rpc,
13318
13704
  sessionId,
13705
+ signal: controller.signal,
13319
13706
  onEnd: () => {
13707
+ if (!alive.current || controller.signal.aborted || pendingCall.current !== controller) return;
13320
13708
  call.current = null;
13321
13709
  setLiveCall(null);
13322
13710
  setState("idle");
13323
13711
  }
13324
13712
  });
13713
+ if (!alive.current || controller.signal.aborted) {
13714
+ await opened.stop();
13715
+ return;
13716
+ }
13717
+ call.current = opened;
13325
13718
  setLiveCall(call.current);
13326
13719
  setState("live");
13327
13720
  } catch (error) {
13721
+ if (!alive.current || controller.signal.aborted) return;
13328
13722
  call.current = null;
13329
13723
  setLiveCall(null);
13330
13724
  setState("idle");
13331
- setProblem(error?.name === "NotAllowedError" ? t("voiceMicBlocked") : t("voiceFailed"));
13725
+ setUnsupported([
13726
+ "voice-no-webrtc",
13727
+ "voice-no-microphone",
13728
+ "voice-insecure"
13729
+ ].includes(error?.code) ? error.code : false);
13730
+ setProblem(voiceCallProblem(error));
13332
13731
  }
13333
13732
  };
13334
13733
  const click = () => {
@@ -13354,9 +13753,27 @@ void main(){
13354
13753
  hidden: true
13355
13754
  });
13356
13755
  if (!enabled || !place) return anchor;
13756
+ const visible = state !== "idle" || place.idle;
13757
+ const browserUrl = capability === "voice-no-webrtc" || unsupported && unsupported !== "voice-insecure" ? voiceBrowserUrl(window.location.href, sessionId) : void 0;
13357
13758
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
13358
13759
  anchor,
13359
- state !== "idle" || place.idle ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
13760
+ visible ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [state === "idle" && capability === "voice-no-webrtc" && browserUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
13761
+ ref: button,
13762
+ href: browserUrl,
13763
+ target: "_blank",
13764
+ rel: "noopener noreferrer",
13765
+ className: `${place.className} codexVoiceCall`,
13766
+ "data-state": "browser",
13767
+ "aria-label": t("voiceBrowserCall"),
13768
+ title: t("voiceBrowserCall"),
13769
+ style: {
13770
+ left: place.left,
13771
+ top: place.top,
13772
+ width: place.width,
13773
+ height: place.height
13774
+ },
13775
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Bars, {})
13776
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
13360
13777
  ref: button,
13361
13778
  type: "button",
13362
13779
  className: `${place.className} codexVoiceCall`,
@@ -13372,11 +13789,25 @@ void main(){
13372
13789
  height: place.height
13373
13790
  },
13374
13791
  children: live ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Cross, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Bars, {})
13375
- }), problem ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13792
+ }), problem ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
13376
13793
  className: "codexVoiceCallNote",
13377
13794
  role: "alert",
13378
13795
  style: { right: 0 },
13379
- children: problem
13796
+ children: [t(problem), browserUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
13797
+ className: "codexVoiceBrowserActions",
13798
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
13799
+ href: browserUrl,
13800
+ target: "_blank",
13801
+ rel: "noopener noreferrer",
13802
+ children: t("voiceBrowserContinue")
13803
+ }), typeof navigator.clipboard?.writeText === "function" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
13804
+ type: "button",
13805
+ onClick: () => {
13806
+ navigator.clipboard.writeText(browserUrl).then(() => setBrowserCopied(true)).catch(() => setBrowserCopied("error"));
13807
+ },
13808
+ children: t(browserCopied === "error" ? "voiceBrowserCopyFailed" : browserCopied ? "voiceBrowserCopied" : "voiceBrowserCopy")
13809
+ }) : null]
13810
+ }) : null]
13380
13811
  }) : null] }), place.host) : null,
13381
13812
  live && place.activity && liveCall ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
13382
13813
  className: "codexVoiceTools",
@@ -13460,6 +13891,7 @@ void main(){
13460
13891
  function VoiceCallCard({ rpc, preference, snapshot, t }) {
13461
13892
  const audio = (0, react.useRef)();
13462
13893
  const previewSequence = (0, react.useRef)(0);
13894
+ const previewAbort = (0, react.useRef)();
13463
13895
  const alive = (0, react.useRef)(false);
13464
13896
  const [offered, setOffered] = (0, react.useState)();
13465
13897
  const [sample, setSample] = (0, react.useState)({
@@ -13471,39 +13903,62 @@ void main(){
13471
13903
  alive.current = true;
13472
13904
  return () => {
13473
13905
  alive.current = false;
13906
+ previewAbort.current?.abort();
13474
13907
  audio.current?.pause();
13475
13908
  };
13476
13909
  }, []);
13477
13910
  (0, react.useEffect)(() => {
13478
- if (!on) return;
13911
+ if (!on) {
13912
+ previewSequence.current++;
13913
+ previewAbort.current?.abort();
13914
+ audio.current?.pause();
13915
+ setSample({
13916
+ state: "idle",
13917
+ note: ""
13918
+ });
13919
+ setOffered(void 0);
13920
+ return;
13921
+ }
13922
+ const controller = new AbortController();
13923
+ setOffered(void 0);
13479
13924
  (async () => {
13480
13925
  try {
13481
- const result = await rpc.call(CHANNEL, "voice/catalog", {});
13482
- if (alive.current && result.ok) setOffered(result.value.voices);
13926
+ const result = await rpc.call(CHANNEL, "voice/catalog", { language: snapshot.voiceLanguage }, controller.signal);
13927
+ if (alive.current && !controller.signal.aborted && result.ok) setOffered(result.value.voices);
13483
13928
  } catch {}
13484
13929
  })();
13485
- }, [on]);
13930
+ return () => controller.abort();
13931
+ }, [
13932
+ on,
13933
+ snapshot.voiceLanguage,
13934
+ rpc
13935
+ ]);
13486
13936
  /** Play a short clip of a voice; picking a voice plays it too, so it can be heard before it is used. */
13487
13937
  const playVoice = async (voice, language = snapshot.voiceLanguage) => {
13488
13938
  const sequence = ++previewSequence.current;
13939
+ previewAbort.current?.abort();
13940
+ const controller = new AbortController();
13941
+ previewAbort.current = controller;
13489
13942
  audio.current?.pause();
13490
13943
  setSample({
13491
13944
  state: "loading",
13492
13945
  note: ""
13493
13946
  });
13947
+ let phase = "request";
13494
13948
  try {
13495
13949
  const result = await rpc.call(CHANNEL, "voice/preview", {
13496
13950
  voice,
13497
13951
  language
13498
- });
13952
+ }, controller.signal);
13499
13953
  if (!alive.current || sequence !== previewSequence.current) return;
13500
13954
  if (!result.ok) {
13501
13955
  setSample({
13502
- state: "missing",
13503
- note: ""
13956
+ state: "error",
13957
+ code: voicePreviewProblem(result.error?.code)
13504
13958
  });
13505
13959
  return;
13506
13960
  }
13961
+ phase = "playback";
13507
13962
  const clip = new Audio(result.value.audio);
13508
13963
  audio.current = clip;
13509
13964
  clip.onended = () => {
@@ -13512,15 +13967,21 @@ void main(){
13512
13967
  state: "idle"
13513
13968
  }));
13514
13969
  };
13970
+ clip.onerror = () => {
13971
+ if (alive.current && sequence === previewSequence.current) setSample({
13972
+ state: "error",
13973
+ code: "voicePlaybackFailed"
13974
+ });
13975
+ };
13515
13976
  setSample({
13516
13977
  state: "playing",
13517
13978
  note: [result.value.description, result.value.accent].filter(Boolean).join(" · ")
13518
13979
  });
13519
13980
  await clip.play();
13520
13981
  } catch {
13521
- if (alive.current && sequence === previewSequence.current) setSample({
13522
- state: "missing",
13523
- note: ""
13982
+ if (alive.current && sequence === previewSequence.current && !controller.signal.aborted) setSample({
13983
+ state: "error",
13984
+ code: voicePreviewProblem(phase === "playback" ? "playback" : void 0)
13524
13985
  });
13525
13986
  }
13526
13987
  };
@@ -13597,10 +14058,10 @@ void main(){
13597
14058
  role: "status",
13598
14059
  children: sample.note
13599
14060
  }) : null,
13600
- sample.state === "missing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14061
+ sample.state === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
13601
14062
  className: "codexSubscriptionHelp",
13602
14063
  role: "status",
13603
- children: t("voiceNoSample")
14064
+ children: t(sample.code)
13604
14065
  }) : null,
13605
14066
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceRow, {
13606
14067
  label: t("voiceLanguage"),
@@ -13612,9 +14073,13 @@ void main(){
13612
14073
  playVoice(snapshot.voiceVoice, value);
13613
14074
  }
13614
14075
  }),
13615
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
14076
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
13616
14077
  className: "codexSubscriptionHelp",
13617
- children: t("voicePreviewHint")
14078
+ children: [
14079
+ t("voicePreviewHint"),
14080
+ " ",
14081
+ t("voiceMediaHint")
14082
+ ]
13618
14083
  })
13619
14084
  ] }) : null]
13620
14085
  });
@@ -13835,6 +14300,86 @@ void main(){
13835
14300
  })]
13836
14301
  });
13837
14302
  }
14303
+ Object.freeze({
14304
+ imageCapability: ["imageGeneration", "imageEditing"],
14305
+ imageEntryPoints: ["imageShortcut"],
14306
+ sketchCanvas: ["imageSketch"],
14307
+ sketchAgent: ["imageSketchAgent"],
14308
+ imageBrowsing: ["imageViewer", "imageAnnotations"]
14309
+ });
14310
+ //#endregion
14311
+ //#region src/image-preferences.jsx
14312
+ function ImageChoice({ t, label, hint, value, text, items, disabled, onSelect }) {
14313
+ const [open, setOpen] = (0, react.useState)(false);
14314
+ const anchor = (0, react.useRef)(null);
14315
+ (0, react.useEffect)(() => {
14316
+ if (!open || disabled) return;
14317
+ const escape = (event) => {
14318
+ if (event.key !== "Escape") return;
14319
+ event.preventDefault();
14320
+ event.stopPropagation();
14321
+ setOpen(false);
14322
+ anchor.current?.focus();
14323
+ };
14324
+ window.addEventListener("keydown", escape, true);
14325
+ return () => window.removeEventListener("keydown", escape, true);
14326
+ }, [open, disabled]);
14327
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14328
+ className: "codexSubscriptionPreference codexImagePreference",
14329
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14330
+ className: "codexSubscriptionPreferenceCopy",
14331
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }), hint ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
14332
+ t,
14333
+ children: hint
14334
+ }) : null]
14335
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Menu, {
14336
+ open: open && !disabled,
14337
+ items,
14338
+ selectedId: value,
14339
+ onSelect: (id) => {
14340
+ setOpen(false);
14341
+ onSelect(id);
14342
+ },
14343
+ onClose: () => setOpen(false),
14344
+ align: "end",
14345
+ side: "bottom",
14346
+ portal: true,
14347
+ compact: true,
14348
+ anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
14349
+ ref: anchor,
14350
+ type: "button",
14351
+ className: "codexSubscriptionContextTrigger",
14352
+ "aria-label": label,
14353
+ "aria-haspopup": "menu",
14354
+ "aria-expanded": open && !disabled,
14355
+ disabled,
14356
+ onClick: () => setOpen((current) => !current),
14357
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: text }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronDownOutline14, {})]
14358
+ })
14359
+ })]
14360
+ });
14361
+ }
14362
+ //#endregion
14363
+ //#region src/default-reasoning-preferences.jsx
14364
+ function DefaultReasoningEffortPreference({ preference, t }) {
14365
+ const snapshot = usePreferenceSnapshot(preference);
14366
+ const value = normalizeDefaultReasoningEffortChoice(snapshot[DEFAULT_REASONING_EFFORT_FIELD]);
14367
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageChoice, {
14368
+ t,
14369
+ label: t("defaultReasoningEffort"),
14370
+ hint: t("defaultReasoningEffortHint"),
14371
+ value,
14372
+ text: t(`defaultReasoningEffort_${value}`),
14373
+ items: DEFAULT_REASONING_EFFORTS.map((id) => ({
14374
+ id,
14375
+ label: t(`defaultReasoningEffort_${id}`)
14376
+ })),
14377
+ disabled: snapshot.status !== "ready" || !snapshot.writable || snapshot.saving,
14378
+ onSelect: (effort) => {
14379
+ preference.set({ [DEFAULT_REASONING_EFFORT_FIELD]: effort });
14380
+ }
14381
+ });
14382
+ }
13838
14383
  //#endregion
13839
14384
  //#region src/client-runtime-management.jsx
13840
14385
  function RuntimeManagement({ rpc, preference, t }) {
@@ -16428,6 +16973,7 @@ void main(){
16428
16973
  search: "search",
16429
16974
  image: "images",
16430
16975
  model: "transport",
16976
+ voice: "transport",
16431
16977
  login: "account",
16432
16978
  "quota-reset": "quota"
16433
16979
  };
@@ -16817,40 +17363,45 @@ void main(){
16817
17363
  }, [rpc]);
16818
17364
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
16819
17365
  className: "codexSubscriptionCard codexSubscriptionStorage",
16820
- "aria-label": t("storageTitle"),
17366
+ "aria-label": t("storageForecast"),
16821
17367
  children: [
16822
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("storageTitle") }),
16823
17368
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17369
+ className: "codexSubscriptionStorageHead",
17370
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17371
+ className: "codexSubscriptionStorageTitle",
17372
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("storageForecast") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("output", {
17373
+ role: "status",
17374
+ children: usage ? `${(usage.bytes / 1024).toFixed(1)} / ${(usage.limit / 1024).toFixed(0)} KiB` : t("storageLoading")
17375
+ })]
17376
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17377
+ className: "codexSubscriptionActions",
17378
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
17379
+ type: "button",
17380
+ variant: "outline",
17381
+ disabled: busy,
17382
+ onClick: () => void read(false),
17383
+ children: t("runtimeRefresh")
17384
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
17385
+ type: "button",
17386
+ variant: "outline",
17387
+ disabled: busy || !usage?.bytes,
17388
+ onClick: () => setConfirm(true),
17389
+ children: t("storageClear")
17390
+ })]
17391
+ })]
17392
+ }),
17393
+ usage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
16824
17394
  className: "codexSubscriptionStorageMeter",
16825
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("storageForecast") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("output", {
16826
- role: "status",
16827
- children: usage ? `${(usage.bytes / 1024).toFixed(1)} / ${(usage.limit / 1024).toFixed(0)} KiB` : t("storageLoading")
16828
- })] }), usage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
17395
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
16829
17396
  "aria-label": t("storageForecast"),
16830
17397
  value: usage.bytes,
16831
17398
  max: usage.limit
16832
- }) : null]
16833
- }),
17399
+ })
17400
+ }) : null,
16834
17401
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
16835
17402
  className: "codexSubscriptionHelp",
16836
17403
  children: t("storageHint")
16837
17404
  }),
16838
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
16839
- className: "codexSubscriptionActions",
16840
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
16841
- type: "button",
16842
- variant: "outline",
16843
- disabled: busy,
16844
- onClick: () => void read(false),
16845
- children: t("runtimeRefresh")
16846
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
16847
- type: "button",
16848
- variant: "outline",
16849
- disabled: busy || !usage?.bytes,
16850
- onClick: () => setConfirm(true),
16851
- children: t("storageClear")
16852
- })]
16853
- }),
16854
17405
  confirm ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
16855
17406
  className: "codexSubscriptionConfirm",
16856
17407
  role: "group",
@@ -17002,34 +17553,68 @@ void main(){
17002
17553
  const hint = snapshot.searchProvider === "dsh" ? "searchDshHint" : snapshot.searchProvider === "codex" ? "searchCodexHint" : "searchAutoHint";
17003
17554
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17004
17555
  className: "codexSubscriptionSearch",
17005
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17006
- className: "codexSubscriptionPreference",
17007
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17008
- className: "codexSubscriptionPreferenceCopy",
17009
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
17010
- className: "codexSubscriptionPreferenceLabel",
17011
- children: t("searchTitle")
17012
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
17013
- t,
17014
- children: t(hint)
17556
+ children: [
17557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17558
+ className: "codexSubscriptionPreference",
17559
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17560
+ className: "codexSubscriptionPreferenceCopy",
17561
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
17562
+ className: "codexSubscriptionPreferenceLabel",
17563
+ children: t("searchTitle")
17564
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
17565
+ t,
17566
+ children: t(hint)
17567
+ })]
17568
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17569
+ className: "codexSubscriptionSearchChoices codexSubscriptionQuotaModes",
17570
+ "data-saving": snapshot.saving || void 0,
17571
+ "aria-busy": snapshot.saving || void 0,
17572
+ role: "radiogroup",
17573
+ "aria-label": t("searchTitle"),
17574
+ children: [
17575
+ choice(SEARCH_PROVIDER_AUTO, t("searchAuto")),
17576
+ choice("dsh", "DSH"),
17577
+ choice(SEARCH_PROVIDER_CODEX, "Codex")
17578
+ ]
17015
17579
  })]
17016
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17017
- className: "codexSubscriptionSearchChoices codexSubscriptionQuotaModes",
17018
- "data-saving": snapshot.saving || void 0,
17019
- "aria-busy": snapshot.saving || void 0,
17020
- role: "radiogroup",
17021
- "aria-label": t("searchTitle"),
17022
- children: [
17023
- choice(SEARCH_PROVIDER_AUTO, t("searchAuto")),
17024
- choice("dsh", "DSH"),
17025
- choice(SEARCH_PROVIDER_CODEX, "Codex")
17026
- ]
17027
- })]
17028
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CapabilityPreferences, {
17029
- preference,
17030
- t,
17031
- section: "search"
17032
- })]
17580
+ }),
17581
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17582
+ className: "codexSubscriptionPreference",
17583
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17584
+ className: "codexSubscriptionPreferenceCopy",
17585
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
17586
+ className: "codexSubscriptionPreferenceLabel",
17587
+ children: t("fetchTitle")
17588
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
17589
+ t,
17590
+ children: t(!snapshot.fetchRoutingAvailable ? "fetchUnavailableHint" : snapshot.fetchProvider === "codex" ? "fetchCodexHint" : "fetchDshHint")
17591
+ })]
17592
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
17593
+ className: "codexSubscriptionSearchChoices codexSubscriptionQuotaModes",
17594
+ "data-saving": snapshot.saving || void 0,
17595
+ "aria-busy": snapshot.saving || void 0,
17596
+ role: "radiogroup",
17597
+ "aria-label": t("fetchTitle"),
17598
+ children: ["dsh", FETCH_PROVIDER_CODEX].map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
17599
+ className: "codexSubscriptionQuotaMode",
17600
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
17601
+ type: "radio",
17602
+ name: "codex-subscription-fetch-provider",
17603
+ checked: snapshot.fetchProvider === value,
17604
+ disabled: !writable || value === "codex" && !snapshot.fetchRoutingAvailable,
17605
+ onChange: () => {
17606
+ preference.set({ [FETCH_PROVIDER_FIELD]: value });
17607
+ }
17608
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: value === "codex" ? "Codex" : "DSH" })]
17609
+ }, value))
17610
+ })]
17611
+ }),
17612
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CapabilityPreferences, {
17613
+ preference,
17614
+ t,
17615
+ section: "search"
17616
+ })
17617
+ ]
17033
17618
  });
17034
17619
  }
17035
17620
  function InputImageDetailPreference({ preference, t }) {
@@ -17467,9 +18052,10 @@ void main(){
17467
18052
  function ModelCatalogStatus({ preference, t, title }) {
17468
18053
  const snapshot = usePreferenceSnapshot(preference);
17469
18054
  const online = snapshot.catalogStatus?.source === "online";
18055
+ const cached = snapshot.catalogStatus?.source === "cached";
17470
18056
  const { refresh: catalogRefresh } = snapshot.catalogStatus ?? {};
17471
18057
  const failed = snapshot.modelError || catalogRefresh === "failed";
17472
- const message = snapshot.modelsLoading || catalogRefresh === "refreshing" ? "catalogLoading" : failed && !online ? "catalogFailed" : online ? "catalogOnline" : "catalogSignedOut";
18058
+ const message = snapshot.modelsLoading || catalogRefresh === "refreshing" ? "catalogLoading" : failed && cached ? "catalogCachedFailed" : failed && !online ? "catalogFailed" : online ? "catalogOnline" : cached ? "catalogCached" : "catalogSignedOut";
17473
18059
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17474
18060
  className: "codexModelsHead",
17475
18061
  children: [
@@ -17479,7 +18065,7 @@ void main(){
17479
18065
  role: failed && !online ? "alert" : void 0,
17480
18066
  children: t(message)
17481
18067
  }),
17482
- online || catalogRefresh !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
18068
+ online || cached || catalogRefresh !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
17483
18069
  type: "button",
17484
18070
  variant: "outline",
17485
18071
  disabled: snapshot.modelsLoading,
@@ -17492,65 +18078,6 @@ void main(){
17492
18078
  ]
17493
18079
  });
17494
18080
  }
17495
- Object.freeze({
17496
- imageCapability: ["imageGeneration", "imageEditing"],
17497
- imageEntryPoints: ["imageShortcut"],
17498
- sketchCanvas: ["imageSketch"],
17499
- sketchAgent: ["imageSketchAgent"],
17500
- imageBrowsing: ["imageViewer", "imageAnnotations"]
17501
- });
17502
- //#endregion
17503
- //#region src/image-preferences.jsx
17504
- function ImageChoice({ t, label, hint, value, text, items, disabled, onSelect }) {
17505
- const [open, setOpen] = (0, react.useState)(false);
17506
- const anchor = (0, react.useRef)(null);
17507
- (0, react.useEffect)(() => {
17508
- if (!open || disabled) return;
17509
- const escape = (event) => {
17510
- if (event.key !== "Escape") return;
17511
- event.preventDefault();
17512
- event.stopPropagation();
17513
- setOpen(false);
17514
- anchor.current?.focus();
17515
- };
17516
- window.addEventListener("keydown", escape, true);
17517
- return () => window.removeEventListener("keydown", escape, true);
17518
- }, [open, disabled]);
17519
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17520
- className: "codexSubscriptionPreference codexImagePreference",
17521
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17522
- className: "codexSubscriptionPreferenceCopy",
17523
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }), hint ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Hint, {
17524
- t,
17525
- children: hint
17526
- }) : null]
17527
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Menu, {
17528
- open: open && !disabled,
17529
- items,
17530
- selectedId: value,
17531
- onSelect: (id) => {
17532
- setOpen(false);
17533
- onSelect(id);
17534
- },
17535
- onClose: () => setOpen(false),
17536
- align: "end",
17537
- side: "bottom",
17538
- portal: true,
17539
- compact: true,
17540
- anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
17541
- ref: anchor,
17542
- type: "button",
17543
- className: "codexSubscriptionContextTrigger",
17544
- "aria-label": label,
17545
- "aria-haspopup": "menu",
17546
- "aria-expanded": open && !disabled,
17547
- disabled,
17548
- onClick: () => setOpen((current) => !current),
17549
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: text }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconChevronDownOutline14, {})]
17550
- })
17551
- })]
17552
- });
17553
- }
17554
18081
  //#endregion
17555
18082
  //#region src/client-pages.jsx
17556
18083
  const ready = (snapshot) => snapshot.status === "ready" && snapshot.writable === true;
@@ -17808,6 +18335,10 @@ void main(){
17808
18335
  defaultModel,
17809
18336
  t
17810
18337
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "codexSubscriptionDivider" })] }),
18338
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultReasoningEffortPreference, {
18339
+ preference,
18340
+ t
18341
+ }),
17811
18342
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PickerModelsPreference, {
17812
18343
  preference,
17813
18344
  t
@@ -18773,6 +19304,10 @@ void main(){
18773
19304
  if (period.usedPercent !== void 0) return void 0;
18774
19305
  return period.endsAt > now ? "current" : "past";
18775
19306
  }
19307
+ const historyPeriodKey = (period) => `${period.startsAt}:${period.endsAt}:${period.windowMinutes ?? ""}`;
19308
+ function selectHistoryPeriod(periods, selected, now = Date.now()) {
19309
+ return periods.find((period) => historyPeriodKey(period) === selected) ?? periods.find((period) => period.startsAt <= now && period.endsAt > now) ?? periods[0];
19310
+ }
18776
19311
  //#endregion
18777
19312
  //#region src/usage-heatmap.js
18778
19313
  const pad = (value) => String(value).padStart(2, "0");
@@ -18959,7 +19494,7 @@ void main(){
18959
19494
  const amount = (value) => value > 0 && value < .1 ? "<0.1" : (value >= 10 ? Math.round(value) : Math.round(value * 10) / 10).toLocaleString(uiLocale());
18960
19495
  const labelOf = (dimension, key, t) => dimension === "model" ? key : LABELS.has(key) ? t(LABELS.get(key)) : key.replaceAll("_", " ");
18961
19496
  function Rows({ dimension, rows, total, t }) {
18962
- const top = Math.max(total, ...rows.map((row) => row.percent));
19497
+ const top = Math.max(total ?? 0, ...rows.map((row) => row.percent));
18963
19498
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
18964
19499
  className: "codexSubscriptionHistoryGroup",
18965
19500
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { children: t(`historyBy_${dimension}`) }), rows.toSorted((a, b) => b.percent - a.percent).map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -18979,7 +19514,7 @@ void main(){
18979
19514
  }, row.key))]
18980
19515
  });
18981
19516
  }
18982
- function UsageHistory({ rpc, t, signedIn, resetKey }) {
19517
+ function UsageHistory({ rpc, t, signedIn, resetKey, refreshKey }) {
18983
19518
  const [open, setOpen] = (0, react.useState)(false);
18984
19519
  const [state, setState] = (0, react.useState)({ status: "idle" });
18985
19520
  const [selected, setSelected] = (0, react.useState)();
@@ -18989,11 +19524,14 @@ void main(){
18989
19524
  setState({ status: "idle" });
18990
19525
  setSelected(void 0);
18991
19526
  }, [signedIn, resetKey]);
18992
- (0, react.useEffect)(() => {
18993
- if (!open || !signedIn || state.status !== "idle") return;
19527
+ const load = (0, react.useCallback)((force) => {
19528
+ if (!signedIn) return;
18994
19529
  const id = ++request.current;
18995
- setState({ status: "loading" });
18996
- recoveryCall(rpc, "usage/history", {}).then((value) => {
19530
+ setState((previous) => ({
19531
+ status: "loading",
19532
+ value: previous.value
19533
+ }));
19534
+ recoveryCall(rpc, "usage/history", { force }, 2e4).then((value) => {
18997
19535
  if (request.current === id) setState({
18998
19536
  status: "ready",
18999
19537
  value
@@ -19004,16 +19542,24 @@ void main(){
19004
19542
  message: error.message
19005
19543
  });
19006
19544
  });
19545
+ }, [signedIn, rpc]);
19546
+ (0, react.useEffect)(() => {
19547
+ if (!open || !signedIn) return;
19548
+ load(false);
19549
+ return () => {
19550
+ request.current += 1;
19551
+ };
19007
19552
  }, [
19008
19553
  open,
19009
19554
  signedIn,
19010
- state.status,
19011
- rpc
19555
+ resetKey,
19556
+ refreshKey,
19557
+ load
19012
19558
  ]);
19013
19559
  if (!signedIn) return null;
19014
19560
  const value = state.value;
19015
19561
  const periods = [...value?.periods ?? []].sort((a, b) => b.startsAt - a.startsAt);
19016
- const period = periods.find((item) => item.startsAt === selected) ?? periods.find((item) => item.usedPercent !== void 0);
19562
+ const period = selectHistoryPeriod(periods, selected);
19017
19563
  const reason = period === void 0 ? void 0 : pendingReason(period);
19018
19564
  const asOfDate = value?.asOf ? new Date(value.asOf).toLocaleDateString(uiLocale(), {
19019
19565
  month: "numeric",
@@ -19025,6 +19571,13 @@ void main(){
19025
19571
  onToggle: (event) => setOpen(event.currentTarget.open),
19026
19572
  children: [
19027
19573
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t("historyTitle") }),
19574
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
19575
+ className: "codexSubscriptionHistoryRefresh",
19576
+ type: "button",
19577
+ disabled: state.status === "loading",
19578
+ onClick: () => load(true),
19579
+ children: t("historyRefresh")
19580
+ }),
19028
19581
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
19029
19582
  "aria-live": "polite",
19030
19583
  children: [
@@ -19038,12 +19591,12 @@ void main(){
19038
19591
  role: "alert",
19039
19592
  children: state.message
19040
19593
  }) : null,
19041
- state.status === "ready" && value.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19594
+ state.status === "ready" && value?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19042
19595
  className: "codexSubscriptionEmpty",
19043
19596
  role: "status",
19044
19597
  children: t("historyUnavailable")
19045
19598
  }) : null,
19046
- state.status === "ready" && value.available !== false && period === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19599
+ state.status === "ready" && value?.available !== false && period === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19047
19600
  className: "codexSubscriptionEmpty",
19048
19601
  role: "status",
19049
19602
  children: t("historyEmpty")
@@ -19059,9 +19612,9 @@ void main(){
19059
19612
  type: "button",
19060
19613
  "aria-pressed": item === period,
19061
19614
  title: item.usedPercent === void 0 ? t("historyPending") : void 0,
19062
- onClick: () => setSelected(item.startsAt),
19615
+ onClick: () => setSelected(historyPeriodKey(item)),
19063
19616
  children: `${day(item.startsAt)}–${day(item.endsAt)}`
19064
- }, item.startsAt))
19617
+ }, historyPeriodKey(item)))
19065
19618
  }),
19066
19619
  reason === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
19067
19620
  className: "codexSubscriptionHistorySummary",
@@ -19069,8 +19622,13 @@ void main(){
19069
19622
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19070
19623
  className: "codexSubscriptionEmpty",
19071
19624
  role: "status",
19072
- children: fill(t(reason === "current" ? "historyPendingCurrent" : "historyPendingPast"), { date: asOfDate })
19625
+ children: fill(t(reason === "current" ? "historyPendingCurrent" : asOfDate ? "historyPendingPast" : "historyPendingPastUnknown"), { date: asOfDate })
19073
19626
  }),
19627
+ reason === void 0 && present.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19628
+ className: "codexSubscriptionEmpty",
19629
+ role: "status",
19630
+ children: t("historyNoBreakdown")
19631
+ }) : null,
19074
19632
  present.map((dimension) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Rows, {
19075
19633
  dimension,
19076
19634
  rows: period.breakdowns[dimension],
@@ -19109,26 +19667,6 @@ void main(){
19109
19667
  }), estimate ? ` ${t("creditsExpiryEstimate")}` : ""] })
19110
19668
  });
19111
19669
  }
19112
- /** A long window that will run out before it resets says so, in plain words with a day and part of the day. */
19113
- function PaceWarning({ window, t }) {
19114
- const now = Date.now();
19115
- const pace = quotaPace({
19116
- remainingPercent: window.remainingPercent,
19117
- windowSeconds: window.windowSeconds,
19118
- resetsAt: window.resetsAt,
19119
- now
19120
- });
19121
- if (pace === void 0) return null;
19122
- const words = paceWords(pace, now, {
19123
- t,
19124
- locale: uiLocale()
19125
- });
19126
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19127
- className: "codexSubscriptionPace",
19128
- role: "status",
19129
- children: fill(t("paceWarning"), words)
19130
- });
19131
- }
19132
19670
  function ResetTime({ resetsAt, t }) {
19133
19671
  const date = Number.isSafeInteger(resetsAt) ? validDate(resetsAt * 1e3) : void 0;
19134
19672
  if (date === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("resetUnknown") });
@@ -19356,42 +19894,12 @@ void main(){
19356
19894
  ])).get(error instanceof Error ? error.message : "") ?? "resetFailed");
19357
19895
  }
19358
19896
  function UsageCard({ rpc, t, signedIn, resetKey, preference }) {
19359
- const [usage, setUsage] = (0, react.useState)();
19360
- const [usageRefreshGeneration, setUsageRefreshGeneration] = (0, react.useState)(0);
19361
- const [busy, setBusy] = (0, react.useState)(false);
19362
- const [error, setError] = (0, react.useState)();
19363
- const request = (0, react.useRef)(0);
19897
+ const { usage, busy, error, now, refresh } = useQuotaUsage(rpc, signedIn);
19898
+ const forecastMode = usePreferenceSnapshot(preference).quickQuotaMode === QUICK_QUOTA_MODE_FORECAST;
19364
19899
  const load = (force) => {
19365
- if (!signedIn) return;
19366
- const id = ++request.current;
19367
- setBusy(true);
19368
- setError(void 0);
19369
- recoveryCall(rpc, "usage", { force }).then((next) => {
19370
- if (request.current === id) {
19371
- setUsage(next);
19372
- setUsageRefreshGeneration((value) => value + 1);
19373
- if (typeof window !== "undefined") window.dispatchEvent(new Event("codex-subscription:usage-loaded"));
19374
- if (force) notifyQuickQuota();
19375
- }
19376
- }).catch((error) => {
19377
- if (request.current === id) setError(error.message);
19378
- }).finally(() => {
19379
- if (request.current === id) setBusy(false);
19380
- });
19900
+ if (signedIn) refresh(force).catch(() => {});
19381
19901
  };
19382
- (0, react.useEffect)(() => {
19383
- setUsage(void 0);
19384
- if (signedIn) load(false);
19385
- else {
19386
- request.current += 1;
19387
- setUsage(void 0);
19388
- setError(void 0);
19389
- setBusy(false);
19390
- }
19391
- return () => {
19392
- request.current += 1;
19393
- };
19394
- }, [signedIn, resetKey]);
19902
+ const usageRefreshGeneration = usage?.fetchedAt ?? 0;
19395
19903
  const visibleUsage = signedIn ? usage : void 0;
19396
19904
  const limits = visibleUsage?.rateLimits ?? [];
19397
19905
  const exhausted = limits.some((limit) => limit.id !== "code_review" && limit.windows.some((window) => window.usedPercent >= 100));
@@ -19452,11 +19960,6 @@ void main(){
19452
19960
  className: "codexSubscriptionLimits",
19453
19961
  children: limits.flatMap((limit) => limit.windows.map((window, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
19454
19962
  className: "codexSubscriptionLimit",
19455
- "data-pace": quotaPace({
19456
- remainingPercent: window.remainingPercent,
19457
- windowSeconds: window.windowSeconds,
19458
- resetsAt: window.resetsAt
19459
- }) ? "true" : void 0,
19460
19963
  children: [
19461
19964
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
19462
19965
  className: "codexSubscriptionLimitTop",
@@ -19472,18 +19975,24 @@ void main(){
19472
19975
  }),
19473
19976
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
19474
19977
  className: "codexSubscriptionLimitMeta",
19475
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
19978
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
19476
19979
  className: "codexSubscriptionLimitPeriod",
19477
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: windowLabel(window.windowSeconds, t) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatQuotaForecast(window.forecast, t) })]
19980
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: windowLabel(window.windowSeconds, t) })
19478
19981
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResetTime, {
19479
19982
  resetsAt: window.resetsAt,
19480
19983
  t
19481
19984
  })]
19482
19985
  }),
19483
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PaceWarning, {
19484
- window,
19485
- t
19486
- })
19986
+ forecastMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
19987
+ className: "codexSubscriptionForecast",
19988
+ role: "status",
19989
+ children: formatQuotaForecast(window.forecast, t, {
19990
+ ...window,
19991
+ fetchedAt: visibleUsage.fetchedAt,
19992
+ now,
19993
+ refreshError: error !== void 0
19994
+ })
19995
+ }) : null
19487
19996
  ]
19488
19997
  }, `${limit.id}-${window.windowSeconds}-${index}`)))
19489
19998
  }),
@@ -19497,7 +20006,8 @@ void main(){
19497
20006
  rpc,
19498
20007
  t,
19499
20008
  signedIn,
19500
- resetKey
20009
+ resetKey,
20010
+ refreshKey: usageRefreshGeneration
19501
20011
  }),
19502
20012
  visibleUsage?.chatPass === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
19503
20013
  className: "codexSubscriptionLimits",
@@ -20014,6 +20524,27 @@ void main(){
20014
20524
  ];
20015
20525
  const ComposerRight = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodexComposerQuota, { ...props }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VoiceCallButton, { ...props })] });
20016
20526
  function apply(ctx) {
20527
+ if (new URL(window.location.href).searchParams.has("codexVoiceSession")) ctx.inject(["uiWorkspace", "sessions"], (scope) => scope.effect(() => {
20528
+ const sessions = scope.get("sessions"), controller = new AbortController();
20529
+ let attempted = false;
20530
+ const restore = () => {
20531
+ if (attempted || typeof sessions.list?.getSnapshot === "function" && sessions.list.getSnapshot().phase !== "ready") return;
20532
+ attempted = true;
20533
+ restoreVoiceConversation({
20534
+ href: window.location.href,
20535
+ workspace: scope.get("uiWorkspace"),
20536
+ history: window.history,
20537
+ sessions,
20538
+ signal: controller.signal
20539
+ }).catch(() => {});
20540
+ };
20541
+ const unsubscribe = sessions.list?.subscribe?.(restore) ?? (() => {});
20542
+ restore();
20543
+ return () => {
20544
+ controller.abort();
20545
+ unsubscribe();
20546
+ };
20547
+ }, "codex-subscription: browser voice conversation"));
20017
20548
  const diagnostics = createHostDiagnostics();
20018
20549
  ctx.effect(() => diagnostics.register(ctx.slots), "codex-subscription: host inspection");
20019
20550
  const imageViewer = new SubscriptionImageViewerService();
@@ -20030,6 +20561,17 @@ void main(){
20030
20561
  }, "codex-subscription: style");
20031
20562
  const rpc = createSubscriptionRpcClient(ctx.get("connection").rpc);
20032
20563
  const preference = createPreferenceController(rpc);
20564
+ const quotaUsage = quotaUsageController(rpc);
20565
+ ctx.effect(() => {
20566
+ let mode = preference.getSnapshot().quickQuotaMode;
20567
+ return preference.subscribe(() => {
20568
+ const next = preference.getSnapshot().quickQuotaMode;
20569
+ if (next !== mode) {
20570
+ mode = next;
20571
+ quotaUsage.invalidate({ preserveUsage: true });
20572
+ }
20573
+ });
20574
+ }, "codex-subscription: quota preference snapshot");
20033
20575
  const defaultModel = createDefaultModelController(rpc);
20034
20576
  ctx.effect(() => {
20035
20577
  let previous = JSON.stringify(preference.getSnapshot(), (key, value) => key.startsWith("image") || key === "" ? value : void 0);
@@ -20044,6 +20586,7 @@ void main(){
20044
20586
  preference.load();
20045
20587
  accountStatus.load();
20046
20588
  const disposeReset = ctx.on("connection/reset", () => {
20589
+ quotaUsage.invalidate();
20047
20590
  preference.load();
20048
20591
  preference.refreshModels();
20049
20592
  accountStatus.reload();