dsh-leader-agent 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/lib/client.js CHANGED
@@ -320,7 +320,7 @@ function isBoardEntryVisible(project, sessionId, isWorker) {
320
320
  }
321
321
  async function resolveBoardAccess(callRemote, sessionId) {
322
322
  const project = await resolveProject(callRemote, sessionId);
323
- if (project === void 0) return { project, worker: false };
323
+ if (project === void 0) return resolveBoardAccessFromRegistry(callRemote, sessionId);
324
324
  if (isLeaderProject(project, sessionId)) return { project, worker: false };
325
325
  if (isRetiredLeaderSession(project, sessionId)) return { project, worker: false };
326
326
  try {
@@ -330,6 +330,26 @@ async function resolveBoardAccess(callRemote, sessionId) {
330
330
  return { project, worker: false };
331
331
  }
332
332
  }
333
+ async function resolveBoardAccessFromRegistry(callRemote, sessionId) {
334
+ try {
335
+ const sessions = await fetchProjectSessions(callRemote);
336
+ let projectId;
337
+ for (const [id, ids] of sessions) {
338
+ if (ids.has(sessionId)) {
339
+ projectId = id;
340
+ break;
341
+ }
342
+ }
343
+ if (projectId === void 0) return { project: void 0, worker: false };
344
+ const projects = await callRemote("list", []);
345
+ const project = Array.isArray(projects) ? projects.find((item) => item?.id === projectId) : void 0;
346
+ if (project === void 0) return { project: void 0, worker: false };
347
+ if (isRetiredLeaderSession(project, sessionId)) return { project, worker: false };
348
+ return { project, worker: !isLeaderProject(project, sessionId) };
349
+ } catch {
350
+ return { project: void 0, worker: false };
351
+ }
352
+ }
333
353
  async function fetchProjectSessions(callRemote) {
334
354
  const groups = await callRemote("sessionsByProject", []);
335
355
  const table = /* @__PURE__ */ new Map();
@@ -581,7 +601,9 @@ var zh = Object.freeze({
581
601
  "guide.steps": "\u4F60\u53EF\u4EE5\u8BA9\u5B83\u5EFA\u4EFB\u52A1\u5361\u3001\u7ED9 Agent \u6D3E\u6D3B\uFF0C\u5728\u53F3\u680F\u770B\u677F\u8DDF\u8FDB",
582
602
  "guide.action.intro": "\u4E86\u89E3\u600E\u4E48\u7528",
583
603
  "guide.action.dismiss": "\u77E5\u9053\u4E86",
584
- "guide.intro.prompt": "\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u914D\u7F6E\uFF0C\u5148\u8BB2\u8BB2 dsh-leader-agent \u600E\u4E48\u7528\u3002"
604
+ "guide.intro.prompt": "\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u914D\u7F6E\uFF0C\u5148\u8BB2\u8BB2 dsh-leader-agent \u600E\u4E48\u7528\u3002",
605
+ "tabs.list": "\u9879\u76EE\u4F1A\u8BDD\u6807\u7B7E",
606
+ "tabs.close": "\u5173\u95ED\u6807\u7B7E"
585
607
  });
586
608
  var en = Object.freeze({
587
609
  "slot.discuss": "Discuss",
@@ -591,7 +613,9 @@ var en = Object.freeze({
591
613
  "guide.steps": "Open task cards, hand work to Agents, track progress in the board",
592
614
  "guide.action.intro": "Show me how to use it",
593
615
  "guide.action.dismiss": "Got it",
594
- "guide.intro.prompt": "This project isn't set up yet \u2014 show me how dsh-leader-agent works."
616
+ "guide.intro.prompt": "This project isn't set up yet \u2014 show me how dsh-leader-agent works.",
617
+ "tabs.list": "Project session tabs",
618
+ "tabs.close": "Close tab"
595
619
  });
596
620
  function slotLabel(name, t) {
597
621
  const key = SLOT_LABEL_KEYS[name];
@@ -2960,22 +2984,56 @@ function ConfirmDialog({
2960
2984
  });
2961
2985
  }
2962
2986
 
2987
+ // src/client/board-foreground.js
2988
+ var foregroundSessionId;
2989
+ function noteBoardForeground(sessionId) {
2990
+ foregroundSessionId = sessionId;
2991
+ }
2992
+ function clearBoardForeground(sessionId) {
2993
+ if (foregroundSessionId === sessionId) foregroundSessionId = void 0;
2994
+ }
2995
+ function lastBoardForegroundSession() {
2996
+ return foregroundSessionId;
2997
+ }
2998
+
2963
2999
  // src/client/board.js
2964
3000
  var PROJECT_RECHECK_MS = 3e4;
3001
+ var BOARD_CACHE = /* @__PURE__ */ new Map();
3002
+ function cachedBoard(projectId) {
3003
+ return BOARD_CACHE.get(projectId);
3004
+ }
3005
+ function rememberBoard(projectId, project, cards) {
3006
+ BOARD_CACHE.set(projectId, { project, cards });
3007
+ }
2965
3008
  function BoardBody(props) {
2966
- const { sessionId, getSessions, getUiWorkspace, useSessionStatus, callRemote, t } = props;
3009
+ const { sessionId, getSessions, getUiWorkspace, useSessionStatus, useTabInfo, getSidebarRight, callRemote, t } = props;
3010
+ const useInfo = typeof useTabInfo === "function" ? useTabInfo : useNoTabInfo;
3011
+ const tabInfo = useInfo();
3012
+ const visible = tabInfo?.tab?.visible !== false;
3013
+ const mountedSessionId = getSidebarRight?.()?.mounted?.getSnapshot?.();
3014
+ (0, import_react8.useEffect)(() => {
3015
+ if (visible) noteBoardForeground(sessionId);
3016
+ else if (mountedSessionId === sessionId) clearBoardForeground(sessionId);
3017
+ }, [visible, mountedSessionId, sessionId]);
3018
+ const params = tabInfo?.tab?.navigation?.params;
3019
+ const projectHint = typeof params?.projectId === "string" ? params.projectId : void 0;
2967
3020
  return (0, import_react8.createElement)(BoardPanel, {
2968
3021
  sessionId,
2969
3022
  getSessions,
2970
3023
  getUiWorkspace,
2971
3024
  useSessionStatus,
2972
3025
  callRemote,
2973
- t
3026
+ t,
3027
+ visible,
3028
+ projectHint
2974
3029
  });
2975
3030
  }
2976
3031
  function useNoSessionStatus() {
2977
3032
  return void 0;
2978
3033
  }
3034
+ function useNoTabInfo() {
3035
+ return void 0;
3036
+ }
2979
3037
  function sameSlotLabels(left, right) {
2980
3038
  const leftKeys = Object.keys(left);
2981
3039
  const rightKeys = Object.keys(right);
@@ -3127,15 +3185,18 @@ function BoardSkeleton() {
3127
3185
  )
3128
3186
  );
3129
3187
  }
3130
- function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus, callRemote, t }) {
3131
- const [project, setProject] = (0, import_react8.useState)(void 0);
3132
- const [resolved, setResolved] = (0, import_react8.useState)(false);
3133
- const [worker, setWorker] = (0, import_react8.useState)(void 0);
3134
- const [cards, setCards] = (0, import_react8.useState)(() => []);
3188
+ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus, callRemote, t, visible, projectHint }) {
3189
+ const cached = projectHint === void 0 ? void 0 : cachedBoard(projectHint);
3190
+ const [project, setProject] = (0, import_react8.useState)(cached?.project);
3191
+ const [resolved, setResolved] = (0, import_react8.useState)(cached !== void 0);
3192
+ const [worker, setWorker] = (0, import_react8.useState)(cached === void 0 ? void 0 : true);
3193
+ const [cards, setCards] = (0, import_react8.useState)(() => cached?.cards ?? []);
3135
3194
  const [projectError, setProjectError] = (0, import_react8.useState)(null);
3136
3195
  const [cardsError, setCardsError] = (0, import_react8.useState)(null);
3137
3196
  const [slotLabels, setSlotLabels] = (0, import_react8.useState)(() => ({}));
3138
- const [loaded, setLoaded] = (0, import_react8.useState)(false);
3197
+ const [loaded, setLoaded] = (0, import_react8.useState)(cached !== void 0);
3198
+ const prefilled = (0, import_react8.useRef)(cached !== void 0);
3199
+ const accessSession = (0, import_react8.useRef)(void 0);
3139
3200
  const [detail, setDetail] = (0, import_react8.useState)(null);
3140
3201
  const [pendingDelete, setPendingDelete] = (0, import_react8.useState)(null);
3141
3202
  const [deleteBusy, setDeleteBusy] = (0, import_react8.useState)(false);
@@ -3152,22 +3213,37 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
3152
3213
  setDeleteError("");
3153
3214
  }, [project?.id]);
