@liyuera/dsh-chrome-browser 0.5.0 → 0.6.0
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/README.md +16 -2
- package/extension/manifest.json +1 -1
- package/extension/service-worker.js +32 -4
- package/lib/activity.d.ts +35 -22
- package/lib/activity.d.ts.map +1 -1
- package/lib/activity.js +68 -28
- package/lib/activity.js.map +1 -1
- package/lib/backend.d.ts +35 -2
- package/lib/backend.d.ts.map +1 -1
- package/lib/backend.js +57 -6
- package/lib/backend.js.map +1 -1
- package/lib/client/BrowserActivity.d.ts +14 -11
- package/lib/client/BrowserActivity.d.ts.map +1 -1
- package/lib/client/BrowserActivity.js +86 -45
- package/lib/client/BrowserActivity.js.map +1 -1
- package/lib/client/activity.d.ts +16 -9
- package/lib/client/activity.d.ts.map +1 -1
- package/lib/client/activity.js +41 -20
- package/lib/client/activity.js.map +1 -1
- package/lib/client/index.d.ts +2 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +9 -8
- package/lib/client/index.js.map +1 -1
- package/lib/client.js +195 -73
- package/lib/client.js.map +1 -1
- package/lib/expressions.d.ts +11 -0
- package/lib/expressions.d.ts.map +1 -1
- package/lib/expressions.js +25 -0
- package/lib/expressions.js.map +1 -1
- package/lib/routes.d.ts.map +1 -1
- package/lib/routes.js +10 -2
- package/lib/routes.js.map +1 -1
- package/lib/skill.js +3 -3
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +14 -1
- package/lib/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/client/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmBH,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,GAAG,CAAA;AAUpB,kEAAkE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4,14 +4,14 @@
|
|
|
4
4
|
* The composer dock used to carry a full-width tab selector above the input
|
|
5
5
|
* card. That row, its component and the session-binding routes behind it are
|
|
6
6
|
* gone: the live tab list lives in the `@` menu, where a pick inserts a
|
|
7
|
-
* reference chip and binds nothing. The
|
|
7
|
+
* reference chip and binds nothing. The Session header carries the status chip.
|
|
8
8
|
* @module @liyuera/dsh-chrome-browser/client
|
|
9
9
|
*/
|
|
10
10
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
11
11
|
/** Required services for the slot contribution and the `@` source. */
|
|
12
12
|
export declare const inject: string[];
|
|
13
13
|
/**
|
|
14
|
-
* Client plugin body: register the
|
|
14
|
+
* Client plugin body: register the Chrome status chip and the `@` tab source.
|
|
15
15
|
* @param ctx - client root context.
|
|
16
16
|
*/
|
|
17
17
|
export declare function apply(ctx: ClientContext): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAUnE,sEAAsE;AACtE,eAAO,MAAM,MAAM,UAA6B,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAUnE,sEAAsE;AACtE,eAAO,MAAM,MAAM,UAA6B,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAe9C"}
|
package/lib/client/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The composer dock used to carry a full-width tab selector above the input
|
|
5
5
|
* card. That row, its component and the session-binding routes behind it are
|
|
6
6
|
* gone: the live tab list lives in the `@` menu, where a pick inserts a
|
|
7
|
-
* reference chip and binds nothing. The
|
|
7
|
+
* reference chip and binds nothing. The Session header carries the status chip.
|
|
8
8
|
* @module @liyuera/dsh-chrome-browser/client
|
|
9
9
|
*/
|
|
10
10
|
import { BrowserActivity } from "./BrowserActivity.js";
|
|
@@ -14,17 +14,18 @@ import { tabIcon } from "./tab-icon.js";
|
|
|
14
14
|
/** Required services for the slot contribution and the `@` source. */
|
|
15
15
|
export const inject = ['slots', 'inputTriggers'];
|
|
16
16
|
/**
|
|
17
|
-
* Client plugin body: register the
|
|
17
|
+
* Client plugin body: register the Chrome status chip and the `@` tab source.
|
|
18
18
|
* @param ctx - client root context.
|
|
19
19
|
*/
|
|
20
20
|
export function apply(ctx) {
|
|
21
|
-
// The
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// The status chip: the last item in the Session header's trailing utilities,
|
|
22
|
+
// so the state of the browser bridge sits with the other session-level
|
|
23
|
+
// facts. It stays mounted and stays visible — a chip that only appears while
|
|
24
|
+
// a call runs flickers past, because these calls finish in milliseconds.
|
|
25
|
+
ctx.slots.inject('conversation.session.header.utilities', () => ctx.slots.register({
|
|
26
|
+
name: 'conversation.session.header.utilities',
|
|
26
27
|
id: 'chrome-browser-activity',
|
|
27
|
-
order:
|
|
28
|
+
order: 90,
|
|
28
29
|
}, BrowserActivity));
|
|
29
30
|
ctx.effect(() => ctx.inputTriggers.registerSource(createChromeTabSource({ listTabs: listChromeTabs, iconFor: tabIcon })), 'chrome-browser: @ tab source');
|
|
30
31
|
}
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAuB,CAAA;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lib/client.js
CHANGED
|
@@ -38,40 +38,70 @@ window.__ModuleLoader__.load({
|
|
|
38
38
|
* Browser-side activity probe: `GET /chrome-browser/activity` behind a short
|
|
39
39
|
* cache.
|
|
40
40
|
*
|
|
41
|
-
* The
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* The header chip polls this while a session view is open. An unreachable host
|
|
42
|
+
* answers "offline" rather than throwing into React: a chip that flickers an
|
|
43
|
+
* error is worse than one that says the bridge is not there, which is also the
|
|
44
|
+
* truth.
|
|
44
45
|
* @module @liyuera/dsh-chrome-browser/client/activity
|
|
45
46
|
*/
|
|
46
47
|
/** One snapshot per this window, however many callers ask. */
|
|
47
|
-
const CACHE_MS$1 =
|
|
48
|
-
|
|
48
|
+
const CACHE_MS$1 = 400;
|
|
49
|
+
/** What the chip shows when the host cannot be reached at all. */
|
|
50
|
+
const OFFLINE = { phase: "offline" };
|
|
49
51
|
let cachedAt$1 = 0;
|
|
50
|
-
let cached$1 =
|
|
52
|
+
let cached$1 = OFFLINE;
|
|
51
53
|
let inflight$1 = null;
|
|
54
|
+
/**
|
|
55
|
+
* Turn one host answer into the phase the chip renders.
|
|
56
|
+
*
|
|
57
|
+
* The link decides first: an extension that is not attached, or is running
|
|
58
|
+
* older files than the plugin ships, is a condition the user has to fix, and it
|
|
59
|
+
* outranks whatever the last call happened to do — a `done` flash drawn on top
|
|
60
|
+
* of a disconnected bridge would be actively misleading.
|
|
61
|
+
* @param body - the parsed route answer.
|
|
62
|
+
* @returns the phase and the fields that belong to it.
|
|
63
|
+
*/
|
|
64
|
+
function phaseOf(body) {
|
|
65
|
+
const rest = {
|
|
66
|
+
...body.tool === void 0 ? {} : { tool: body.tool },
|
|
67
|
+
...body.tabId === void 0 ? {} : { tabId: body.tabId },
|
|
68
|
+
...body.detail === void 0 ? {} : { detail: body.detail },
|
|
69
|
+
...body.since === void 0 ? {} : { since: body.since }
|
|
70
|
+
};
|
|
71
|
+
if (body.connected === false) return {
|
|
72
|
+
phase: "offline",
|
|
73
|
+
...rest
|
|
74
|
+
};
|
|
75
|
+
if (body.stale === true) return {
|
|
76
|
+
phase: "stale",
|
|
77
|
+
...rest
|
|
78
|
+
};
|
|
79
|
+
const phase = body.phase;
|
|
80
|
+
if (phase === "running" || phase === "done" || phase === "error") return {
|
|
81
|
+
phase,
|
|
82
|
+
...rest
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
phase: "ready",
|
|
86
|
+
...rest
|
|
87
|
+
};
|
|
88
|
+
}
|
|
52
89
|
async function fetchActivity(sessionId) {
|
|
53
90
|
try {
|
|
54
91
|
const query = sessionId === "" ? "" : `?sessionId=${encodeURIComponent(sessionId)}`;
|
|
55
92
|
const body = await (await fetch(`/chrome-browser/activity${query}`)).json();
|
|
56
93
|
if (body.ok !== true) throw new Error(body.error ?? "activity probe failed");
|
|
57
|
-
cached$1 =
|
|
58
|
-
active: body.active === true,
|
|
59
|
-
...body.tool === void 0 ? {} : { tool: body.tool },
|
|
60
|
-
...body.tabId === void 0 ? {} : { tabId: body.tabId },
|
|
61
|
-
...body.startedAt === void 0 ? {} : { startedAt: body.startedAt },
|
|
62
|
-
...body.lastTool === void 0 ? {} : { lastTool: body.lastTool },
|
|
63
|
-
...body.lastAt === void 0 ? {} : { lastAt: body.lastAt }
|
|
64
|
-
};
|
|
94
|
+
cached$1 = phaseOf(body);
|
|
65
95
|
} catch {
|
|
66
|
-
cached$1 =
|
|
96
|
+
cached$1 = OFFLINE;
|
|
67
97
|
}
|
|
68
98
|
cachedAt$1 = Date.now();
|
|
69
99
|
return cached$1;
|
|
70
100
|
}
|
|
71
101
|
/**
|
|
72
102
|
* Read the plugin's current activity for one session.
|
|
73
|
-
* @param sessionId - the session the
|
|
74
|
-
* @returns the snapshot, or an
|
|
103
|
+
* @param sessionId - the session the chip belongs to.
|
|
104
|
+
* @returns the snapshot, or an offline one while the host is unreachable.
|
|
75
105
|
*/
|
|
76
106
|
async function readChromeActivity(sessionId) {
|
|
77
107
|
if (Date.now() - cachedAt$1 < CACHE_MS$1) return cached$1;
|
|
@@ -83,26 +113,30 @@ window.__ModuleLoader__.load({
|
|
|
83
113
|
//#endregion
|
|
84
114
|
//#region lib/client/BrowserActivity.js
|
|
85
115
|
/**
|
|
86
|
-
*
|
|
87
|
-
* transcript,
|
|
116
|
+
* Chrome status chip: the one place the user can see, without reading the
|
|
117
|
+
* transcript, whether the plugin can drive their browser and what it is doing
|
|
118
|
+
* with it right now.
|
|
88
119
|
*
|
|
89
|
-
* It
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
120
|
+
* It sits at the end of the Session header's utilities and is **always**
|
|
121
|
+
* rendered — a pale idle state that is legible at a glance, and a louder one
|
|
122
|
+
* only for the phases that ask for attention (a call in flight, a failure, an
|
|
123
|
+
* extension that needs reloading). An indicator that appears only while a call
|
|
124
|
+
* runs is not readable: those calls finish in milliseconds, so it reads as a
|
|
125
|
+
* flicker rather than as information.
|
|
93
126
|
* @module @liyuera/dsh-chrome-browser/client/activity-strip
|
|
94
127
|
*/
|
|
95
|
-
/** Poll interval while the
|
|
128
|
+
/** Poll interval while the chip is mounted; the host caches for slightly less. */
|
|
96
129
|
const POLL_MS = 1e3;
|
|
97
130
|
/**
|
|
98
|
-
* Human labels for the
|
|
99
|
-
* so adding a tool never leaves the
|
|
131
|
+
* Human labels for the tool a phase belongs to. A tool with no label shows its
|
|
132
|
+
* wire name, so adding a tool never leaves the chip blank.
|
|
100
133
|
*/
|
|
101
134
|
const TOOL_LABELS = {
|
|
102
135
|
chrome_tabs: "列出标签页",
|
|
103
136
|
chrome_read: "读取页面",
|
|
104
137
|
chrome_navigate: "导航",
|
|
105
138
|
chrome_open: "打开标签页",
|
|
139
|
+
chrome_close: "关闭标签页",
|
|
106
140
|
chrome_screenshot: "截图",
|
|
107
141
|
chrome_click: "点击",
|
|
108
142
|
chrome_hover: "悬停",
|
|
@@ -114,48 +148,121 @@ window.__ModuleLoader__.load({
|
|
|
114
148
|
chrome_console: "读取控制台",
|
|
115
149
|
chrome_request_help: "等待你操作"
|
|
116
150
|
};
|
|
151
|
+
/** What each phase says, and what a reader who wants more gets on hover. */
|
|
152
|
+
const PHASES = {
|
|
153
|
+
offline: {
|
|
154
|
+
text: "Chrome 未连接",
|
|
155
|
+
hint: "扩展没有连上。检查 chrome://extensions 里 dsh Chrome Control 是否已加载。"
|
|
156
|
+
},
|
|
157
|
+
stale: {
|
|
158
|
+
text: "扩展待更新",
|
|
159
|
+
hint: "扩展在跑旧文件,插件正在请它重载;若一直如此,手动重新加载一次扩展。"
|
|
160
|
+
},
|
|
161
|
+
running: {
|
|
162
|
+
text: "工作中",
|
|
163
|
+
hint: "正在操作你的 Chrome。"
|
|
164
|
+
},
|
|
165
|
+
done: {
|
|
166
|
+
text: "完成",
|
|
167
|
+
hint: "上一次调用已完成。"
|
|
168
|
+
},
|
|
169
|
+
error: {
|
|
170
|
+
text: "失败",
|
|
171
|
+
hint: "上一次调用失败。"
|
|
172
|
+
},
|
|
173
|
+
ready: {
|
|
174
|
+
text: "Chrome 就绪",
|
|
175
|
+
hint: "扩展已连接,空闲中。"
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/** Only the pulse needs a stylesheet; every size is inline on purpose. */
|
|
117
179
|
const STYLE_ID = "dsh-chrome-browser-activity";
|
|
118
|
-
const
|
|
119
|
-
.cb-activity {
|
|
120
|
-
display: flex;
|
|
121
|
-
align-items: center;
|
|
122
|
-
gap: 6px;
|
|
123
|
-
margin: 0 0 6px;
|
|
124
|
-
padding: 3px 8px;
|
|
125
|
-
width: fit-content;
|
|
126
|
-
border: 1px solid var(--dsw-alias-border-l1);
|
|
127
|
-
border-radius: 999px;
|
|
128
|
-
background: var(--dsw-specific-tip);
|
|
129
|
-
color: var(--dsw-alias-label-primary);
|
|
130
|
-
font-size: 12px;
|
|
131
|
-
line-height: 18px;
|
|
132
|
-
}
|
|
133
|
-
.cb-activity img { width: 14px; height: 14px; }
|
|
134
|
-
.cb-activity .cb-dot {
|
|
135
|
-
width: 6px;
|
|
136
|
-
height: 6px;
|
|
137
|
-
border-radius: 50%;
|
|
138
|
-
background: currentColor;
|
|
139
|
-
animation: cb-pulse 1.2s ease-in-out infinite;
|
|
140
|
-
}
|
|
141
|
-
@keyframes cb-pulse { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }
|
|
142
|
-
@media (prefers-reduced-motion: reduce) { .cb-activity .cb-dot { animation: none } }
|
|
143
|
-
.cb-activity .cb-activity-tab { opacity: .7 }
|
|
144
|
-
`;
|
|
180
|
+
const PULSE_CSS = "@keyframes cb-pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }";
|
|
145
181
|
function ensureStyles() {
|
|
146
182
|
if (document.getElementById(STYLE_ID) !== null) return;
|
|
147
183
|
const style = document.createElement("style");
|
|
148
184
|
style.id = STYLE_ID;
|
|
149
|
-
style.textContent =
|
|
185
|
+
style.textContent = PULSE_CSS;
|
|
150
186
|
document.head.appendChild(style);
|
|
151
187
|
}
|
|
188
|
+
/** The colour each phase draws its dot and its text in. */
|
|
189
|
+
const PHASE_COLOR = {
|
|
190
|
+
ready: {
|
|
191
|
+
dot: "var(--dsw-alias-state-success-primary)",
|
|
192
|
+
ink: "var(--dsw-alias-label-secondary)"
|
|
193
|
+
},
|
|
194
|
+
offline: { dot: "var(--dsw-alias-state-idle-primary)" },
|
|
195
|
+
stale: {
|
|
196
|
+
dot: "var(--dsw-alias-state-warn-primary)",
|
|
197
|
+
ink: "var(--dsw-alias-state-warn-primary)"
|
|
198
|
+
},
|
|
199
|
+
running: {
|
|
200
|
+
dot: "var(--dsw-alias-state-success-primary)",
|
|
201
|
+
ink: "var(--dsw-alias-label-primary)"
|
|
202
|
+
},
|
|
203
|
+
done: {
|
|
204
|
+
dot: "var(--dsw-alias-state-success-primary)",
|
|
205
|
+
ink: "var(--dsw-alias-state-success-primary)"
|
|
206
|
+
},
|
|
207
|
+
error: {
|
|
208
|
+
dot: "var(--dsw-alias-state-error-primary)",
|
|
209
|
+
ink: "var(--dsw-alias-state-error-primary)"
|
|
210
|
+
}
|
|
211
|
+
};
|
|
152
212
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
213
|
+
* Sizes that must hold whatever the surrounding header does.
|
|
214
|
+
*
|
|
215
|
+
* These are inline rather than a rule set: the chip carries this plugin's own
|
|
216
|
+
* 512px artwork, and a stylesheet that fails to apply does not degrade it to a
|
|
217
|
+
* plain label — it renders the raw icon at full size and takes the header with
|
|
218
|
+
* it. Measured, not assumed.
|
|
219
|
+
*/
|
|
220
|
+
const CHIP_STYLE = {
|
|
221
|
+
display: "inline-flex",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
gap: 5,
|
|
224
|
+
padding: "1px 8px 1px 6px",
|
|
225
|
+
borderRadius: 999,
|
|
226
|
+
fontSize: 12,
|
|
227
|
+
lineHeight: "18px",
|
|
228
|
+
height: 22,
|
|
229
|
+
maxHeight: 22,
|
|
230
|
+
whiteSpace: "nowrap",
|
|
231
|
+
overflow: "hidden",
|
|
232
|
+
flex: "none",
|
|
233
|
+
border: "1px solid transparent",
|
|
234
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
235
|
+
};
|
|
236
|
+
const ICON_STYLE = {
|
|
237
|
+
width: 13,
|
|
238
|
+
height: 13,
|
|
239
|
+
flex: "none",
|
|
240
|
+
opacity: .75
|
|
241
|
+
};
|
|
242
|
+
/** The words one phase shows, given the call it belongs to. */
|
|
243
|
+
function wording(state) {
|
|
244
|
+
const phase = PHASES[state.phase];
|
|
245
|
+
const label = state.tool === void 0 ? void 0 : TOOL_LABELS[state.tool] ?? state.tool;
|
|
246
|
+
if (state.phase === "running" && label !== void 0) return {
|
|
247
|
+
text: label,
|
|
248
|
+
hint: `${phase.hint}${label}${state.tabId === void 0 ? "" : ` · 标签页 ${state.tabId}`}`
|
|
249
|
+
};
|
|
250
|
+
if (state.phase === "error") return {
|
|
251
|
+
text: phase.text,
|
|
252
|
+
hint: state.detail === void 0 ? phase.hint : `上一次调用失败:${state.detail}`
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
text: phase.text,
|
|
256
|
+
hint: phase.hint
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Render the persistent Chrome status chip.
|
|
261
|
+
* @param props - the header utility's session identity.
|
|
262
|
+
* @returns the chip.
|
|
156
263
|
*/
|
|
157
264
|
function BrowserActivity({ sessionId }) {
|
|
158
|
-
const [state, setState] = (0, react.useState)({
|
|
265
|
+
const [state, setState] = (0, react.useState)({ phase: "ready" });
|
|
159
266
|
(0, react.useEffect)(() => {
|
|
160
267
|
ensureStyles();
|
|
161
268
|
let live = true;
|
|
@@ -172,25 +279,40 @@ window.__ModuleLoader__.load({
|
|
|
172
279
|
clearInterval(timer);
|
|
173
280
|
};
|
|
174
281
|
}, [sessionId]);
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
return (0, react_jsx_runtime.jsxs)("
|
|
178
|
-
className: "cb-
|
|
282
|
+
const { text, hint } = wording(state);
|
|
283
|
+
const color = PHASE_COLOR[state.phase];
|
|
284
|
+
return (0, react_jsx_runtime.jsxs)("span", {
|
|
285
|
+
className: "cb-status",
|
|
286
|
+
"data-phase": state.phase,
|
|
179
287
|
role: "status",
|
|
180
288
|
"aria-live": "polite",
|
|
289
|
+
title: hint,
|
|
290
|
+
style: {
|
|
291
|
+
...CHIP_STYLE,
|
|
292
|
+
...color.ink === void 0 ? {} : { color: color.ink }
|
|
293
|
+
},
|
|
181
294
|
children: [
|
|
182
295
|
(0, react_jsx_runtime.jsx)("span", {
|
|
183
|
-
|
|
184
|
-
|
|
296
|
+
"aria-hidden": "true",
|
|
297
|
+
style: {
|
|
298
|
+
width: 6,
|
|
299
|
+
height: 6,
|
|
300
|
+
borderRadius: "50%",
|
|
301
|
+
flex: "none",
|
|
302
|
+
background: color.dot,
|
|
303
|
+
opacity: state.phase === "ready" ? .55 : 1,
|
|
304
|
+
...state.phase === "running" ? { animation: "cb-pulse 1.2s ease-in-out infinite" } : {}
|
|
305
|
+
}
|
|
185
306
|
}),
|
|
186
307
|
(0, react_jsx_runtime.jsx)("img", {
|
|
187
308
|
src: CHROME_ICON_SRC,
|
|
188
309
|
alt: "",
|
|
189
|
-
"aria-hidden": "true"
|
|
310
|
+
"aria-hidden": "true",
|
|
311
|
+
style: ICON_STYLE
|
|
190
312
|
}),
|
|
191
|
-
(0, react_jsx_runtime.jsx)("span", { children:
|
|
192
|
-
state.tabId === void 0 ? null : (0, react_jsx_runtime.jsxs)("span", {
|
|
193
|
-
|
|
313
|
+
(0, react_jsx_runtime.jsx)("span", { children: text }),
|
|
314
|
+
state.phase !== "running" || state.tabId === void 0 ? null : (0, react_jsx_runtime.jsxs)("span", {
|
|
315
|
+
style: { opacity: .7 },
|
|
194
316
|
children: ["标签页 ", state.tabId]
|
|
195
317
|
})
|
|
196
318
|
]
|
|
@@ -410,20 +532,20 @@ window.__ModuleLoader__.load({
|
|
|
410
532
|
* The composer dock used to carry a full-width tab selector above the input
|
|
411
533
|
* card. That row, its component and the session-binding routes behind it are
|
|
412
534
|
* gone: the live tab list lives in the `@` menu, where a pick inserts a
|
|
413
|
-
* reference chip and binds nothing. The
|
|
535
|
+
* reference chip and binds nothing. The Session header carries the status chip.
|
|
414
536
|
* @module @liyuera/dsh-chrome-browser/client
|
|
415
537
|
*/
|
|
416
538
|
/** Required services for the slot contribution and the `@` source. */
|
|
417
539
|
const inject = ["slots", "inputTriggers"];
|
|
418
540
|
/**
|
|
419
|
-
* Client plugin body: register the
|
|
541
|
+
* Client plugin body: register the Chrome status chip and the `@` tab source.
|
|
420
542
|
* @param ctx - client root context.
|
|
421
543
|
*/
|
|
422
544
|
function apply(ctx) {
|
|
423
|
-
ctx.slots.inject("conversation.
|
|
424
|
-
name: "conversation.
|
|
545
|
+
ctx.slots.inject("conversation.session.header.utilities", () => ctx.slots.register({
|
|
546
|
+
name: "conversation.session.header.utilities",
|
|
425
547
|
id: "chrome-browser-activity",
|
|
426
|
-
order:
|
|
548
|
+
order: 90
|
|
427
549
|
}, BrowserActivity));
|
|
428
550
|
ctx.effect(() => ctx.inputTriggers.registerSource(createChromeTabSource({
|
|
429
551
|
listTabs: listChromeTabs,
|