dsh-github-copilot 0.4.0-alpha.108 → 0.4.0-alpha.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/CHANGELOG.md +7 -0
- package/README.md +11 -7
- package/README.zh.md +11 -7
- package/deployment-baseline.json +24 -2
- package/docs/account-management-experience.md +93 -0
- package/docs/copilot-accounts.md +11 -4
- package/docs/mockups/copilot-account-management.html +393 -0
- package/docs/session-continuation.md +87 -0
- package/lib/client.js +980 -133
- package/lib/client.js.map +1 -1
- package/lib/index.js +541 -85
- package/lib/remote.js +68 -7
- package/lib/types/client.d.ts +3 -0
- package/lib/types/composer-notice-style.d.ts +2 -0
- package/lib/types/config.d.ts +19 -2
- package/lib/types/copilot-accounts-card.d.ts +13 -2
- package/lib/types/copilot-usage-card.d.ts +6 -0
- package/lib/types/replay-recovery-ui.d.ts +3 -1
- package/lib/types/responses-replay-compat.d.ts +1 -1
- package/lib/types/session-continuation-host.d.ts +42 -0
- package/lib/types/session-continuation-remote.d.ts +22 -0
- package/lib/types/session-continuation-types.d.ts +35 -0
- package/lib/types/session-continuation-ui.d.ts +47 -0
- package/lib/types/session-continuation.d.ts +13 -0
- package/package.json +4 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<title>Chat → Models · 完整多账号体验 Mock</title>
|
|
5
|
+
<!-- Shared current-account summary; searchable bounded selector only after Switch.
|
|
6
|
+
Chat owns session selection, Models owns global default. All data is synthetic. -->
|
|
7
|
+
<style>
|
|
8
|
+
:root{color-scheme:dark;--bg:#171717;--panel:#252525;--text:#eee;--muted:#bdbdbd;--line:#555;--hover:#353535;--accent:#b9d5ff}
|
|
9
|
+
*{box-sizing:border-box}body{margin:0;padding:24px;background:var(--bg);color:var(--text);font:13px/1.55 system-ui,"Segoe UI",sans-serif}
|
|
10
|
+
button,input,select,textarea{font:inherit;color:inherit}button,select,input{background:transparent;border:1px solid var(--line);border-radius:6px;padding:7px 10px}
|
|
11
|
+
button{cursor:pointer}button:hover{background:var(--hover)}button:disabled{opacity:.5;cursor:default}button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
|
12
|
+
header{display:flex;gap:14px;align-items:center;flex-wrap:wrap;padding-bottom:14px;border-bottom:1px solid var(--line)}header span,p,small{color:var(--muted)}
|
|
13
|
+
nav{display:flex;gap:8px;margin:20px 0}nav button[aria-pressed=true]{background:var(--hover)}main{max-width:952px;margin:auto}
|
|
14
|
+
h1{font-size:22px;margin:0 0 18px}h2{font-size:17px;margin:0}p{margin:6px 0}small{font-size:12px}.row{display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
15
|
+
.history{height:160px;display:grid;place-content:center;color:var(--muted)}.composer{border:1px solid var(--line);border-radius:12px;padding:12px}textarea{width:100%;min-height:72px;background:none;border:0;resize:vertical}.toolbar{display:flex;justify-content:space-between;color:var(--muted)}
|
|
16
|
+
.dock{display:flex;justify-content:flex-end;margin:8px 0}.quiet{border:0;color:var(--accent)}.account-surface{position:relative;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:16px;width:min(100%,430px);margin-left:auto;box-shadow:0 6px 20px #0003}.models .account-surface{width:100%;margin:0;box-shadow:none}
|
|
17
|
+
.identity{min-width:0}.identity strong{display:block}.identity small{display:block}.account-summary{padding:12px 0}.section{border-top:1px solid var(--line);padding-top:14px;margin-top:10px}
|
|
18
|
+
.selector{border-top:1px solid var(--line);padding-top:12px}.search{width:100%;margin:10px 0}.account-list{max-height:220px;overflow:auto;overscroll-behavior:contain}.account-option{display:flex;justify-content:space-between;align-items:center;gap:12px;border:0;width:100%;text-align:left;padding:9px 8px}.account-option[aria-pressed=true]{background:var(--hover)}.account-option small{display:block}.selected{color:var(--accent);white-space:nowrap}.selector-footer{border-top:1px solid var(--line);padding-top:10px;margin-top:8px}.selector-footer button{width:100%;text-align:left}
|
|
19
|
+
.notice{padding:8px 10px;background:var(--hover);border-radius:6px;margin:10px 0}.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.primary{background:#e4e4e4;color:#171717;border-color:#e4e4e4}.primary:hover{background:white}
|
|
20
|
+
details p{font-size:12px}summary{cursor:pointer}.label{display:block;margin-top:10px}input[type=checkbox]{accent-color:#adcfff}
|
|
21
|
+
.models-list{margin-top:20px;border-top:1px solid var(--line)}.model-row{padding:12px 0;border-bottom:1px solid var(--line)}.simulation{margin:24px auto 0;max-width:952px;border-top:1px dashed var(--line);padding-top:14px;display:flex;align-items:center;flex-wrap:wrap;gap:8px;color:var(--muted);font-size:12px}
|
|
22
|
+
[hidden]{display:none!important}.save-error{color:var(--text)}#status{font-size:12px;min-height:18px}
|
|
23
|
+
@media(max-width:480px){body{padding:14px}.history{height:90px}.account-surface{padding:14px}.row{gap:8px}.row select{max-width:150px}.account-list{max-height:190px}header{gap:6px}}
|
|
24
|
+
@media(prefers-color-scheme:light){:root{color-scheme:light;--bg:#fafafa;--panel:#fff;--text:#222;--muted:#555;--line:#bbb;--hover:#f0f0f0;--accent:#24599b}.primary{background:#303030;color:white;border-color:#303030}.primary:hover{background:#444}}
|
|
25
|
+
|
|
26
|
+
body{background:#191919;padding:24px;color-scheme:dark}
|
|
27
|
+
.app-backdrop{position:fixed;inset:0;z-index:-1;display:grid;grid-template-columns:220px 1fr;opacity:.35;pointer-events:none;color:#bbb}
|
|
28
|
+
.app-sidebar{border-right:1px solid #555;padding:100px 16px 24px}.app-sidebar div{margin:22px 0}.app-chat{padding:100px 60px}
|
|
29
|
+
header{max-width:1100px;margin:0 auto 18px;border:0;padding:0;font-size:12px}
|
|
30
|
+
.settings-shell{display:grid;grid-template-columns:185px minmax(0,1fr);max-width:880px;height:min(820px,calc(100vh - 110px));min-height:480px;margin:auto;border-radius:22px;background:#2a2a2c;box-shadow:0 18px 60px #0006;overflow:hidden;border:1px solid #3b3b3d}
|
|
31
|
+
.settings-nav{padding:24px 12px}.settings-nav strong{display:block;margin:0 12px 22px;font-size:16px}.settings-nav button{display:block;text-align:left;width:100%;margin:6px 0;border:0;padding:10px 12px}.settings-nav .active{background:#444449}
|
|
32
|
+
main{max-width:none;margin:0;padding:20px 24px;overflow:auto;min-width:0;background:#2a2a2c}
|
|
33
|
+
main>nav{display:none}.settings-actions{display:flex;justify-content:flex-end;gap:8px;margin-bottom:16px}.settings-actions button{font-size:12px}
|
|
34
|
+
h1{font-size:17px;margin-bottom:12px}h2{font-size:17px}.intro{margin-bottom:20px}
|
|
35
|
+
.native-provider{display:flex;align-items:center;justify-content:space-between;border:1px solid #48484b;border-radius:12px;padding:13px;margin-top:18px}
|
|
36
|
+
.missing{color:#fb7777;font-size:12px}.native-add{width:100%;border-style:dashed;margin:10px 0 24px;padding:12px}
|
|
37
|
+
.models .account-surface{background:transparent;border-color:#48484b;border-radius:12px;padding:14px}
|
|
38
|
+
.account-summary{padding:14px 0}.account-summary strong{font-size:14px}.section{border-color:#48484b}
|
|
39
|
+
.provider-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:4px 0 14px}.provider-heading span{color:#bdbdbd;font-size:12px}.provider-heading strong{font-size:15px}
|
|
40
|
+
.model-status{border-top:1px solid #48484b;padding-top:14px;margin-top:14px;display:flex;gap:8px;align-items:center;flex-wrap:wrap}.model-status small{font-size:12px}.model-status button{margin-left:auto}
|
|
41
|
+
.manage{margin-top:12px;border-top:1px solid #48484b;padding-top:12px}.manage details{padding:8px 0}.manage summary{font-size:13px}.manage .actions button{font-size:12px}
|
|
42
|
+
.preferences{display:grid;gap:6px;max-height:190px;overflow:auto;margin-top:10px}.preference{display:flex;align-items:center;gap:10px;padding:5px}.preference input{accent-color:#adcfff}
|
|
43
|
+
#policy{margin:12px 0 0}#policy-summary{font-size:13px}#models-list{display:none!important}
|
|
44
|
+
.simulation{max-width:880px;margin:16px auto;background:#191919;border:0}
|
|
45
|
+
.account-list{max-height:210px}#policy-details>p{font-size:12px}
|
|
46
|
+
.management-section+.management-section{border-top:1px solid #48484b;margin-top:20px;padding-top:18px}.management-section h3{font-size:15px;margin:0 0 8px}.compact-identity{color:#bdbdbd;font-size:12px;margin-top:4px}.model-status{border:0;padding:0;margin:0}.provider-heading{margin-bottom:8px}.model-owner{font-size:12px;color:#bdbdbd;margin-bottom:10px}.manage{padding-top:18px;margin-top:16px}.manage .account-summary{padding-top:0}.management-section #policy{padding-top:10px}
|
|
47
|
+
.account-entry{display:flex;align-items:center;gap:6px}.account-entry .account-option{flex:1;min-width:0}.remove-account{border:0;color:#ffb3b3;font-size:12px;flex-shrink:0}.remove-review{padding:12px;background:#353535;border-radius:6px;margin:10px 0}.model-search{width:100%;margin:8px 0}.model-filters{display:flex;gap:6px;flex-wrap:wrap}.model-filters button[aria-pressed=true]{background:#444449}.model-preference{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 0;border-bottom:1px solid #48484b}.model-preference small{display:block}.model-preference strong{font-size:13px}.model-preference button{flex-shrink:0;font-size:12px}
|
|
48
|
+
@media(max-width:620px){body{padding:12px}.settings-shell{grid-template-columns:1fr;height:calc(100vh - 160px);min-height:450px;border-radius:14px}.settings-nav{display:none}main{padding:16px}.settings-actions{margin-bottom:12px}header{flex-direction:column;align-items:flex-start}.simulation{margin-top:12px}.model-status button{margin-left:0}}
|
|
49
|
+
|
|
50
|
+
.settings-shell{position:fixed;z-index:10;left:50%;top:80px;transform:translateX(-50%);width:calc(100% - 40px);max-height:calc(100vh - 110px)}
|
|
51
|
+
.modal-shade{position:fixed;inset:0;background:#0009;z-index:9}
|
|
52
|
+
.settings-actions{position:sticky;top:0;z-index:2;background:#2a2a2c;padding:8px 0;border-bottom:1px solid #48484b}
|
|
53
|
+
select{color-scheme:dark;background:#252525;color:#eee}option{background:#252525;color:#eee}
|
|
54
|
+
.switch-review,.replay-guidance{padding:12px;background:#353535;border:1px solid #555;border-radius:8px;margin:12px 0}
|
|
55
|
+
.switch-review strong,.replay-guidance strong{display:block;margin-bottom:6px}.switch-review button,.replay-guidance button{font-size:12px}
|
|
56
|
+
.chat-host .history{height:auto;min-height:210px;display:flex;flex-direction:column;gap:18px;padding:20px 0;color:#eee}.mock-message{max-width:78%;padding:12px 16px;border-radius:10px;background:#252525}.mock-message.user{align-self:flex-end;background:#303036}.mock-message p{margin:5px 0}.mock-message small{display:block;color:#bdbdbd}.mock-message.failure{max-width:100%;border:1px solid #795454;background:#302727}.mock-message .actions{margin-top:10px}.scenario-heading{color:#bdbdbd;font-size:12px}
|
|
57
|
+
.chat-host{max-width:952px;margin:45px auto 0}.chat-host .history{height:210px}
|
|
58
|
+
.chat-host .account-surface{background:#252525;width:min(100%,430px);max-height:62vh;overflow:auto}
|
|
59
|
+
.chat-host .provider-heading{margin-bottom:0}.chat-host .account-summary{padding:12px 0}
|
|
60
|
+
.chat-host .model-status,.chat-host .compact-identity{display:none}
|
|
61
|
+
.chat-host .manage{border:0;padding:0;margin:0}
|
|
62
|
+
.chat-host #policy{border-top:1px solid #555;margin-top:12px;padding-top:12px}
|
|
63
|
+
.chat-host .preferences{display:none}.manage-link{border-top:1px solid #555;margin-top:12px;padding-top:10px;display:flex;justify-content:flex-end}
|
|
64
|
+
.chat-host .account-surface .management-section h3{display:none}
|
|
65
|
+
.mock-caption{max-width:952px;margin:12px auto;color:#bdbdbd;font-size:12px}
|
|
66
|
+
@media(max-width:620px){.settings-shell{top:72px;width:calc(100% - 24px);height:calc(100vh - 100px)}.chat-host{margin-top:20px}.chat-host .history{height:auto;min-height:100px}}
|
|
67
|
+
</style>
|
|
68
|
+
<div class="app-backdrop"><div class="app-sidebar"><strong>deepseek HARNESS</strong><div>+ New Session</div><div>Plugins</div><div>Automation tasks</div><div>Workspaces</div></div><div class="app-chat">Chat</div></div>
|
|
69
|
+
<header><strong>Chat → Models · 完整多账号体验 Mock</strong><span>参照当前 Desktop Settings;24 个虚构账号,不操作真实账号或设置</span></header>
|
|
70
|
+
<div class="settings-shell"><aside class="settings-nav"><strong>Settings</strong><button>⚙ General</button><button class="active">▤ Models</button><button>Built-in plugins</button><button>Agent presets</button></aside>
|
|
71
|
+
<main><div class="settings-actions"><button disabled>Open configuration file</button><button disabled aria-label="Close Settings">×</button></div>
|
|
72
|
+
<nav aria-label="预览页面"><button id="chat-tab" aria-pressed="true">Chat 页面</button><button id="models-tab" aria-pressed="false">Models 页面</button></nav>
|
|
73
|
+
<div id="chat"><div class="history">聊天区不显示账号列表或续聊设置</div><div class="composer"><textarea aria-label="模拟消息" placeholder="输入消息或任务…(仅模拟)"></textarea><div class="toolbar"><span>+ Full access⌄</span><span>GPT-6.1 Sol⌄ <button disabled aria-label="发送已禁用">↑</button></span></div></div><div class="dock"><button id="credits" class="quiet">Credits · <span id="dock-account"></span> ⌄</button></div></div>
|
|
74
|
+
<div id="models-heading" hidden><h1>Models</h1><p class="intro">Enter your API keys to use models from the following providers.</p>
|
|
75
|
+
<div class="native-provider"><span><strong>DeepSeek</strong> <span class="missing" title="API key missing">●</span></span><button disabled>Edit</button></div><button class="native-add" disabled>+ Add model provider</button></div>
|
|
76
|
+
<div id="surface-holder">
|
|
77
|
+
<section class="account-surface" aria-label="Copilot 账号">
|
|
78
|
+
<div class="provider-heading"><strong>GitHub Copilot</strong><span id="scope">全局默认</span></div>
|
|
79
|
+
<div class="row account-summary"><div class="identity"><strong id="current-name"></strong><small id="current-credit"></small><small id="source"></small></div><button id="switch" aria-expanded="false" aria-controls="selector">Switch</button></div>
|
|
80
|
+
<p id="running" class="notice" hidden></p>
|
|
81
|
+
<div id="selector" class="selector" hidden>
|
|
82
|
+
<div class="row"><strong id="selector-title">切换本 Session 账号</strong><button id="cancel-switch" class="quiet">取消</button></div>
|
|
83
|
+
<input id="search" class="search" type="search" aria-label="搜索账号" placeholder="搜索账号名称或标识">
|
|
84
|
+
<div id="account-list" class="account-list" role="group" aria-label="可选账号"></div>
|
|
85
|
+
<p id="empty" hidden>未找到匹配账号。可修改搜索,或添加新账号。</p>
|
|
86
|
+
<p id="save-error" class="save-error" role="alert" hidden>模拟保存失败,原账号保持不变。<button id="retry" class="quiet">重试</button></p>
|
|
87
|
+
<div class="selector-footer"><button id="add">+ 添加新账号</button></div>
|
|
88
|
+
<div id="add-view" hidden><label class="label" for="new-name">账号显示名称</label><input id="new-name" placeholder="例如:备用工作账号"><p><small>正式功能将在 GitHub 授权完成后添加。这里只模拟,不收集 token 或凭据。</small></p><div class="actions"><button id="finish-add">模拟授权完成</button><button id="cancel-add" class="quiet">取消添加</button></div><p id="add-error" role="alert" hidden>请输入账号显示名称。</p></div>
|
|
89
|
+
</div>
|
|
90
|
+
<p><small>全局默认用于跟随默认的后续轮次。正在运行的轮次和 Session 显式账号不变。</small></p><div class="section" id="policy">
|
|
91
|
+
<details id="policy-details"><summary id="policy-summary">降级续聊 · 关闭</summary>
|
|
92
|
+
<div id="session-policy-view"><div class="row" style="margin-top:12px"><label for="session-policy">本 Session 默认策略</label><select id="session-policy"><option value="follow">沿用创建时默认</option><option value="on">开启</option><option value="off">关闭</option></select></div><p><small>每个新轮次不回放旧加密推理及内嵌摘要,同账号也适用;可见消息、工具记录和磁盘历史不变。</small></p><div id="shortcuts" class="actions"><button id="once">仅下一轮降级</button><button id="enable" class="primary">一键持续开启</button></div><p id="consent"><small>点击即同意上述损失,不自动发送或重试。</small></p><p id="once-state" hidden>已授权仅下一轮降级 <button id="revoke" class="quiet">撤销</button></p></div>
|
|
93
|
+
<div id="global-policy-view" hidden><label class="label"><input id="global-policy" type="checkbox"> 新 Session 默认开启降级续聊</label><p><small>勾选即同意新 Session 每轮不回放旧加密推理及内嵌摘要,同账号也适用。已有 Session 不批量修改。</small></p></div>
|
|
94
|
+
<p><small>可能失去旧推理隐含细节。关闭不恢复已生成回答。不解决额度、408 或上下文超限,也不保证请求成功。</small></p>
|
|
95
|
+
</details>
|
|
96
|
+
</div>
|
|
97
|
+
<div class="model-status"><strong>Models</strong><small>Signed in</small><small>19 models</small><small title="Synthetic timestamp">Updated 1 hour ago</small><button id="manage-toggle" aria-expanded="false">Manage</button></div>
|
|
98
|
+
<div id="manage" class="manage" hidden>
|
|
99
|
+
<details><summary>Model preferences · <span id="enabled-count">7</span> enabled · exclusions</summary><p><small>取消勾选将排除模型,不改写已有 Session 的选择。</small></p><div class="preferences">
|
|
100
|
+
<label class="preference"><input class="model-enabled" type="checkbox" checked> GPT-6.1 Sol</label><label class="preference"><input class="model-enabled" type="checkbox" checked> GPT-6 Sol</label><label class="preference"><input class="model-enabled" type="checkbox" checked> Claude Sonnet</label><label class="preference"><input class="model-enabled" type="checkbox" checked> Claude Opus</label><label class="preference"><input class="model-enabled" type="checkbox" checked> Gemini Pro</label><label class="preference"><input class="model-enabled" type="checkbox" checked> GPT-5.4</label><label class="preference"><input class="model-enabled" type="checkbox" checked> GPT-5.4 mini</label></div></details>
|
|
101
|
+
<details><summary>Discovery details</summary><p><small>模拟:账号模型缓存有效。时间戳、账号及模型均为演示数据,不证明线上可用性。</small></p></details>
|
|
102
|
+
<div class="actions"><button id="refresh-models">Refresh models</button><button id="refresh-identity">Refresh account information</button><button id="reauthorize">Reauthorize</button></div>
|
|
103
|
+
<p><small>以上操作作用于当前默认账号。此 mock 仅模拟状态,不发起授权或网络请求。</small></p></div>
|
|
104
|
+
<p id="status" role="status" aria-live="polite"></p>
|
|
105
|
+
</section>
|
|
106
|
+
</div>
|
|
107
|
+
<div id="models-list" class="models-list" hidden><div class="model-row row"><span>GPT-6.1 Sol</span><small>演示模型 · 可用</small></div><div class="model-row row"><span>Claude Sonnet</span><small>演示模型 · 可用</small></div></div>
|
|
108
|
+
</main></div>
|
|
109
|
+
<aside class="simulation"><span>演示专用:</span><button id="turn">开始模拟轮</button><button id="new-session">模拟新 Session</button><label><input id="fail" type="checkbox">下一次切换保存失败</label><span>不属于正式产品控件。</span></aside>
|
|
110
|
+
<script>
|
|
111
|
+
const $=id=>document.getElementById(id)
|
|
112
|
+
const accounts=Array.from({length:24},(_,i)=>({id:String(i+1),name:i===0?'个人账号':i===1?'工作账号':`备用账号 ${String(i+1).padStart(2,'0')}`,handle:`demo-account-${String(i+1).padStart(2,'0')}`,credits:i===0?'180 / 300':i===1?'420 / 1,000':'未读取额度'}))
|
|
113
|
+
let page='chat',globalAccount='1',sessionAccount=null,globalOn=false,initialOn=false,policy='follow',once=false,active=null,saving=false,target=null
|
|
114
|
+
const effective=()=>sessionAccount??globalAccount
|
|
115
|
+
const on=()=>policy==='follow'?initialOn:policy==='on'
|
|
116
|
+
const find=id=>accounts.find(a=>a.id===id)
|
|
117
|
+
function status(s){$('status').textContent=s}
|
|
118
|
+
function closeSelector(){$('selector').hidden=true;$('switch').setAttribute('aria-expanded','false');$('search').value='';$('add-view').hidden=true;$('switch').focus()}
|
|
119
|
+
function render(){
|
|
120
|
+
const current=find(page==='chat'?effective():globalAccount)
|
|
121
|
+
$('current-name').textContent=current.name
|
|
122
|
+
$('current-credit').textContent=current.credits==='未读取额度'?'额度未读取':current.credits+' Credits 剩余 · 演示账期数据'
|
|
123
|
+
$('source').textContent=page==='models'?'全局默认账号':sessionAccount===null?'跟随全局默认':'本 Session 已指定'
|
|
124
|
+
$('scope').textContent=page==='chat'?'本 Session':'全局默认'
|
|
125
|
+
$('dock-account').textContent=active?find(active.account).name+(active.account!==effective()?' → 下轮 '+find(effective()).name:''):find(effective()).name
|
|
126
|
+
$('running').hidden=page!=='chat'||!active
|
|
127
|
+
$('running').textContent=active?'本轮:'+find(active.account).name+' · '+(active.on?'降级开启':'降级关闭')+';下一轮:'+find(effective()).name+' · '+(on()||once?'降级开启':'降级关闭'):''
|
|
128
|
+
$('policy-summary').textContent=page==='models'?'新 Session 降级默认 · '+(globalOn?'开启':'关闭'):'降级续聊 · '+(on()?'开启':once?'仅下一轮':'关闭')
|
|
129
|
+
$('shortcuts').hidden=on();$('consent').hidden=on();$('once').disabled=once;$('once-state').hidden=!once
|
|
130
|
+
$('turn').textContent=active?'结束模拟轮':'开始模拟轮'
|
|
131
|
+
$('switch').disabled=saving
|
|
132
|
+
$('cancel-switch').disabled=saving;$('add').disabled=saving
|
|
133
|
+
renderList()
|
|
134
|
+
}
|
|
135
|
+
function renderList(){
|
|
136
|
+
const query=$('search').value.trim().toLowerCase(), list=$('account-list');list.replaceChildren()
|
|
137
|
+
const selected=page==='models'?globalAccount:sessionAccount
|
|
138
|
+
const entries=[...(page==='chat'?[{id:'follow',name:'跟随全局默认',handle:'当前默认:'+find(globalAccount).name}]:[]),...accounts].filter(a=>(a.name+' '+a.handle).toLowerCase().includes(query))
|
|
139
|
+
for(const a of entries){
|
|
140
|
+
const button=document.createElement('button');button.className='account-option';button.dataset.account=a.id;button.disabled=saving
|
|
141
|
+
const checked=a.id===(selected??'follow');button.setAttribute('aria-pressed',String(checked))
|
|
142
|
+
const text=document.createElement('span'),name=document.createElement('strong'),sub=document.createElement('small');name.textContent=a.name;sub.textContent=a.handle;text.append(name,sub)
|
|
143
|
+
const marker=document.createElement('span');marker.className='selected';marker.textContent=saving&&target===a.id?'保存中…':checked?'当前':''
|
|
144
|
+
button.append(text,marker);button.onclick=()=>choose(a.id);list.append(button)
|
|
145
|
+
}
|
|
146
|
+
$('empty').hidden=entries.length>0
|
|
147
|
+
}
|
|
148
|
+
async function choose(id){
|
|
149
|
+
if(saving)return;saving=true;target=id;$('save-error').hidden=true;render()
|
|
150
|
+
await new Promise(r=>setTimeout(r,250));saving=false
|
|
151
|
+
if($('fail').checked){$('fail').checked=false;$('save-error').hidden=false;status('保存失败;账号未改变。');render();return}
|
|
152
|
+
if(page==='models')globalAccount=id;else sessionAccount=id==='follow'?null:id
|
|
153
|
+
closeSelector();status(page==='models'?'已模拟设置全局默认;已有 Session 的显式账号不变。':active?'已保存,下一轮生效;当前轮不受影响。':'已保存,下次发送使用所选账号。');render()
|
|
154
|
+
}
|
|
155
|
+
function setPage(next){
|
|
156
|
+
if(saving)return;page=next;closeSelector()
|
|
157
|
+
document.querySelector('.account-surface').hidden=false
|
|
158
|
+
$('chat').hidden=page!=='chat';$('models-heading').hidden=page!=='models';$('models-list').hidden=page!=='models'
|
|
159
|
+
$('surface-holder').className=page==='models'?'models':''
|
|
160
|
+
$('chat-tab').setAttribute('aria-pressed',String(page==='chat'));$('models-tab').setAttribute('aria-pressed',String(page==='models'))
|
|
161
|
+
$('session-policy-view').hidden=page!=='chat';$('global-policy-view').hidden=page!=='models'
|
|
162
|
+
$('selector-title').textContent=page==='chat'?'切换本 Session 账号':'设置全局默认账号';status('');render()
|
|
163
|
+
}
|
|
164
|
+
$('chat-tab').onclick=()=>setPage('chat');$('models-tab').onclick=()=>setPage('models')
|
|
165
|
+
$('switch').onclick=()=>{$('selector').hidden=!$('selector').hidden;$('switch').setAttribute('aria-expanded',String(!$('selector').hidden));if(!$('selector').hidden)$('search').focus();renderList()}
|
|
166
|
+
$('cancel-switch').onclick=closeSelector;$('search').oninput=renderList;$('retry').onclick=()=>choose(target)
|
|
167
|
+
$('credits').onclick=()=>{const surface=document.querySelector('.account-surface');surface.hidden=!surface.hidden}
|
|
168
|
+
$('add').onclick=()=>{$('add-view').hidden=false;$('new-name').focus()}
|
|
169
|
+
$('cancel-add').onclick=()=>{$('add-view').hidden=true}
|
|
170
|
+
$('finish-add').onclick=()=>{const name=$('new-name').value.trim();$('add-error').hidden=!!name;if(!name)return;accounts.push({id:String(accounts.length+1),name,handle:'demo-new-account',credits:'未读取额度'});$('search').value=name;$('add-view').hidden=true;$('new-name').value='';status('已模拟添加账号,尚未切换;请选择该账号使用。');render()}
|
|
171
|
+
$('session-policy').onchange=e=>{policy=e.target.value;if(on())once=false;status(active?'策略已保存,下一轮生效。':'本 Session 策略已模拟保存。');render()}
|
|
172
|
+
$('global-policy').onchange=e=>{globalOn=e.target.checked;status('新 Session 默认已保存;已有 Session 不变。');render()}
|
|
173
|
+
$('once').onclick=()=>{once=true;status('已同意仅下一轮损失,请手动发送或重试。');render()}
|
|
174
|
+
$('revoke').onclick=()=>{once=false;status('已撤销下一轮授权。');render()}
|
|
175
|
+
$('enable').onclick=()=>{policy='on';once=false;$('session-policy').value='on';status('已同意损失并持续开启;可切回关闭。');render()}
|
|
176
|
+
$('turn').onclick=()=>{if(active){active=null;status('模拟轮结束。')}else{active={account:effective(),on:on()||once};once=false;status('模拟轮已开始,未执行任何推理。')}render()}
|
|
177
|
+
$('new-session').onclick=()=>{if(saving)return;active=null;sessionAccount=null;initialOn=globalOn;policy='follow';once=false;$('session-policy').value='follow';setPage('chat');document.querySelector('.account-surface').hidden=false;status('新模拟 Session 继承全局默认。');render()}
|
|
178
|
+
document.addEventListener('keydown',e=>{if(e.key==='Escape'&&!saving)closeSelector()})
|
|
179
|
+
|
|
180
|
+
const manage=$('manage'),surface=document.querySelector('.account-surface')
|
|
181
|
+
const accountSection=document.createElement('section');accountSection.className='management-section';accountSection.setAttribute('aria-label','账号管理')
|
|
182
|
+
accountSection.innerHTML='<h3>账号管理</h3>'
|
|
183
|
+
const accountSummary=surface.querySelector('.account-summary')
|
|
184
|
+
const explanation=$('policy').previousElementSibling
|
|
185
|
+
accountSection.append(accountSummary,$('selector'),explanation,$('policy'))
|
|
186
|
+
const accountActions=document.createElement('div');accountActions.className='actions';accountActions.append($('refresh-identity'),$('reauthorize'));accountSection.append(accountActions)
|
|
187
|
+
const modelSection=document.createElement('section');modelSection.className='management-section';modelSection.setAttribute('aria-label','当前账号的模型')
|
|
188
|
+
modelSection.innerHTML='<h3>模型偏好</h3><p class="model-owner" id="model-owner">适用于所有 Copilot 账号;可用性按当前账号判断。</p>'
|
|
189
|
+
while(manage.firstChild)modelSection.append(manage.firstChild)
|
|
190
|
+
manage.append(accountSection,modelSection)
|
|
191
|
+
const compact=document.createElement('p');compact.className='compact-identity';compact.id='compact-identity';surface.querySelector('.provider-heading').after(compact)
|
|
192
|
+
function updateOwnership(){
|
|
193
|
+
compact.textContent=$('current-name').textContent+' · 全局默认'
|
|
194
|
+
$('model-owner').textContent='偏好适用于所有 Copilot 账号 · 当前可用性:'+$('current-name').textContent+'(模拟)'
|
|
195
|
+
renderPreferences()
|
|
196
|
+
}
|
|
197
|
+
new MutationObserver(updateOwnership).observe($('current-name'),{childList:true})
|
|
198
|
+
$('manage-toggle').onclick=()=>{const open=manage.hidden;manage.hidden=!open;$('manage-toggle').setAttribute('aria-expanded',String(open));if(!open)closeSelector()}
|
|
199
|
+
const preferences=modelSection.querySelector('details')
|
|
200
|
+
preferences.innerHTML='<summary>启用与排除 · 跨账号共享</summary><p><small>新发现模型默认启用;账号缺失模型时保留偏好,恢复可用后沿用原设置。不自动切模型或账号。</small></p><input class="model-search" id="model-search" type="search" aria-label="搜索模型" placeholder="搜索模型名称或 ID"><div class="model-filters" id="model-filters"></div><div class="preferences" id="preference-rows"></div>'
|
|
201
|
+
const models=[
|
|
202
|
+
{id:'gpt-6.1-sol',name:'GPT-6.1 Sol',accounts:['1','2']},
|
|
203
|
+
{id:'gpt-6-sol',name:'GPT-6 Sol',accounts:['1','2']},
|
|
204
|
+
{id:'claude-sonnet',name:'Claude Sonnet',accounts:['1']},
|
|
205
|
+
{id:'claude-opus',name:'Claude Opus',accounts:['2']},
|
|
206
|
+
{id:'gemini-pro',name:'Gemini Pro',accounts:['1','2'],fresh:true},
|
|
207
|
+
{id:'gpt-5.4',name:'GPT-5.4',accounts:['1','2']},
|
|
208
|
+
{id:'gpt-5.4-mini',name:'GPT-5.4 mini',accounts:['1','2']}
|
|
209
|
+
]
|
|
210
|
+
const excluded=new Set(['gpt-5.4-mini']);let filter='all'
|
|
211
|
+
function renderPreferences(){
|
|
212
|
+
const query=$('model-search').value.trim().toLowerCase(),rows=$('preference-rows');rows.replaceChildren()
|
|
213
|
+
const filters=$('model-filters');filters.replaceChildren()
|
|
214
|
+
for(const [id,name] of [['all','全部'],['available','当前可用'],['excluded','已排除'],['unavailable','当前不可用']]){
|
|
215
|
+
const b=document.createElement('button');b.textContent=name;b.setAttribute('aria-pressed',String(filter===id));b.onclick=()=>{filter=id;renderPreferences()};filters.append(b)
|
|
216
|
+
}
|
|
217
|
+
for(const model of models){
|
|
218
|
+
const available=model.accounts.includes(globalAccount),off=excluded.has(model.id)
|
|
219
|
+
if(!(model.name+' '+model.id).toLowerCase().includes(query)||filter==='available'&&!available||filter==='excluded'&&!off||filter==='unavailable'&&available)continue
|
|
220
|
+
const row=document.createElement('div');row.className='model-preference';row.dataset.model=model.id
|
|
221
|
+
const label=document.createElement('span'),name=document.createElement('strong'),detail=document.createElement('small')
|
|
222
|
+
name.textContent=model.name+(model.fresh?' · 新发现':'')
|
|
223
|
+
detail.textContent=(off?'已排除':'已启用')+' · '+(available?'当前账号可用':'当前账号不可用,偏好保留')
|
|
224
|
+
label.append(name,detail)
|
|
225
|
+
const action=document.createElement('button');action.textContent=off?'恢复':'排除';action.onclick=()=>{off?excluded.delete(model.id):excluded.add(model.id);status('跨账号偏好已模拟保存;不会自动选择模型。');renderPreferences()}
|
|
226
|
+
row.append(label,action);rows.append(row)
|
|
227
|
+
}
|
|
228
|
+
if(!rows.childElementCount){const empty=document.createElement('p');empty.textContent='没有匹配模型。';rows.append(empty)}
|
|
229
|
+
}
|
|
230
|
+
$('model-search').oninput=renderPreferences
|
|
231
|
+
const removal=document.createElement('div');removal.className='remove-review';removal.hidden=true;removal.setAttribute('role','group');removal.setAttribute('aria-label','确认移除账号')
|
|
232
|
+
removal.innerHTML='<strong id="remove-title"></strong><p><small>仅移除本机保存的授权,不撤销 GitHub 端权限,不删除对话,也不清除共享模型偏好。不会自动切换到其他账号。</small></p><div class="actions"><button id="confirm-remove">确认移除</button><button id="cancel-remove">取消</button></div>'
|
|
233
|
+
$('selector').append(removal)
|
|
234
|
+
let removeTarget=null
|
|
235
|
+
const originalRenderList=renderList
|
|
236
|
+
renderList=function(){
|
|
237
|
+
originalRenderList()
|
|
238
|
+
document.querySelectorAll('#account-list .account-option').forEach(button=>{
|
|
239
|
+
const id=button.dataset.account
|
|
240
|
+
if(id==='follow')return
|
|
241
|
+
const wrapper=document.createElement('div');wrapper.className='account-entry'
|
|
242
|
+
button.replaceWith(wrapper);wrapper.append(button)
|
|
243
|
+
const remove=document.createElement('button');remove.className='remove-account';remove.textContent='移除';remove.setAttribute('aria-label','移除 '+find(id).name)
|
|
244
|
+
remove.disabled=saving||id===globalAccount||active?.account===id
|
|
245
|
+
remove.title=id===globalAccount?'请先切换全局默认账号':active?.account===id?'正在使用的账号不可移除':'移除本机保存的授权'
|
|
246
|
+
remove.onclick=()=>{removeTarget=id;$('remove-title').textContent='移除 '+find(id).name+'?';removal.hidden=false}
|
|
247
|
+
wrapper.append(remove)
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
$('search').oninput=()=>renderList()
|
|
251
|
+
$('cancel-remove').onclick=()=>{removal.hidden=true;removeTarget=null}
|
|
252
|
+
$('confirm-remove').onclick=()=>{
|
|
253
|
+
if(!removeTarget||removeTarget===globalAccount||active?.account===removeTarget)return
|
|
254
|
+
const id=removeTarget,name=find(id).name,index=accounts.findIndex(a=>a.id===id)
|
|
255
|
+
accounts.splice(index,1);removal.hidden=true;removeTarget=null
|
|
256
|
+
status('已模拟移除 '+name+';共享模型偏好保留。');render()
|
|
257
|
+
}
|
|
258
|
+
$('refresh-models').onclick=()=>status('模拟模型刷新完成;未发起网络请求。')
|
|
259
|
+
$('refresh-identity').onclick=()=>status('模拟账号信息刷新完成;未读取真实账号。')
|
|
260
|
+
$('reauthorize').onclick=()=>status('这里只演示重新授权入口;未打开 GitHub 或修改凭据。')
|
|
261
|
+
setPage('models')
|
|
262
|
+
updateOwnership()
|
|
263
|
+
|
|
264
|
+
const shell=document.querySelector('.settings-shell')
|
|
265
|
+
const shade=document.createElement('div');shade.className='modal-shade';shade.hidden=true;shell.before(shade)
|
|
266
|
+
const chatHost=document.createElement('div');chatHost.className='chat-host';shell.before(chatHost)
|
|
267
|
+
const chatNode=$('chat'),holder=$('surface-holder'),main=document.querySelector('main')
|
|
268
|
+
chatHost.append(chatNode,holder)
|
|
269
|
+
const link=document.createElement('div');link.className='manage-link';link.innerHTML='<button class="quiet" id="full-management">管理账号与模型 →</button>';surface.append(link)
|
|
270
|
+
const accountTitle=accountSection.querySelector('h3')
|
|
271
|
+
const accountActionsForModels=accountActions
|
|
272
|
+
const explanationForModels=explanation
|
|
273
|
+
const originalSetPage=setPage
|
|
274
|
+
function showChat(){
|
|
275
|
+
originalSetPage('chat');shell.hidden=true;shade.hidden=true;chatNode.hidden=false
|
|
276
|
+
chatHost.append(holder);holder.className=''
|
|
277
|
+
manage.hidden=false;accountSection.hidden=false;modelSection.hidden=true
|
|
278
|
+
accountActionsForModels.hidden=true;explanationForModels.hidden=true;accountTitle.hidden=true;link.hidden=false
|
|
279
|
+
compact.hidden=true;$('manage-toggle').hidden=true
|
|
280
|
+
surface.querySelector('.model-status').hidden=true
|
|
281
|
+
surface.hidden=false;render()
|
|
282
|
+
}
|
|
283
|
+
function showModels(){
|
|
284
|
+
closeSelector();originalSetPage('models');chatNode.hidden=false
|
|
285
|
+
main.insertBefore(holder,$('models-list'));holder.className='models'
|
|
286
|
+
shell.hidden=false;shade.hidden=false;manage.hidden=false
|
|
287
|
+
accountActionsForModels.hidden=false;explanationForModels.hidden=false;accountTitle.hidden=false
|
|
288
|
+
modelSection.hidden=false;link.hidden=true;compact.hidden=false
|
|
289
|
+
$('manage-toggle').hidden=false;$('manage-toggle').setAttribute('aria-expanded','true')
|
|
290
|
+
surface.querySelector('.model-status').hidden=false
|
|
291
|
+
$('scope').textContent='全局默认'
|
|
292
|
+
main.scrollTop=0
|
|
293
|
+
$('manage-toggle').focus()
|
|
294
|
+
}
|
|
295
|
+
$('full-management').onclick=showModels
|
|
296
|
+
const closeSettings=document.querySelector('[aria-label="Close Settings"]');closeSettings.disabled=false;closeSettings.onclick=()=>{showChat();$('full-management').focus()}
|
|
297
|
+
$('manage-toggle').onclick=()=>{manage.hidden=!manage.hidden;$('manage-toggle').setAttribute('aria-expanded',String(!manage.hidden));if(manage.hidden)closeSelector()}
|
|
298
|
+
const removeList=renderList
|
|
299
|
+
renderList=function(){removeList();if(page==='chat')document.querySelectorAll('.remove-account').forEach(b=>b.hidden=true);else document.querySelectorAll('.account-entry').forEach(row=>{if(row.querySelector('[data-account]')?.dataset.account===sessionAccount){const button=row.querySelector('.remove-account');button.disabled=true;button.title='此账号被当前 Session 显式绑定,需先解除绑定'}})}
|
|
300
|
+
$('search').oninput=()=>renderList()
|
|
301
|
+
const switchReview=document.createElement('div');switchReview.className='switch-review';switchReview.hidden=true
|
|
302
|
+
switchReview.setAttribute('role','group');switchReview.setAttribute('aria-label','确认关闭降级后切换账号')
|
|
303
|
+
switchReview.innerHTML='<strong>降级续聊已关闭</strong><p id="switch-warning"></p><p><small>旧加密推理可能无法跨账号回放。未发送新请求,不能确认它一定失败;切换不会修改历史。</small></p><div class="actions"><button id="enable-switch" class="primary">开启降级并切换</button><button id="once-switch">仅下一轮降级并切换</button><button id="keep-off-switch">保持关闭并切换</button><button id="cancel-switch-review" class="quiet">取消</button></div>'
|
|
304
|
+
$('selector').append(switchReview)
|
|
305
|
+
let pendingAccount=null
|
|
306
|
+
const originalChoose=choose
|
|
307
|
+
choose=async function(id){
|
|
308
|
+
const resolved=id==='follow'?globalAccount:id
|
|
309
|
+
if(page==='chat'&&!on()&&!once&&resolved!==effective()){
|
|
310
|
+
pendingAccount=id;$('switch-warning').textContent='将从 '+find(effective()).name+' 切换到 '+find(resolved).name+'。'
|
|
311
|
+
switchReview.hidden=false;return
|
|
312
|
+
}
|
|
313
|
+
return originalChoose(id)
|
|
314
|
+
}
|
|
315
|
+
async function applySwitch(mode){
|
|
316
|
+
const id=pendingAccount;if(id===null)return
|
|
317
|
+
switchReview.hidden=true;pendingAccount=null
|
|
318
|
+
if(mode==='on'){policy='on';$('session-policy').value='on'}
|
|
319
|
+
if(mode==='once')once=true
|
|
320
|
+
await originalChoose(id)
|
|
321
|
+
}
|
|
322
|
+
$('enable-switch').onclick=()=>applySwitch('on')
|
|
323
|
+
$('once-switch').onclick=()=>applySwitch('once')
|
|
324
|
+
$('keep-off-switch').onclick=()=>applySwitch('off')
|
|
325
|
+
$('cancel-switch-review').onclick=()=>{switchReview.hidden=true;pendingAccount=null;status('已取消切换,账号及降级策略不变。')}
|
|
326
|
+
const guidance=document.createElement('div');guidance.className='replay-guidance';guidance.hidden=true;guidance.setAttribute('role','alert')
|
|
327
|
+
guidance.innerHTML='<strong>旧推理回放被当前账号拒绝(模拟)</strong><p><small>可见消息与工具记录仍保留。开启降级后不回放旧加密推理及内嵌摘要,可能失去隐含细节。不会自动重试。</small></p><div class="actions"><button id="failure-enable" class="primary">开启本 Session 降级</button><button id="failure-once">仅下一轮降级</button><button id="failure-manage" class="quiet">管理账号与模型 →</button></div><p id="failure-next" hidden>已授权。请手动重试原任务;这里没有发送任何请求。</p>'
|
|
328
|
+
accountSection.append(guidance)
|
|
329
|
+
const failButton=document.createElement('button');failButton.id='simulate-replay-mismatch';failButton.textContent='模拟回放不一致';document.querySelector('.simulation').append(failButton)
|
|
330
|
+
failButton.onclick=()=>{if(!shell.hidden)showChat();surface.hidden=false;guidance.hidden=false;status('模拟供应方已明确拒绝旧回放;未执行真实推理。')}
|
|
331
|
+
const scenario=document.createElement('button');scenario.id='off-scenario';scenario.textContent='体验:降级关闭后 A → B'
|
|
332
|
+
document.querySelector('.simulation').prepend(scenario)
|
|
333
|
+
function startOffScenario(){
|
|
334
|
+
active=null;sessionAccount='1';globalAccount='1';policy='off';once=false
|
|
335
|
+
$('session-policy').value='off';guidance.hidden=true;$('failure-next').hidden=true
|
|
336
|
+
showChat();surface.hidden=false;$('policy-details').open=false
|
|
337
|
+
$('selector').hidden=false;$('switch').setAttribute('aria-expanded','true')
|
|
338
|
+
$('search').value='demo-account-02';renderList()
|
|
339
|
+
choose('2')
|
|
340
|
+
status('演示起点:个人账号 A,降级关闭。你刚选择了工作账号 B;请在确认区选择下一步。')
|
|
341
|
+
renderConversation('switch')
|
|
342
|
+
switchReview.scrollIntoView({block:'nearest'})
|
|
343
|
+
}
|
|
344
|
+
scenario.onclick=startOffScenario
|
|
345
|
+
const originalApplySwitch=applySwitch
|
|
346
|
+
applySwitch=async function(mode){
|
|
347
|
+
await originalApplySwitch(mode)
|
|
348
|
+
if(mode==='off'){
|
|
349
|
+
renderConversation('ready')
|
|
350
|
+
status('已切换到 B,降级仍关闭。下一步可模拟一次发送,观察供应方拒绝旧回放后的引导。')
|
|
351
|
+
sendSimulation.hidden=false
|
|
352
|
+
}else{sendSimulation.hidden=true;renderConversation('authorized');status('已授权降级并切换。可手动发送;这里不会执行真实推理。')}
|
|
353
|
+
}
|
|
354
|
+
const sendSimulation=document.createElement('button');sendSimulation.id='simulate-off-send';sendSimulation.textContent='模拟发送:旧回放被拒绝';sendSimulation.hidden=true
|
|
355
|
+
document.querySelector('.simulation').append(sendSimulation)
|
|
356
|
+
sendSimulation.onclick=()=>{guidance.hidden=false;sendSimulation.hidden=true;renderConversation('failed');status('模拟发送已失败:供应方拒绝旧回放。尚未开启降级,也没有自动重试。');document.querySelector('.history').scrollIntoView({block:'start'})}
|
|
357
|
+
function renderConversation(state){
|
|
358
|
+
const history=chatNode.querySelector('.history')
|
|
359
|
+
history.innerHTML='<div class="scenario-heading">模拟对话 · 账号 A 的历史保留在同一个 Session</div><div class="mock-message user"><small>你 · 之前使用账号 A</small><p>帮我设计一个支持多账号切换的界面。</p></div><div class="mock-message"><small>助手 · 账号 A · 模拟内容</small><p>建议平时只显示当前账号,用 Switch 打开搜索列表。完整管理放在 Models 页面。</p></div>'
|
|
360
|
+
if(state==='switch')history.insertAdjacentHTML('beforeend','<p class="scenario-heading">现在你准备切到账号 B。降级关闭,下方先确认切换;还没有发送下一条消息。</p>')
|
|
361
|
+
else{
|
|
362
|
+
history.insertAdjacentHTML('beforeend','<div class="mock-message user"><small>你 · 准备使用账号 B</small><p>继续刚才的方案,补上删除账号的确认流程。</p></div>')
|
|
363
|
+
if(state==='failed')history.insertAdjacentHTML('beforeend','<div class="mock-message failure" role="alert"><strong>这一轮失败 · 未生成回答(模拟)</strong><p>账号 B 拒绝了账号 A 历史中的旧加密推理。可见对话与工具记录仍然保留。</p><small>COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH</small><div class="actions"><button id="message-enable">开启降级续聊</button><button id="message-once">仅下一轮降级</button></div><p><small>这两个操作只授权,不会自动重发这条消息。</small></p></div>')
|
|
364
|
+
else history.insertAdjacentHTML('beforeend','<p class="scenario-heading">'+(state==='authorized'?'已授权降级。请手动发送上面的后续消息(模拟)。':'已切到账号 B,降级仍关闭。点击下方“模拟发送:旧回放被拒绝”查看失败状态。')+'</p>')
|
|
365
|
+
}
|
|
366
|
+
for(const [id,action] of [['message-enable','failure-enable'],['message-once','failure-once']]){
|
|
367
|
+
const b=document.getElementById(id);if(b)b.onclick=()=>{$(action).click();showRetry()}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function showRetry(){
|
|
371
|
+
const history=chatNode.querySelector('.history')
|
|
372
|
+
const old=document.getElementById('mock-manual-retry');if(old)return
|
|
373
|
+
const box=document.createElement('div');box.className='notice';box.innerHTML='<p>降级已授权。原失败消息还没有重发。</p><button id="mock-manual-retry">手动重试刚才的消息(模拟)</button>'
|
|
374
|
+
history.append(box)
|
|
375
|
+
$('mock-manual-retry').onclick=()=>{
|
|
376
|
+
box.innerHTML='<p>你手动重试了原消息 · 使用账号 B · 不回放旧加密推理(模拟)</p>'
|
|
377
|
+
history.insertAdjacentHTML('beforeend','<div class="mock-message"><small>助手 · 账号 B · 演示回答,不代表真实供应方验收</small><p>可以继续。删除账号前展示确认说明:只移除本机保存的授权,不删除对话或共享模型偏好;当前默认账号需要先切换。</p></div>')
|
|
378
|
+
guidance.hidden=true;status('模拟重试已完成;未执行真实请求。')
|
|
379
|
+
}
|
|
380
|
+
box.scrollIntoView({block:'nearest'})
|
|
381
|
+
}
|
|
382
|
+
$('failure-enable').onclick=()=>{policy='on';once=false;$('session-policy').value='on';$('failure-next').hidden=false;render();showRetry()}
|
|
383
|
+
$('failure-once').onclick=()=>{once=true;$('failure-next').hidden=false;render();showRetry()}
|
|
384
|
+
$('failure-manage').onclick=showModels
|
|
385
|
+
$('new-session').onclick=()=>{if(saving)return;active=null;sessionAccount=null;initialOn=globalOn;policy='follow';once=false;$('session-policy').value='follow';showChat();status('新模拟 Session 已继承全局默认;未创建真实会话。')}
|
|
386
|
+
$('credits').onclick=()=>{surface.hidden=!surface.hidden}
|
|
387
|
+
document.addEventListener('keydown',event=>{if(event.key==='Escape'&&!saving&&!shell.hidden&&$('selector').hidden){showChat();$('full-management').focus()}})
|
|
388
|
+
globalOn=true;initialOn=true;$('global-policy').checked=true
|
|
389
|
+
showChat()
|
|
390
|
+
status('降级续聊默认开启(模拟)。可展开详情关闭;每轮不回放旧加密推理,同账号也适用。')
|
|
391
|
+
if(new URLSearchParams(location.search).get('scenario')==='off-switch')startOffScenario()
|
|
392
|
+
</script>
|
|
393
|
+
</html>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Session cross-account continuation
|
|
2
|
+
|
|
3
|
+
Explicit **visible-history continuation** is a plugin-owned, lossy outgoing
|
|
4
|
+
Responses policy. It is not a new memory service or portable encrypted state.
|
|
5
|
+
Native Core and pi-ai already preserve replay signatures and reconstruct history;
|
|
6
|
+
their same-provider/API/model check does not establish Copilot account identity.
|
|
7
|
+
|
|
8
|
+
## Experience
|
|
9
|
+
|
|
10
|
+
The Credits account panel contains **Visible-history continuation**. New,
|
|
11
|
+
unseeded Sessions created after this feature's first successful activation default
|
|
12
|
+
on. Activation persists a bounded creation-time policy epoch using Settings CAS;
|
|
13
|
+
existing Sessions, seeded histories, forks and unknown birth evidence remain off.
|
|
14
|
+
Manage the global default in **Models → GitHub Copilot → Manage → Account management**.
|
|
15
|
+
Changing it affects only subsequently created Sessions. Session overrides
|
|
16
|
+
(on, off or creation-time default) persist across account changes and restarts.
|
|
17
|
+
No failed request is required first and no hourly confirmation is needed.
|
|
18
|
+
|
|
19
|
+
The enabled disclosure stays compact. Details contain the disable action.
|
|
20
|
+
Enable/disable changes affect future turns; the active turn retains its captured
|
|
21
|
+
policy and account. The UI distinguishes pending changes from the active policy.
|
|
22
|
+
Disabling does not undo answers; it may expose the original replay rejection on
|
|
23
|
+
later requests. When off, switching to a different account pauses for persistent
|
|
24
|
+
enable, next-turn-only authorization, keep off, or cancel. Next-turn authorization
|
|
25
|
+
is consumed at the next managed turn admission, includes its native retries, can
|
|
26
|
+
be revoked beforehand or by changing the Session policy, and is lost on Host restart. It never automatically sends
|
|
27
|
+
or retries. An exact replay rejection also exposes these authorization controls
|
|
28
|
+
beside recovery guidance; retry remains a separate native user action.
|
|
29
|
+
|
|
30
|
+
See the [approved account-management experience and mock](./account-management-experience.md).
|
|
31
|
+
On the currently pinned Core, direct Models navigation is not a public Client
|
|
32
|
+
service. Chat provides manual Settings → Models → GitHub Copilot → Manage
|
|
33
|
+
instructions rather than accessing private stores or replacing Settings.
|
|
34
|
+
|
|
35
|
+
## Loss and retained content
|
|
36
|
+
|
|
37
|
+
On each admitted managed Responses turn, the first normalized payload captures
|
|
38
|
+
fingerprints of pre-existing completed encrypted reasoning. Those exact items,
|
|
39
|
+
including summaries embedded inside them, are omitted from outgoing requests
|
|
40
|
+
throughout that turn. Newly generated reasoning remains available to subsequent
|
|
41
|
+
tool steps and native retries. A later turn treats the preceding turn's reasoning
|
|
42
|
+
as historical, even without an account change.
|
|
43
|
+
|
|
44
|
+
Visible user/assistant messages, native tool calls and result pairing, system/tool
|
|
45
|
+
definitions and disk history remain under their existing owners. No encrypted
|
|
46
|
+
content is decoded, copied to settings or converted into invented raw reasoning.
|
|
47
|
+
The policy does not claim which account issued an old item.
|
|
48
|
+
|
|
49
|
+
## Public integration and safety
|
|
50
|
+
|
|
51
|
+
`github-copilot.sessionContinuation` stores strict bounded entries containing
|
|
52
|
+
only Session ID, policy version, explicit enabled state and consent timestamp.
|
|
53
|
+
Legacy entries without enabled retain their prior true meaning.
|
|
54
|
+
`continuationDefaultHistory` stores chronological bounded `{enabled, changedAt}`
|
|
55
|
+
entries, never Session content. Native SettingsForms CAS,
|
|
56
|
+
hidden volatile owned-field projection and readback preserve other settings and
|
|
57
|
+
the active plugin fiber. A separate strict `githubCopilotSessionContinuation`
|
|
58
|
+
Remote uses explicit Agent lookup; temporary recovery descriptors remain intact.
|
|
59
|
+
|
|
60
|
+
Public `agent/request`, `session/event` and `agent/disposed` bind an in-memory
|
|
61
|
+
per-turn baseline to the exact initiating Session and request signal. The
|
|
62
|
+
published adapter/SDK's payload hook filters the normalized payload. Only
|
|
63
|
+
`github-copilot-preview` Responses chat calls participate. Classifier, compaction,
|
|
64
|
+
unbound requests and other protocols remain native. Cold mid-turn recovery
|
|
65
|
+
without a first-step boundary fails explicitly.
|
|
66
|
+
|
|
67
|
+
The fingerprint baseline is bounded to 4096 distinct items, 65536 traversed
|
|
68
|
+
values, depth 64 and 16 MiB serialized payload. Unsupported reasoning, malformed
|
|
69
|
+
settings, missing boundaries and exhausted limits produce named diagnostics,
|
|
70
|
+
not partial filtering or guessed success. Credentials, account entitlement,
|
|
71
|
+
model capabilities and cancellation remain independently guarded.
|
|
72
|
+
|
|
73
|
+
Native retry normalization retains raw reference-restoration evidence but records
|
|
74
|
+
the final filtered bytes for exact 408 matching. No new retry loop is introduced.
|
|
75
|
+
Input admission still precedes payload filtering: this is not an oversized-context,
|
|
76
|
+
quota, upload-timeout, compaction or native context-meter repair.
|
|
77
|
+
|
|
78
|
+
## Evidence limits
|
|
79
|
+
|
|
80
|
+
Synthetic account transitions, source/Host/UI tests and exact-source native
|
|
81
|
+
gateway/persistence fixtures are distinct from real supplier acceptance.
|
|
82
|
+
Publication, installation, loaded runtime and controlled live A-B-B-A success
|
|
83
|
+
must be reported separately. Enabling this product mode is not authorized by
|
|
84
|
+
implementing it; live existing Sessions still require explicit loss consent.
|
|
85
|
+
The default-on creation policy is disclosed in account controls and can be
|
|
86
|
+
disabled globally or overridden per Session. Source tests do not establish live
|
|
87
|
+
default acceptance or real cross-account transport.
|