3154
3215
  (0, import_react8.useEffect)(() => {
3216
+ if (!visible) return void 0;
3217
+ setNow(Date.now());
3155
3218
  const timer = setInterval(() => {
3156
3219
  setNow(Date.now());
3157
3220
  }, 6e4);
3158
3221
  return () => clearInterval(timer);
3159
- }, []);
3222
+ }, [visible]);
3223
+ (0, import_react8.useEffect)(() => {
3224
+ if (visible) return;
3225
+ setDetail(null);
3226
+ setPendingDelete(null);
3227
+ setDeleteError("");
3228
+ }, [visible]);
3160
3229
  (0, import_react8.useEffect)(() => {
3230
+ if (!visible) return void 0;
3161
3231
  let cancelled = false;
3232
+ const sameSession = accessSession.current === sessionId;
3233
+ accessSession.current = sessionId;
3234
+ const keepPrefilled = prefilled.current || sameSession;
3235
+ prefilled.current = false;
3162
3236
  setProjectError(null);
3163
- setResolved(false);
3164
- setCards([]);
3165
- setLoaded(false);
3166
- setWorker(void 0);
3167
- setSlotLabels({});
3237
+ if (!keepPrefilled) {
3238
+ setResolved(false);
3239
+ setCards([]);
3240
+ setLoaded(false);
3241
+ setWorker(void 0);
3242
+ setSlotLabels({});
3243
+ deletedCardIds.current.clear();
3244
+ }
3168
3245
  setPendingDelete(null);
3169
3246
  setDeleteError("");
3170
- deletedCardIds.current.clear();
3171
3247
  const load = () => {
3172
3248
  resolveBoardAccess(callRemote, sessionId).then((access) => {
3173
3249
  if (cancelled) return;
@@ -3200,8 +3276,9 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
3200
3276
  clearInterval(timer);
3201
3277
  window.removeEventListener("focus", onFocus);
3202
3278
  };
3203
- }, [sessionId, callRemote]);
3279
+ }, [sessionId, callRemote, visible]);
3204
3280
  (0, import_react8.useEffect)(() => {
3281
+ if (!visible) return void 0;
3205
3282
  if (!isBoardViewable(project, sessionId, worker)) return void 0;
3206
3283
  let cancelled = false;
3207
3284
  const refresh = () => {
@@ -3229,7 +3306,11 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
3229
3306
  clearInterval(timer);
3230
3307
  window.removeEventListener("focus", onFocus);
3231
3308
  };
3232
- }, [project, worker, callRemote, sessionId]);
3309
+ }, [project, worker, callRemote, sessionId, visible]);
3310
+ (0, import_react8.useEffect)(() => {
3311
+ if (project === void 0 || !loaded) return;
3312
+ rememberBoard(project.id, project, cards);
3313
+ }, [project, cards, loaded]);
3233
3314
  const cardList = cards;
3234
3315
  const states = useSlotStates(cardList, getSessions, useSessionStatus, sessionId);
3235
3316
  const { active, done } = (0, import_react8.useMemo)(() => ({
@@ -6164,10 +6245,674 @@ function createReadySignal() {
6164
6245
  };
6165
6246
  }
6166
6247
 
6167
- // src/client/toast-view.js
6248
+ // src/client/session-tabs.js
6168
6249
  var import_react14 = require("react");
6169
- var STYLE_ID5 = "dsh-leader-agent-toast-style";
6250
+ var import_react_dom4 = require("react-dom");
6251
+ var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
6252
+
6253
+ // src/client/session-tabs-logic.js
6254
+ var SESSION_TABS_STORAGE_KEY = "dsh-leader-agent.session-tabs.v1";
6255
+ var MAX_OPEN_TABS_PER_PROJECT = 50;
6256
+ function validKey(value) {
6257
+ return typeof value === "string" && value.length > 0 && value.length <= 200 && !/[\u0000-\u001f\u007f]/.test(value);
6258
+ }
6259
+ function emptyTabStore() {
6260
+ return { version: 1, projects: {} };
6261
+ }
6262
+ function projectsOf(store) {
6263
+ const projects = store?.projects;
6264
+ if (projects === null || typeof projects !== "object" || Array.isArray(projects)) return {};
6265
+ return projects;
6266
+ }
6267
+ function normalizeStore(value) {
6268
+ if (value === null || typeof value !== "object" || value.version !== 1) return emptyTabStore();
6269
+ const entries = [];
6270
+ for (const [projectId, ids] of Object.entries(projectsOf(value))) {
6271
+ if (!validKey(projectId) || !Array.isArray(ids)) continue;
6272
+ const seen = /* @__PURE__ */ new Set();
6273
+ for (const id of ids) {
6274
+ if (!validKey(id) || seen.has(id)) continue;
6275
+ seen.add(id);
6276
+ if (seen.size >= MAX_OPEN_TABS_PER_PROJECT) break;
6277
+ }
6278
+ if (seen.size > 0) entries.push([projectId, [...seen]]);
6279
+ }
6280
+ return { version: 1, projects: Object.fromEntries(entries) };
6281
+ }
6282
+ function parseTabStore(raw) {
6283
+ if (typeof raw !== "string" || raw === "") return emptyTabStore();
6284
+ let value;
6285
+ try {
6286
+ value = JSON.parse(raw);
6287
+ } catch {
6288
+ return emptyTabStore();
6289
+ }
6290
+ return normalizeStore(value);
6291
+ }
6292
+ function serializeTabStore(store) {
6293
+ return JSON.stringify(normalizeStore(store));
6294
+ }
6295
+ function openTabIds(store, projectId) {
6296
+ if (!validKey(projectId)) return [];
6297
+ const ids = projectsOf(store)[projectId];
6298
+ if (!Array.isArray(ids)) return [];
6299
+ return ids.filter((id) => validKey(id));
6300
+ }
6301
+ function hasOpenTab(store, projectId, sessionId) {
6302
+ return openTabIds(store, projectId).includes(sessionId);
6303
+ }
6304
+ function addOpenTab(store, projectId, sessionId) {
6305
+ if (!validKey(projectId) || !validKey(sessionId)) return store;
6306
+ const current2 = openTabIds(store, projectId);
6307
+ if (current2.includes(sessionId)) return store;
6308
+ if (current2.length >= MAX_OPEN_TABS_PER_PROJECT) return store;
6309
+ return {
6310
+ version: 1,
6311
+ projects: { ...projectsOf(store), [projectId]: [...current2, sessionId] }
6312
+ };
6313
+ }
6314
+ function removeOpenTab(store, projectId, sessionId) {
6315
+ if (!validKey(projectId) || !validKey(sessionId)) return store;
6316
+ const current2 = openTabIds(store, projectId);
6317
+ if (!current2.includes(sessionId)) return store;
6318
+ const next = current2.filter((id) => id !== sessionId);
6319
+ const projects = { ...projectsOf(store) };
6320
+ if (next.length === 0) delete projects[projectId];
6321
+ else projects[projectId] = next;
6322
+ return { version: 1, projects };
6323
+ }
6324
+ function workerTabState(row) {
6325
+ if (row?.running === true) return "ongoing";
6326
+ if (row?.completed === true) return "done";
6327
+ return "idle";
6328
+ }
6329
+ function sessionLabel(row, sessionId) {
6330
+ const display = row?.displayTitle;
6331
+ if (typeof display === "string" && display !== "") return display;
6332
+ const title = row?.title;
6333
+ if (typeof title === "string" && title !== "") return title;
6334
+ return sessionId;
6335
+ }
6336
+ function findProjectSession(projects, groups, sessionId) {
6337
+ if (!validKey(sessionId) || !Array.isArray(projects)) return null;
6338
+ const leaderProject = projects.find((project2) => project2 !== null && typeof project2 === "object" && project2.leaderSessionId === sessionId && validKey(project2.id));
6339
+ if (leaderProject !== void 0) {
6340
+ if (leaderProject.leaderAlive === false) return null;
6341
+ const group2 = Array.isArray(groups) ? groups.find((entry) => entry?.projectId === leaderProject.id) : void 0;
6342
+ return { project: leaderProject, group: group2, leader: true };
6343
+ }
6344
+ if (!Array.isArray(groups)) return null;
6345
+ const group = groups.find((entry) => entry !== null && typeof entry === "object" && Array.isArray(entry.sessionIds) && entry.sessionIds.includes(sessionId));
6346
+ if (group === void 0) return null;
6347
+ const project = projects.find((entry) => entry?.id === group.projectId);
6348
+ if (project === void 0 || !validKey(project.leaderSessionId)) return null;
6349
+ if (project.leaderAlive === false) return null;
6350
+ const retired = Array.isArray(project.retiredLeaderSessionIds) ? project.retiredLeaderSessionIds : [];
6351
+ if (retired.includes(sessionId)) return null;
6352
+ return { project, group, leader: false };
6353
+ }
6354
+ function hiddenView(activeSessionId) {
6355
+ return {
6356
+ visible: false,
6357
+ project: null,
6358
+ leaderId: null,
6359
+ tabs: [],
6360
+ activeSessionId,
6361
+ isLeaderCurrent: false,
6362
+ isWorkerCurrent: false,
6363
+ workerIds: []
6364
+ };
6365
+ }
6366
+ function resolveTabView({ projects, groups, rows, currentSessionId, store }) {
6367
+ if (!validKey(currentSessionId)) return hiddenView(currentSessionId);
6368
+ const found = findProjectSession(projects, groups, currentSessionId);
6369
+ if (found === null) return hiddenView(currentSessionId);
6370
+ const { project, group, leader } = found;
6371
+ const retired = new Set(Array.isArray(project.retiredLeaderSessionIds) ? project.retiredLeaderSessionIds : []);
6372
+ const groupIds = Array.isArray(group?.sessionIds) ? group.sessionIds : [];
6373
+ const workerIds = [];
6374
+ const seen = /* @__PURE__ */ new Set();
6375
+ for (const id of groupIds) {
6376
+ if (!validKey(id) || seen.has(id) || id === project.leaderSessionId || retired.has(id)) continue;
6377
+ seen.add(id);
6378
+ if (rows?.[id] === void 0) continue;
6379
+ workerIds.push(id);
6380
+ }
6381
+ if (workerIds.length === 0) return hiddenView(currentSessionId);
6382
+ const open = new Set(openTabIds(store, project.id));
6383
+ const tabs = [
6384
+ {
6385
+ id: project.leaderSessionId,
6386
+ kind: "leader",
6387
+ label: typeof project.name === "string" && project.name !== "" ? project.name : project.id,
6388
+ state: "idle"
6389
+ },
6390
+ ...workerIds.filter((id) => open.has(id)).map((id) => ({
6391
+ id,
6392
+ kind: "worker",
6393
+ label: sessionLabel(rows[id], id),
6394
+ state: workerTabState(rows[id])
6395
+ }))
6396
+ ];
6397
+ return {
6398
+ visible: true,
6399
+ project,
6400
+ leaderId: project.leaderSessionId,
6401
+ tabs,
6402
+ activeSessionId: currentSessionId,
6403
+ isLeaderCurrent: leader,
6404
+ isWorkerCurrent: !leader && workerIds.includes(currentSessionId),
6405
+ workerIds
6406
+ };
6407
+ }
6408
+ function tabIdForKey(tabs, activeId, key) {
6409
+ if (!Array.isArray(tabs) || tabs.length === 0) return void 0;
6410
+ const found = tabs.findIndex((tab) => tab?.id === activeId);
6411
+ const index = found === -1 ? 0 : found;
6412
+ switch (key) {
6413
+ case "ArrowRight":
6414
+ return tabs[(index + 1) % tabs.length]?.id;
6415
+ case "ArrowLeft":
6416
+ return tabs[(index - 1 + tabs.length) % tabs.length]?.id;
6417
+ case "Home":
6418
+ return tabs[0]?.id;
6419
+ case "End":
6420
+ return tabs[tabs.length - 1]?.id;
6421
+ default:
6422
+ return void 0;
6423
+ }
6424
+ }
6425
+ function tabAfterClose(view, closingId) {
6426
+ if (view?.visible !== true || typeof closingId !== "string") return null;
6427
+ if (view.activeSessionId !== closingId) return null;
6428
+ return view.leaderId;
6429
+ }
6430
+
6431
+ // src/client/session-tabs.js
6432
+ var STYLE_ID5 = "dsh-leader-agent-session-tabs-style";
6433
+ var COLUMN_ATTR = "data-dsh-leader-agent-tabs-column";
6434
+ var MAIN_ATTR = "data-dsh-leader-agent-tabs-main";
6170
6435
  var STYLE_TEXT5 = `
6436
+ [${COLUMN_ATTR}] { min-height: 0; }
6437
+ [${MAIN_ATTR}] {
6438
+ flex: 1 1 0 !important;
6439
+ min-height: 0 !important;
6440
+ height: auto !important;
6441
+ }
6442
+ [data-dsh-leader-agent-session-tabs] { display: contents; }
6443
+ .dsh-leader-agent-tabs {
6444
+ flex: none;
6445
+ display: flex;
6446
+ align-items: center;
6447
+ gap: 4px;
6448
+ height: 38px;
6449
+ min-width: 0;
6450
+ box-sizing: border-box;
6451
+ padding-block: 0;
6452
+ padding-inline-start: max(20px, var(--dsh-frame-leading-clearance, 0px));
6453
+ padding-inline-end: 20px;
6454
+ background: var(--dsw-alias-bg-base);
6455
+ border-bottom: .5px solid var(--dsw-alias-border-l3);
6456
+ -webkit-app-region: drag;
6457
+ overflow: hidden;
6458
+ }
6459
+ .dsh-leader-agent-tabs-scroll {
6460
+ flex: 1 1 auto;
6461
+ display: flex;
6462
+ align-items: center;
6463
+ gap: 4px;
6464
+ min-width: 0;
6465
+ overflow-x: auto;
6466
+ overflow-y: hidden;
6467
+ scrollbar-width: none;
6468
+ }
6469
+ .dsh-leader-agent-tabs-scroll::-webkit-scrollbar { display: none; }
6470
+ .dsh-leader-agent-tab {
6471
+ position: relative;
6472
+ flex: none;
6473
+ display: flex;
6474
+ align-items: center;
6475
+ gap: 5px;
6476
+ height: 28px;
6477
+ max-width: 240px;
6478
+ box-sizing: border-box;
6479
+ padding: 0 6px 0 8px;
6480
+ border-radius: var(--dsw-radius-sm, 8px);
6481
+ color: var(--dsw-alias-label-secondary);
6482
+ font-size: 13px;
6483
+ line-height: 18px;
6484
+ font-weight: 500;
6485
+ cursor: pointer;
6486
+ user-select: none;
6487
+ -webkit-app-region: no-drag;
6488
+ outline: none;
6489
+ }
6490
+ .dsh-leader-agent-tab:hover:not([aria-selected='true']) {
6491
+ background: color-mix(in srgb, var(--dsw-alias-interactive-bg-hover) 55%, transparent);
6492
+ color: var(--dsw-alias-label-primary);
6493
+ }
6494
+ .dsh-leader-agent-tab[aria-selected='true'] {
6495
+ background: var(--dsw-alias-interactive-bg-hover);
6496
+ color: var(--dsw-alias-label-primary);
6497
+ }
6498
+ .dsh-leader-agent-tab:focus-visible {
6499
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4176e6);
6500
+ outline-offset: -2px;
6501
+ }
6502
+ .dsh-leader-agent-tab[data-kind='leader'] { font-weight: 600; }
6503
+ .dsh-leader-agent-tab-icon {
6504
+ flex: none;
6505
+ display: flex;
6506
+ color: var(--dsw-alias-label-tertiary);
6507
+ }
6508
+ .dsh-leader-agent-tab-dot {
6509
+ flex: none;
6510
+ display: flex;
6511
+ align-items: center;
6512
+ justify-content: center;
6513
+ width: 12px;
6514
+ height: 12px;
6515
+ }
6516
+ .dsh-leader-agent-tab-label {
6517
+ min-width: 0;
6518
+ overflow: hidden;
6519
+ text-overflow: ellipsis;
6520
+ white-space: nowrap;
6521
+ }
6522
+ .dsh-leader-agent-tab-close {
6523
+ flex: none;
6524
+ display: flex;
6525
+ align-items: center;
6526
+ justify-content: center;
6527
+ width: 16px;
6528
+ height: 16px;
6529
+ margin-inline-start: 1px;
6530
+ padding: 0;
6531
+ border: 0;
6532
+ border-radius: var(--dsw-radius-xs, 4px);
6533
+ background: transparent;
6534
+ color: var(--dsw-alias-label-tertiary);
6535
+ cursor: pointer;
6536
+ opacity: 0;
6537
+ transition: opacity 120ms ease, background-color 120ms ease;
6538
+ }
6539
+ .dsh-leader-agent-tab:hover .dsh-leader-agent-tab-close,
6540
+ .dsh-leader-agent-tab[aria-selected='true'] .dsh-leader-agent-tab-close,
6541
+ .dsh-leader-agent-tab-close:focus-visible { opacity: 1; }
6542
+ .dsh-leader-agent-tab-close:hover {
6543
+ background: var(--dsw-alias-interactive-bg-hover);
6544
+ color: var(--dsw-alias-label-primary);
6545
+ }
6546
+ .dsh-leader-agent-tab-close:focus-visible {
6547
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4176e6);
6548
+ outline-offset: -2px;
6549
+ }
6550
+ @media (prefers-reduced-motion: reduce) {
6551
+ .dsh-leader-agent-tab-close { transition: none; }
6552
+ }
6553
+ `;
6554
+ function ensureStyles4() {
6555
+ if (typeof document === "undefined") return;
6556
+ if (document.getElementById(STYLE_ID5) !== null) return;
6557
+ const style = document.createElement("style");
6558
+ style.id = STYLE_ID5;
6559
+ style.textContent = STYLE_TEXT5;
6560
+ document.head.append(style);
6561
+ }
6562
+ function findMainSlot() {
6563
+ if (typeof document === "undefined") return null;
6564
+ return document.querySelector('#root [data-slot="main"]') ?? document.querySelector('[data-slot="main"]') ?? document.querySelector('[class*="mainPanel"]');
6565
+ }
6566
+ function findColumn(slot) {
6567
+ let column = slot.parentElement;
6568
+ while (column !== null && column.hasAttribute("data-slot") && column.parentElement !== null) {
6569
+ column = column.parentElement;
6570
+ }
6571
+ return column ?? slot;
6572
+ }
6573
+ function mainBodyOf(slot) {
6574
+ let body = slot.firstElementChild;
6575
+ while (body !== null && typeof window !== "undefined" && window.getComputedStyle(body).display === "contents") {
6576
+ body = body.firstElementChild;
6577
+ }
6578
+ return body;
6579
+ }
6580
+ function SessionTabsAnchor(props) {
6581
+ const [host, setHost] = (0, import_react14.useState)(null);
6582
+ const visibleRef = (0, import_react14.useRef)(false);
6583
+ const applyRef = (0, import_react14.useRef)(null);
6584
+ const reportVisible = (0, import_react14.useCallback)((next) => {
6585
+ if (visibleRef.current === next) return;
6586
+ visibleRef.current = next;
6587
+ applyRef.current?.();
6588
+ }, []);
6589
+ (0, import_react14.useEffect)(() => {
6590
+ ensureStyles4();
6591
+ const created = document.createElement("div");
6592
+ created.setAttribute("data-dsh-leader-agent-session-tabs", "");
6593
+ let column = null;
6594
+ let mainBody = null;
6595
+ let retry = null;
6596
+ let scheduled = false;
6597
+ let scheduleTimer = null;
6598
+ let alive = true;
6599
+ const apply2 = () => {
6600
+ if (!alive) return;
6601
+ if (!visibleRef.current) {
6602
+ column?.removeAttribute(COLUMN_ATTR);
6603
+ mainBody?.removeAttribute(MAIN_ATTR);
6604
+ created.remove();
6605
+ column = null;
6606
+ mainBody = null;
6607
+ return;
6608
+ }
6609
+ const slot = findMainSlot();
6610
+ if (slot === null) return;
6611
+ const nextColumn = findColumn(slot);
6612
+ const nextBody = mainBodyOf(slot);
6613
+ if (nextColumn !== column) {
6614
+ column?.removeAttribute(COLUMN_ATTR);
6615
+ column = nextColumn;
6616
+ }
6617
+ if (nextBody !== mainBody) {
6618
+ mainBody?.removeAttribute(MAIN_ATTR);
6619
+ mainBody = nextBody;
6620
+ }
6621
+ column.setAttribute(COLUMN_ATTR, "");
6622
+ mainBody?.setAttribute(MAIN_ATTR, "");
6623
+ if (created.parentElement !== column) column.insertBefore(created, column.firstElementChild);
6624
+ };
6625
+ applyRef.current = apply2;
6626
+ apply2();
6627
+ if (visibleRef.current && created.parentElement === null) {
6628
+ retry = setTimeout(apply2, 250);
6629
+ }
6630
+ setHost(created);
6631
+ const schedule = () => {
6632
+ if (!alive || scheduled) return;
6633
+ scheduled = true;
6634
+ scheduleTimer = setTimeout(() => {
6635
+ scheduled = false;
6636
+ if (!alive || !visibleRef.current) return;
6637
+ if (created.parentElement === null || mainBody !== null && !mainBody.isConnected) apply2();
6638
+ }, 16);
6639
+ };
6640
+ const observer = new MutationObserver(schedule);
6641
+ if (typeof document !== "undefined" && document.body !== null) {
6642
+ observer.observe(document.body, { childList: true, subtree: true });
6643
+ }
6644
+ return () => {
6645
+ alive = false;
6646
+ observer.disconnect();
6647
+ if (retry !== null) clearTimeout(retry);
6648
+ if (scheduleTimer !== null) clearTimeout(scheduleTimer);
6649
+ applyRef.current = null;
6650
+ visibleRef.current = false;
6651
+ column?.removeAttribute(COLUMN_ATTR);
6652
+ mainBody?.removeAttribute(MAIN_ATTR);
6653
+ created.remove();
6654
+ document.getElementById(STYLE_ID5)?.remove();
6655
+ };
6656
+ }, []);
6657
+ return host === null ? null : (0, import_react_dom4.createPortal)((0, import_react14.createElement)(SessionTabBar, { ...props, reportVisible }), host);
6658
+ }
6659
+ function SessionTabBar({ t, callRemote, getSessions, getUiWorkspace, getLayout, getSidebarRight, reportVisible }) {
6660
+ const sessions = getSessions?.();
6661
+ const [snapshot, setSnapshot] = (0, import_react14.useState)(() => sessions?.list?.getSnapshot?.() ?? {
6662
+ phase: "pending",
6663
+ ids: [],
6664
+ byId: {}
6665
+ });
6666
+ const [completed, setCompleted] = (0, import_react14.useState)(() => /* @__PURE__ */ new Set());
6667
+ const [projects, setProjects] = (0, import_react14.useState)([]);
6668
+ const [groups, setGroups] = (0, import_react14.useState)([]);
6669
+ const [store, setStore] = (0, import_react14.useState)(readStore);
6670
+ const [panelActive, setPanelActive] = (0, import_react14.useState)(false);
6671
+ const lastCurrent = (0, import_react14.useRef)(void 0);
6672
+ const tabRefs = (0, import_react14.useRef)(/* @__PURE__ */ new Map());
6673
+ const pendingFocus = (0, import_react14.useRef)(void 0);
6674
+ const refresh = (0, import_react14.useCallback)(async () => {
6675
+ if (!isProjectRemoteReady()) return;
6676
+ try {
6677
+ const [nextProjects, nextGroups] = await Promise.all([
6678
+ callRemote("list", []),
6679
+ callRemote("sessionsByProject", [])
6680
+ ]);
6681
+ setProjects(Array.isArray(nextProjects) ? nextProjects : []);
6682
+ setGroups(Array.isArray(nextGroups) ? nextGroups : []);
6683
+ } catch (error) {
6684
+ console.error("dsh-leader-agent: \u8BFB\u53D6\u9879\u76EE\u6807\u7B7E\u6570\u636E\u5931\u8D25", error);
6685
+ }
6686
+ }, [callRemote]);
6687
+ (0, import_react14.useEffect)(() => {
6688
+ if (!sessions?.list?.subscribe) return void 0;
6689
+ const tracker = createSessionCompletionTracker();
6690
+ const sync = () => {
6691
+ const next = sessions.list.getSnapshot();
6692
+ setSnapshot(next);
6693
+ setCompleted(new Set(tracker.update(next)));
6694
+ };
6695
+ sync();
6696
+ return sessions.list.subscribe(sync);
6697
+ }, [sessions]);
6698
+ (0, import_react14.useEffect)(() => onProjectRemoteReady(() => {
6699
+ void refresh();
6700
+ }), [refresh]);
6701
+ (0, import_react14.useEffect)(() => {
6702
+ const stop = onProjectsChanged(() => {
6703
+ void refresh();
6704
+ });
6705
+ const onFocus = () => {
6706
+ void refresh();
6707
+ };
6708
+ window.addEventListener("focus", onFocus);
6709
+ return () => {
6710
+ stop();
6711
+ window.removeEventListener("focus", onFocus);
6712
+ };
6713
+ }, [refresh]);
6714
+ (0, import_react14.useEffect)(() => {
6715
+ const info = getLayout?.()?.panelInfo;
6716
+ if (info === void 0 || typeof info.subscribe !== "function") return void 0;
6717
+ const sync = () => setPanelActive(info.getSnapshot().activePanelId !== null);
6718
+ sync();
6719
+ return info.subscribe(sync);
6720
+ }, [getLayout]);
6721
+ const currentSessionId = (0, import_react14.useMemo)(() => currentSessionIdOf(snapshot.byId), [snapshot]);
6722
+ (0, import_react14.useEffect)(() => {
6723
+ const previous = lastCurrent.current;
6724
+ lastCurrent.current = currentSessionId;
6725
+ if (previous !== void 0 && currentSessionId !== void 0 && previous !== currentSessionId) {
6726
+ void refresh();
6727
+ }
6728
+ }, [currentSessionId, refresh]);
6729
+ (0, import_react14.useEffect)(() => {
6730
+ try {
6731
+ window.localStorage.setItem(SESSION_TABS_STORAGE_KEY, serializeTabStore(store));
6732
+ } catch {
6733
+ }
6734
+ }, [store]);
6735
+ const rows = (0, import_react14.useMemo)(() => {
6736
+ const next = {};
6737
+ for (const [id, row] of Object.entries(snapshot.byId ?? {})) {
6738
+ next[id] = {
6739
+ id,
6740
+ title: row.title,
6741
+ displayTitle: row.displayTitle,
6742
+ running: row.running,
6743
+ completed: completed.has(id)
6744
+ };
6745
+ }
6746
+ return next;
6747
+ }, [snapshot, completed]);
6748
+ const view = (0, import_react14.useMemo)(() => resolveTabView({
6749
+ projects,
6750
+ groups,
6751
+ rows,
6752
+ currentSessionId,
6753
+ store
6754
+ }), [projects, groups, rows, currentSessionId, store]);
6755
+ (0, import_react14.useEffect)(() => {
6756
+ const id = pendingFocus.current;
6757
+ if (id === void 0 || view.activeSessionId !== id) return void 0;
6758
+ pendingFocus.current = void 0;
6759
+ const frame = requestAnimationFrame(() => {
6760
+ tabRefs.current.get(id)?.focus();
6761
+ });
6762
+ return () => cancelAnimationFrame(frame);
6763
+ }, [view.activeSessionId]);
6764
+ (0, import_react14.useEffect)(() => {
6765
+ if (!view.visible || !view.isWorkerCurrent || currentSessionId === void 0) return;
6766
+ if (hasOpenTab(store, view.project.id, currentSessionId)) return;
6767
+ setStore((current2) => addOpenTab(current2, view.project.id, currentSessionId));
6768
+ }, [view.visible, view.isWorkerCurrent, view.project?.id, currentSessionId]);
6769
+ const lastBoardCarry = (0, import_react14.useRef)(void 0);
6770
+ const carryBoard = (0, import_react14.useCallback)(() => {
6771
+ if (panelActive || currentSessionId === void 0) return;
6772
+ if (!view.visible || !view.isWorkerCurrent) {
6773
+ lastBoardCarry.current = void 0;
6774
+ return;
6775
+ }
6776
+ if (lastBoardCarry.current === currentSessionId) return;
6777
+ const leaderId = view.project?.leaderSessionId;
6778
+ if (typeof leaderId !== "string" || leaderId === "") return;
6779
+ const sidebarRight = getSidebarRight?.();
6780
+ if (sidebarRight === void 0 || sidebarRight === null) return;
6781
+ if (typeof sidebarRight.tabsIn !== "function") return;
6782
+ if (lastBoardForegroundSession() !== leaderId) return;
6783
+ if (!sidebarRight.tabsIn(leaderId).some((tab) => tab.kind === BOARD_TAB_KIND)) return;
6784
+ if (sidebarRight.mounted?.getSnapshot?.() !== currentSessionId) return;
6785
+ const existing = sidebarRight.tabsIn(currentSessionId).find((tab) => tab.kind === BOARD_TAB_KIND);
6786
+ if (existing !== void 0) {
6787
+ lastBoardCarry.current = currentSessionId;
6788
+ if (sidebarRight.active?.()?.id !== existing.id) sidebarRight.focus(existing.id);
6789
+ return;
6790
+ }
6791
+ try {
6792
+ sidebarRight.openTab(BOARD_TAB_KIND, { params: { projectId: view.project.id } });
6793
+ } catch {
6794
+ return;
6795
+ }
6796
+ lastBoardCarry.current = currentSessionId;
6797
+ }, [currentSessionId, getSidebarRight, panelActive, view.visible, view.isWorkerCurrent, view.project?.id, view.project?.leaderSessionId]);
6798
+ (0, import_react14.useLayoutEffect)(() => {
6799
+ carryBoard();
6800
+ }, [carryBoard]);
6801
+ (0, import_react14.useEffect)(() => {
6802
+ carryBoard();
6803
+ }, [carryBoard]);
6804
+ const barVisible = view.visible && !panelActive;
6805
+ (0, import_react14.useLayoutEffect)(() => {
6806
+ reportVisible?.(barVisible);
6807
+ }, [barVisible, reportVisible]);
6808
+ if (!barVisible) return null;
6809
+ const listLabel = typeof t === "function" ? t("tabs.list") : "\u9879\u76EE\u4F1A\u8BDD\u6807\u7B7E";
6810
+ const closeLabel = typeof t === "function" ? t("tabs.close") : "\u5173\u95ED\u6807\u7B7E";
6811
+ const openSession = (sessionId) => {
6812
+ if (sessionId === view.activeSessionId) return;
6813
+ const workspace = getUiWorkspace?.();
6814
+ if (workspace !== void 0 && typeof workspace.openSession === "function") {
6815
+ workspace.openSession(sessionId);
6816
+ }
6817
+ };
6818
+ const closeSession = (sessionId) => {
6819
+ const fallback = tabAfterClose(view, sessionId);
6820
+ if (fallback !== null) {
6821
+ const workspace = getUiWorkspace?.();
6822
+ if (workspace === void 0 || typeof workspace.openSession !== "function") return;
6823
+ workspace.openSession(fallback);
6824
+ }
6825
+ setStore((current2) => removeOpenTab(current2, view.project.id, sessionId));
6826
+ };
6827
+ return (0, import_react14.createElement)(
6828
+ "div",
6829
+ {
6830
+ className: "dsh-leader-agent-tabs",
6831
+ "data-dsh-leader-agent-session-tabs-bar": "",
6832
+ role: "tablist",
6833
+ "aria-label": listLabel
6834
+ },
6835
+ (0, import_react14.createElement)(
6836
+ "div",
6837
+ { className: "dsh-leader-agent-tabs-scroll" },
6838
+ ...view.tabs.map((tab) => (0, import_react14.createElement)(
6839
+ "div",
6840
+ {
6841
+ key: tab.id,
6842
+ className: "dsh-leader-agent-tab",
6843
+ "data-session-id": tab.id,
6844
+ "data-kind": tab.kind,
6845
+ role: "tab",
6846
+ tabIndex: tab.id === view.activeSessionId ? 0 : -1,
6847
+ "aria-selected": tab.id === view.activeSessionId ? "true" : "false",
6848
+ title: tab.label,
6849
+ ref: (node) => {
6850
+ if (node === null) tabRefs.current.delete(tab.id);
6851
+ else tabRefs.current.set(tab.id, node);
6852
+ },
6853
+ onClick: () => openSession(tab.id),
6854
+ onKeyDown: (event) => {
6855
+ if (event.target !== event.currentTarget) return;
6856
+ if (event.key === "Enter" || event.key === " ") {
6857
+ event.preventDefault();
6858
+ openSession(tab.id);
6859
+ return;
6860
+ }
6861
+ const nextId = tabIdForKey(view.tabs, tab.id, event.key);
6862
+ if (nextId === void 0) return;
6863
+ event.preventDefault();
6864
+ if (nextId === view.activeSessionId) {
6865
+ tabRefs.current.get(nextId)?.focus();
6866
+ return;
6867
+ }
6868
+ pendingFocus.current = nextId;
6869
+ openSession(nextId);
6870
+ }
6871
+ },
6872
+ tab.kind === "leader" ? (0, import_react14.createElement)(
6873
+ "span",
6874
+ { className: "dsh-leader-agent-tab-icon" },
6875
+ productIcon("apps-add-outline", { size: 14 })
6876
+ ) : (0, import_react14.createElement)(
6877
+ "span",
6878
+ { className: "dsh-leader-agent-tab-dot" },
6879
+ (0, import_react14.createElement)(import_dsh_client_ui_primitives4.StateDot, {
6880
+ state: tab.state,
6881
+ size: tab.state === "ongoing" ? 12 : 8
6882
+ })
6883
+ ),
6884
+ (0, import_react14.createElement)("span", { className: "dsh-leader-agent-tab-label" }, tab.label),
6885
+ tab.kind === "worker" ? (0, import_react14.createElement)(
6886
+ "button",
6887
+ {
6888
+ type: "button",
6889
+ className: "dsh-leader-agent-tab-close",
6890
+ "aria-label": closeLabel + " " + tab.label,
6891
+ title: closeLabel + " " + tab.label,
6892
+ onClick: (event) => {
6893
+ event.stopPropagation();
6894
+ closeSession(tab.id);
6895
+ }
6896
+ },
6897
+ productIcon("close-outline", { size: 12 })
6898
+ ) : null
6899
+ ))
6900
+ )
6901
+ );
6902
+ }
6903
+ function readStore() {
6904
+ if (typeof window === "undefined") return emptyTabStore();
6905
+ try {
6906
+ return parseTabStore(window.localStorage.getItem(SESSION_TABS_STORAGE_KEY));
6907
+ } catch {
6908
+ return emptyTabStore();
6909
+ }
6910
+ }
6911
+
6912
+ // src/client/toast-view.js
6913
+ var import_react15 = require("react");
6914
+ var STYLE_ID6 = "dsh-leader-agent-toast-style";
6915
+ var STYLE_TEXT6 = `
6171
6916
  .dsh-leader-agent-toast {
6172
6917
  position: fixed;
6173
6918
  top: 40px;
@@ -6201,32 +6946,32 @@ var STYLE_TEXT5 = `
6201
6946
  }
6202
6947
  }
6203
6948
  `;
6204
- function ensureStyles4() {
6949
+ function ensureStyles5() {
6205
6950
  if (typeof document === "undefined") return;
6206
- if (document.getElementById(STYLE_ID5) !== null) return;
6951
+ if (document.getElementById(STYLE_ID6) !== null) return;
6207
6952
  const style = document.createElement("style");
6208
- style.id = STYLE_ID5;
6209
- style.textContent = STYLE_TEXT5;
6953
+ style.id = STYLE_ID6;
6954
+ style.textContent = STYLE_TEXT6;
6210
6955
  document.head.append(style);
6211
6956
  }
6212
6957
  function ToastOverlay() {
6213
- const [toast, setToast] = (0, import_react14.useState)(currentToast);
6214
- (0, import_react14.useEffect)(() => {
6215
- ensureStyles4();
6958
+ const [toast, setToast] = (0, import_react15.useState)(currentToast);
6959
+ (0, import_react15.useEffect)(() => {
6960
+ ensureStyles5();
6216
6961
  setToast(currentToast());
6217
6962
  return subscribeToasts(() => setToast(currentToast()));
6218
6963
  }, []);
6219
- (0, import_react14.useEffect)(() => {
6964
+ (0, import_react15.useEffect)(() => {
6220
6965
  if (toast === null) return void 0;
6221
6966
  const timer = setTimeout(() => dismissToast(toast.id), toast.holdMs + toast.fadeMs);
6222
6967
  return () => clearTimeout(timer);
6223
6968
  }, [toast]);
6224
6969
  if (toast === null) return null;
6225
- return (0, import_react14.createElement)(
6226
- import_react14.Fragment,
6970
+ return (0, import_react15.createElement)(
6971
+ import_react15.Fragment,
6227
6972
  // key 跟着每次弹出换:同一条文案连着出现两次时重挂载,动画与计时都重来。
6228
6973
  { key: toast.id },
6229
- (0, import_react14.createElement)(
6974
+ (0, import_react15.createElement)(
6230
6975
  "div",
6231
6976
  {
6232
6977
  className: "dsh-leader-agent-toast",
@@ -6345,10 +7090,10 @@ var workerReportDefinition = {
6345
7090
  };
6346
7091
 
6347
7092
  // src/client/worker-report-view.js
6348
- var import_react16 = require("react");
7093
+ var import_react17 = require("react");
6349
7094
 
6350
7095
  // src/client/agent-bubble-view.js
6351
- var import_react15 = require("react");
7096
+ var import_react16 = require("react");
6352
7097
 
6353
7098
  // node_modules/minidenticons/minidenticons.js
6354
7099
  var COLORS_NB = 9;
@@ -6488,8 +7233,8 @@ function agentAvatarDataUri(name) {
6488
7233
  }
6489
7234
 
6490
7235
  // src/client/agent-bubble-styles.js
6491
- var STYLE_ID6 = "dsh-leader-agent-agent-bubble";
6492
- var STYLE_TEXT6 = `
7236
+ var STYLE_ID7 = "dsh-leader-agent-agent-bubble";
7237
+ var STYLE_TEXT7 = `
6493
7238
  .dsh-leader-agent-agent-bubble {
6494
7239
  display: flex;
6495
7240
  flex-direction: column;
@@ -6629,10 +7374,10 @@ var STYLE_TEXT6 = `
6629
7374
  `;
6630
7375
  function ensureAgentBubbleStyles() {
6631
7376
  if (typeof document === "undefined") return;
6632
- if (document.getElementById(STYLE_ID6) !== null) return;
7377
+ if (document.getElementById(STYLE_ID7) !== null) return;
6633
7378
  const style = document.createElement("style");
6634
- style.id = STYLE_ID6;
6635
- style.textContent = STYLE_TEXT6;
7379
+ style.id = STYLE_ID7;
7380
+ style.textContent = STYLE_TEXT7;
6636
7381
  document.head.append(style);
6637
7382
  }
6638
7383
 
@@ -6651,11 +7396,11 @@ function formatBubbleClock(time) {
6651
7396
 
6652
7397
  // src/client/agent-bubble-view.js
6653
7398
  function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, time }) {
6654
- const [copied, setCopied] = (0, import_react15.useState)(false);
6655
- const [expanded, setExpanded] = (0, import_react15.useState)(false);
6656
- const [overflowing, setOverflowing] = (0, import_react15.useState)(false);
6657
- const bubbleRef = (0, import_react15.useRef)(null);
6658
- (0, import_react15.useLayoutEffect)(() => {
7399
+ const [copied, setCopied] = (0, import_react16.useState)(false);
7400
+ const [expanded, setExpanded] = (0, import_react16.useState)(false);
7401
+ const [overflowing, setOverflowing] = (0, import_react16.useState)(false);
7402
+ const bubbleRef = (0, import_react16.useRef)(null);
7403
+ (0, import_react16.useLayoutEffect)(() => {
6659
7404
  ensureAgentBubbleStyles();
6660
7405
  const element = bubbleRef.current;
6661
7406
  if (element === null || expanded) return void 0;
@@ -6677,18 +7422,18 @@ function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, ti
6677
7422
  setCopied(true);
6678
7423
  setTimeout(() => setCopied(false), 1500);
6679
7424
  };
6680
- return (0, import_react15.createElement)(
7425
+ return (0, import_react16.createElement)(
6681
7426
  "div",
6682
7427
  { className: "dsh-leader-agent-agent-bubble" },
6683
- (0, import_react15.createElement)(
7428
+ (0, import_react16.createElement)(
6684
7429
  "div",
6685
7430
  { className: "dsh-leader-agent-agent-bubble__identity" },
6686
- (0, import_react15.createElement)("img", {
7431
+ (0, import_react16.createElement)("img", {
6687
7432
  className: "dsh-leader-agent-agent-bubble__avatar",
6688
7433
  src: agentAvatarDataUri(avatarSeed),
6689
7434
  alt: ""
6690
7435
  }),
6691
- (0, import_react15.createElement)(
7436
+ (0, import_react16.createElement)(
6692
7437
  "button",
6693
7438
  {
6694
7439
  type: "button",
@@ -6699,20 +7444,20 @@ function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, ti
6699
7444
  name
6700
7445
  )
6701
7446
  ),
6702
- (0, import_react15.createElement)(
7447
+ (0, import_react16.createElement)(
6703
7448
  "div",
6704
7449
  { className: "dsh-leader-agent-agent-bubble__bubble" },
6705
7450
  // 裁剪只发生在正文层:按钮在气泡内、正文外,否则展开开关会跟着两行水位被裁掉
6706
- (0, import_react15.createElement)(
7451
+ (0, import_react16.createElement)(
6707
7452
  "div",
6708
7453
  {
6709
7454
  ref: bubbleRef,
6710
7455
  className: "dsh-leader-agent-agent-bubble__content",
6711
7456
  "data-collapsed": expanded ? void 0 : "true"
6712
7457
  },
6713
- format === "markdown" ? (0, import_react15.createElement)(Markdown, { source: body }) : (0, import_react15.createElement)("div", { className: "dsh-leader-agent-agent-bubble__plain" }, body)
7458
+ format === "markdown" ? (0, import_react16.createElement)(Markdown, { source: body }) : (0, import_react16.createElement)("div", { className: "dsh-leader-agent-agent-bubble__plain" }, body)
6714
7459
  ),
6715
- overflowing ? (0, import_react15.createElement)(
7460
+ overflowing ? (0, import_react16.createElement)(
6716
7461
  "button",
6717
7462
  {
6718
7463
  type: "button",
@@ -6723,11 +7468,11 @@ function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, ti
6723
7468
  expanded ? "\u6536\u8D77" : "\u5C55\u793A\u66F4\u591A"
6724
7469
  ) : null
6725
7470
  ),
6726
- (0, import_react15.createElement)(
7471
+ (0, import_react16.createElement)(
6727
7472
  "div",
6728
7473
  { className: "dsh-leader-agent-agent-bubble__meta" },
6729
- (0, import_react15.createElement)("span", { className: "dsh-leader-agent-agent-bubble__time" }, formatBubbleClock(time)),
6730
- (0, import_react15.createElement)(
7474
+ (0, import_react16.createElement)("span", { className: "dsh-leader-agent-agent-bubble__time" }, formatBubbleClock(time)),
7475
+ (0, import_react16.createElement)(
6731
7476
  "button",
6732
7477
  {
6733
7478
  type: "button",
@@ -6748,7 +7493,7 @@ function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, ti
6748
7493
  function WorkerReportView({ node, openSession }) {
6749
7494
  const data = node?.data;
6750
7495
  if (data === void 0) return null;
6751
- return (0, import_react16.createElement)(AgentBubble, {
7496
+ return (0, import_react17.createElement)(AgentBubble, {
6752
7497
  name: data.name,
6753
7498
  avatarSeed: data.name,
6754
7499
  openTitle: `\u6253\u5F00 ${data.name} \u7684\u5B50\u4F1A\u8BDD`,
@@ -6815,11 +7560,11 @@ var workerTaskDefinition = {
6815
7560
  };
6816
7561
 
6817
7562
  // src/client/worker-task-view.js
6818
- var import_react17 = require("react");
7563
+ var import_react18 = require("react");
6819
7564
 
6820
7565
  // src/client/worker-task-styles.js
6821
- var STYLE_ID7 = "dsh-leader-agent-worker-task";
6822
- var STYLE_TEXT7 = `
7566
+ var STYLE_ID8 = "dsh-leader-agent-worker-task";
7567
+ var STYLE_TEXT8 = `
6823
7568
  .dsh-leader-agent-worker-task {
6824
7569
  display: flex;
6825
7570
  flex-direction: column;
@@ -6886,18 +7631,18 @@ var STYLE_TEXT7 = `
6886
7631
  `;
6887
7632
  function ensureWorkerTaskStyles() {
6888
7633
  if (typeof document === "undefined") return;
6889
- if (document.getElementById(STYLE_ID7) !== null) return;
7634
+ if (document.getElementById(STYLE_ID8) !== null) return;
6890
7635
  const style = document.createElement("style");
6891
- style.id = STYLE_ID7;
6892
- style.textContent = STYLE_TEXT7;
7636
+ style.id = STYLE_ID8;
7637
+ style.textContent = STYLE_TEXT8;
6893
7638
  document.head.append(style);
6894
7639
  }
6895
7640
 
6896
7641
  // src/client/worker-task-view.js
6897
7642
  function WorkerTaskView({ node }) {
6898
7643
  const data = node?.data;
6899
- const [copied, setCopied] = (0, import_react17.useState)(false);
6900
- (0, import_react17.useLayoutEffect)(() => {
7644
+ const [copied, setCopied] = (0, import_react18.useState)(false);
7645
+ (0, import_react18.useLayoutEffect)(() => {
6901
7646
  ensureWorkerTaskStyles();
6902
7647
  }, []);
6903
7648
  if (data === void 0) return null;
@@ -6911,10 +7656,10 @@ function WorkerTaskView({ node }) {
6911
7656
  setCopied(true);
6912
7657
  setTimeout(() => setCopied(false), 1500);
6913
7658
  };
6914
- return (0, import_react17.createElement)(
7659
+ return (0, import_react18.createElement)(
6915
7660
  "div",
6916
7661
  { className: "dsh-leader-agent-worker-task" },
6917
- (0, import_react17.createElement)(
7662
+ (0, import_react18.createElement)(
6918
7663
  "div",
6919
7664
  {
6920
7665
  className: "dsh-leader-agent-worker-task__bubble",
@@ -6926,13 +7671,13 @@ function WorkerTaskView({ node }) {
6926
7671
  },
6927
7672
  // 与 assistant 内容同套 Markdown:原文直接交给基线 MarkdownText,不补硬换行、
6928
7673
  // 不做行级改写;单换行按 Markdown 合并。
6929
- (0, import_react17.createElement)(Markdown, { source: body, variant: "compact" })
7674
+ (0, import_react18.createElement)(Markdown, { source: body, variant: "compact" })
6930
7675
  ),
6931
- (0, import_react17.createElement)(
7676
+ (0, import_react18.createElement)(
6932
7677
  "div",
6933
7678
  { className: "dsh-leader-agent-worker-task__meta" },
6934
- (0, import_react17.createElement)("span", { className: "dsh-leader-agent-worker-task__time" }, formatBubbleClock(data.time)),
6935
- (0, import_react17.createElement)(
7679
+ (0, import_react18.createElement)("span", { className: "dsh-leader-agent-worker-task__time" }, formatBubbleClock(data.time)),
7680
+ (0, import_react18.createElement)(
6936
7681
  "button",
6937
7682
  {
6938
7683
  type: "button",
@@ -6960,6 +7705,9 @@ function apply(ctx) {
6960
7705
  ctx.effect(() => ctx.sidebarRightTabs.register({
6961
7706
  id: PLUGIN_ID,
6962
7707
  kind: "dsh-leader-agent-board",
7708
+ // 右栏按会话存布局:切会话时宿主会卸载非当前会话的栏。看板保留已访问的
7709
+ // body(keepMounted),切回来不重挂、不重新拉项目与卡片,避免闪一下。
7710
+ keepMounted: true,
6963
7711
  title: () => "\u770B\u677F",
6964
7712
  guide: [{
6965
7713
  id: "board",
@@ -6977,6 +7725,7 @@ function apply(ctx) {
6977
7725
  inject: () => ({
6978
7726
  getSessions: () => ctx.sessions,
6979
7727
  getUiWorkspace: () => ctx.get("uiWorkspace"),
7728
+ getSidebarRight: () => ctx.get("sidebarRight"),
6980
7729
  callRemote: (method, args) => callProjectRemote(ctx, method, args)
6981
7730
  })
6982
7731
  }, BoardBody)), "dsh-leader-agent \u770B\u677F\u9762\u677F");
@@ -7010,6 +7759,19 @@ function apply(ctx) {
7010
7759
  id: "dsh-leader-agent-toast",
7011
7760
  order: 20
7012
7761
  }, ToastOverlay)), "dsh-leader-agent \u63D0\u793A\u6D6E\u5C42");
7762
+ ctx.effect(() => ctx.slots.inject("shell.overlay", () => ctx.slots.register({
7763
+ name: "shell.overlay",
7764
+ id: "dsh-leader-agent-session-tabs",
7765
+ order: 30,
7766
+ locale: SLOT_LOCALE_NAMESPACE,
7767
+ inject: () => ({
7768
+ callRemote: (method, args) => callProjectRemote(ctx, method, args),
7769
+ getSessions: () => ctx.sessions,
7770
+ getUiWorkspace: () => ctx.get("uiWorkspace"),
7771
+ getLayout: () => ctx.get("layout"),
7772
+ getSidebarRight: () => ctx.get("sidebarRight")
7773
+ })
7774
+ }, SessionTabsAnchor)), "dsh-leader-agent \u4F1A\u8BDD\u6807\u7B7E\u680F");
7013
7775
  ctx.inject(["uiConversation"], function mountLeaderViewFiber(conversationCtx) {
7014
7776
  mountLeaderView(conversationCtx);
7015
7777
  mountGuideCard(conversationCtx);