dsh-task-cat 1.0.4 → 1.0.6

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 CHANGED
@@ -37,7 +37,7 @@ Harness 的桌面外壳并没有向插件开放窗口 API(preload 只暴露文
37
37
  - 点一下桌面宠物 → 在**宠物正上方**弹出会话卡片,再点一下关闭(空间不够时自动翻到下方,并始终留在屏幕内)。卡片的层级和窗口内那份面板一致:标题「任务宠物」+ 一句话汇总 + 一句说明,下面依次是会话,每行是「状态点 + 标题 + 状态行 + 进度条」,当前打开的那一行用一张圆角卡片标出来,并带「· 当前会话」。状态点按类型上色(进行中=蓝色实心带呼吸光晕、待查看=琥珀、失败=红、已完成=绿、推进中但没在跑=薄荷空心、空闲=灰空心),状态行和窗口内那只宠物用的是同一句话(例如 `4m · 2/5 · bash`、`待查看`、`上次运行失败`),只有「进行中/推进中」的行下面才有一条进度条——已完成的行再画一条满格条只是噪音。行高统一,列表不会出现忽高忽低。清单**先排需要你的**(待查看 → 进行中 → 其余按最近更新),所以「N 个待查看」里的那几个永远在最上面;待查看一行会写清是「待查看」还是「等你回答」。默认显示 **5 个**,更多的收在底部「还有 N 个会话…」里,点一下展开全部、再点收起。点其中一行跳到那个对话,并把 Harness 窗口带到前台。卡片跟随应用的浅色/深色主题(页面把当前明暗传给助手),不会出现深色卡片压在白底应用上。
38
38
  - 宠物本身下方也有一条细进度条,显示「点它就会跳到的那个会话」的完成度;不用打开清单就能看出走到哪一步了。
39
39
  - 按住拖动可换位置;位置记在 `$DSH_HOME/cache/dsh-task-pet/position.txt`,换屏、拔掉显示器后会自动拉回可视区域。
40
- - 宠物右上角:琥珀色数字是「需要你」的会话数;同时有会话在跑时,数字左边会多一个蓝点,两个状态同时可见。
40
+ - 宠物右上角是两个计数胶囊:琥珀色=待查看的会话数(固定在角落),蓝色=正在进行中的会话数(排在它左边)。两个都为 0 时不显示;超过 9 显示 `9+`。
41
41
  - 菜单栏也有一项「任务宠物」:图标是那只宠物,待处理时带上数字,点开能看汇总和说明,以及隐藏 / 移到当前屏幕 / 打开 Harness。
42
42
  - 右键:动作菜单(打开 Harness / 移到当前屏幕 / 隐藏桌面宠物)。
43
43
  - 卡片不会抢焦点:鼠标移开卡片和宠物一会儿就自动收起,再点宠物也能收起。
@@ -56,6 +56,12 @@ Harness 的桌面外壳并没有向插件开放窗口 API(preload 只暴露文
56
56
 
57
57
  动作都在「没有状态变化时」也保持活着:呼吸(身体轻微起伏)、尾巴按自己的节奏摆动(工作时更快)、偶尔眨眼、耳朵偶尔抖一下;睡着时闭眼并冒出 `z`,需要你时瞳孔放大、右上角弹出感叹号圆盘。
58
58
 
59
+ ## 侧栏工作区标记
60
+
61
+ 工作区折叠后,标题右侧会出现一个蓝色计数:该工作区里**正在进行中**的会话数。展开时标记消失(此时每个会话行自己带状态点);数量归零也会消失。
62
+
63
+ 实现上它是只读标注:侧栏工作区行由应用自己渲染、没有暴露插槽,所以插件读 `useSessions` / `useWorkspaces` 算出每个工作区的进行中数量,再往对应行(`data-row-key="workspace:<id>"`、`aria-expanded="false"`)里插入一个徽章,并用 MutationObserver 在重渲染后补回。插件不改写、不替换行内任何应用内容。
64
+
59
65
  ## 交互
60
66
 
61
67
  - **点宠物**:展开/收起任务清单,按紧急程度排序:进行中 → 待查看 → 有进度 → 失败 → 已完成 → 空闲。
package/client.js CHANGED
@@ -113,6 +113,7 @@ window.__ModuleLoader__.load({
113
113
  'list.goal': '目标:{objective}',
114
114
  'list.jump': '打开对话',
115
115
  'list.ask': '等你回答',
116
+ 'ws.running': '{count} 个任务进行中',
116
117
  'list.behind': 'N 个待查看',
117
118
  'list.more': '还有 {count} 个会话',
118
119
  'list.less': '收起',
@@ -149,6 +150,7 @@ window.__ModuleLoader__.load({
149
150
  'list.step': 'Step {step}',
150
151
  'list.goal': 'Goal: {objective}',
151
152
  'list.ask': 'Waiting for your answer',
153
+ 'ws.running': '{count} running',
152
154
  'list.behind': '{count} need review',
153
155
  'list.more': '{count} more sessions',
154
156
  'list.less': 'Show less',
@@ -185,6 +187,7 @@ window.__ModuleLoader__.load({
185
187
  'list.step': 'ステップ {step}',
186
188
  'list.goal': '目標:{objective}',
187
189
  'list.ask': '回答待ち',
190
+ 'ws.running': '{count} 件実行中',
188
191
  'list.behind': '未確認 {count} 件',
189
192
  'list.more': '他 {count} 件',
190
193
  'list.less': '折りたたむ',
@@ -221,6 +224,7 @@ window.__ModuleLoader__.load({
221
224
  'list.step': 'Paso {step}',
222
225
  'list.goal': 'Objetivo: {objective}',
223
226
  'list.ask': 'Esperando tu respuesta',
227
+ 'ws.running': '{count} en marcha',
224
228
  'list.behind': '{count} por revisar',
225
229
  'list.more': '{count} conversaciones más',
226
230
  'list.less': 'Mostrar menos',
@@ -257,6 +261,7 @@ window.__ModuleLoader__.load({
257
261
  'list.step': 'Étape {step}',
258
262
  'list.goal': 'Objectif : {objective}',
259
263
  'list.ask': 'En attente de votre réponse',
264
+ 'ws.running': '{count} en cours',
260
265
  'list.behind': '{count} à vérifier',
261
266
  'list.more': '{count} autres conversations',
262
267
  'list.less': 'Afficher moins',
@@ -293,6 +298,7 @@ window.__ModuleLoader__.load({
293
298
  'list.step': 'Schritt {step}',
294
299
  'list.goal': 'Ziel: {objective}',
295
300
  'list.ask': 'Wartet auf deine Antwort',
301
+ 'ws.running': '{count} laufen',
296
302
  'list.behind': '{count} zu prüfen',
297
303
  'list.more': '{count} weitere Unterhaltungen',
298
304
  'list.less': 'Weniger anzeigen',
@@ -329,6 +335,7 @@ window.__ModuleLoader__.load({
329
335
  'list.step': 'Шаг {step}',
330
336
  'list.goal': 'Цель: {objective}',
331
337
  'list.ask': 'Ждёт вашего ответа',
338
+ 'ws.running': '{count} выполняется',
332
339
  'list.behind': '{count} требуют внимания',
333
340
  'list.more': 'Ещё диалогов: {count}',
334
341
  'list.less': 'Свернуть',
@@ -365,6 +372,7 @@ window.__ModuleLoader__.load({
365
372
  'list.step': 'Passo {step}',
366
373
  'list.goal': 'Meta: {objective}',
367
374
  'list.ask': 'Aguardando sua resposta',
375
+ 'ws.running': '{count} em execução',
368
376
  'list.behind': '{count} para revisar',
369
377
  'list.more': 'Mais {count} conversas',
370
378
  'list.less': 'Mostrar menos',
@@ -855,6 +863,22 @@ window.__ModuleLoader__.load({
855
863
  }
856
864
  .dsh-task-pet-fab:hover { color: var(--dsw-alias-label-primary); }
857
865
  .dsh-task-pet-fab:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
866
+ /* Marker on a collapsed workspace row with running Sessions. */
867
+ .dsh-task-cat-wsmark {
868
+ flex: none;
869
+ margin-left: 6px;
870
+ min-width: 16px;
871
+ height: 16px;
872
+ padding: 0 4px;
873
+ border-radius: 8px;
874
+ background: #4c90f2;
875
+ color: #fff;
876
+ font-size: 10px;
877
+ font-weight: 600;
878
+ line-height: 16px;
879
+ text-align: center;
880
+ font-variant-numeric: tabular-nums;
881
+ }
858
882
  @keyframes dsh-task-pet-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
859
883
  /* The cat keeps moving between state changes: a tail on its own tempo, a slow
860
884
  breath, and the occasional blink, all slower than the bob so they never sync. */
@@ -885,6 +909,127 @@ window.__ModuleLoader__.load({
885
909
  * @param props.t - translator.
886
910
  * @returns the row button.
887
911
  */
912
+ /**
913
+ * Mark collapsed workspace headers whose group still has running work.
914
+ *
915
+ * The sidebar renders workspace rows itself and exposes no slot for the row,
916
+ * so this reads the two sanctioned data sources and annotates the rendered
917
+ * row: `data-row-key="workspace:<id>"` and its `aria-expanded`. Nothing is
918
+ * replaced — a badge is inserted and removed again, and a MutationObserver
919
+ * reapplies it after any re-render.
920
+ *
921
+ * @param props.useSessions - Session list selector hook.
922
+ * @param props.useWorkspaces - Workspace selector hook (items and archive).
923
+ * @returns nothing; this entry only touches the DOM.
924
+ */
925
+ function WorkspaceMarkers({ useSessions, useWorkspaces, t }) {
926
+ const running = useSessions((state) => {
927
+ const ids = [];
928
+ for (const id of state.ids) {
929
+ const row = state.byId[id];
930
+ if (row === undefined || row.origin === 'subagent') continue;
931
+ if (row.running === true || (row.projectionValues !== undefined
932
+ && row.projectionValues.taskPet !== undefined
933
+ && row.projectionValues.taskPet.active === true)) ids.push(id);
934
+ }
935
+ return ids;
936
+ }, sameIds);
937
+ const groups = useWorkspaces((state) => (state.items === undefined
938
+ ? []
939
+ : state.items.map((item) => ({
940
+ id: item.workspaceId,
941
+ sessions: item.sessionIds === undefined ? [] : [...item.sessionIds]
942
+ }))), sameGroups);
943
+ // The counts feed a DOM pass rather than markup, so keep the latest values
944
+ // in a ref and repaint whenever either side moves.
945
+ const latest = React.useRef({ running, groups });
946
+ latest.current = { running, groups };
947
+
948
+ React.useEffect(() => {
949
+ const runningSet = new Set(running);
950
+ /** @returns the count of running Sessions in one workspace group. */
951
+ const countOf = (sessions) => sessions.reduce((total, id) => total + (runningSet.has(id) ? 1 : 0), 0);
952
+ const wanted = new Map();
953
+ for (const group of groups) {
954
+ if (typeof group.id !== 'string' || group.id === '') continue;
955
+ const count = countOf(group.sessions);
956
+ if (count > 0) wanted.set(group.id, count);
957
+ }
958
+
959
+ /** Paint one workspace row, or drop the badge it no longer earns. */
960
+ const paint = (row) => {
961
+ const key = row.getAttribute('data-row-key') ?? '';
962
+ if (!key.startsWith('workspace:')) return;
963
+ const id = key.slice('workspace:'.length);
964
+ const collapsed = row.getAttribute('aria-expanded') === 'false';
965
+ const count = collapsed ? wanted.get(id) : undefined;
966
+ const existing = row.querySelector('[data-dsh-task-cat="workspace"]');
967
+ if (count === undefined) {
968
+ if (existing !== null) existing.remove();
969
+ return;
970
+ }
971
+ if (existing !== null) {
972
+ existing.textContent = String(count);
973
+ return;
974
+ }
975
+ const badge = document.createElement('span');
976
+ badge.setAttribute('data-dsh-task-cat', 'workspace');
977
+ badge.className = 'dsh-task-cat-wsmark';
978
+ badge.textContent = String(count);
979
+ badge.title = t('ws.running', { count });
980
+ // Land it after the title block but before the row's actions: the row
981
+ // is a flex line whose last child is that action cluster. Appending to
982
+ // the row would put the badge to the right of hidden hover buttons.
983
+ const tail = row.lastElementChild;
984
+ if (tail !== null && tail !== row.firstElementChild) row.insertBefore(badge, tail);
985
+ else row.appendChild(badge);
986
+ };
987
+
988
+ const paintAll = () => {
989
+ for (const row of document.querySelectorAll('[data-row-key^="workspace:"]')) paint(row);
990
+ };
991
+ paintAll();
992
+ const observer = new MutationObserver(paintAll);
993
+ observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-expanded', 'data-row-key'] });
994
+ return () => {
995
+ observer.disconnect();
996
+ for (const badge of document.querySelectorAll('[data-dsh-task-cat="workspace"]')) badge.remove();
997
+ };
998
+ }, [running, groups]);
999
+
1000
+ return null;
1001
+ }
1002
+
1003
+ /**
1004
+ * Whether two id lists are the same set, so the overlay does not repaint on
1005
+ * every Session tick.
1006
+ * @param left - previous ids.
1007
+ * @param right - next ids.
1008
+ * @returns true when nothing changed.
1009
+ */
1010
+ function sameIds(left, right) {
1011
+ if (left.length !== right.length) return false;
1012
+ for (let index = 0; index < left.length; index += 1) {
1013
+ if (left[index] !== right[index]) return false;
1014
+ }
1015
+ return true;
1016
+ }
1017
+
1018
+ /**
1019
+ * Whether two workspace groups describe the same membership.
1020
+ * @param left - previous groups.
1021
+ * @param right - next groups.
1022
+ * @returns true when nothing changed.
1023
+ */
1024
+ function sameGroups(left, right) {
1025
+ if (left.length !== right.length) return false;
1026
+ for (let index = 0; index < left.length; index += 1) {
1027
+ if (left[index].id !== right[index].id) return false;
1028
+ if (!sameIds(left[index].sessions, right[index].sessions)) return false;
1029
+ }
1030
+ return true;
1031
+ }
1032
+
888
1033
  /**
889
1034
  * The one-line status for a Session: elapsed time, todo progress, the tool
890
1035
  * it is on, or why it is worth a look. Shared with the desktop pet so both
@@ -1508,6 +1653,13 @@ window.__ModuleLoader__.load({
1508
1653
  openSession: (sessionId) => { ctx.uiWorkspace.openSession(sessionId); }
1509
1654
  })
1510
1655
  }, TaskPet));
1656
+ // Second entry, drawing nothing: it only marks collapsed workspace rows.
1657
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({
1658
+ name: 'shell.overlay',
1659
+ id: `${NS}-workspaces`,
1660
+ order: 21,
1661
+ locale: NS
1662
+ }, WorkspaceMarkers));
1511
1663
  }
1512
1664
  };
1513
1665
  }
@@ -205,6 +205,9 @@ final class PetView: NSView {
205
205
  var mood: String = "sleeping"
206
206
  var badge: Int = 0
207
207
  var attention: Int = 0
208
+ /// Sessions currently running; shown as its own count so "in progress" is a
209
+ /// number, not just a dot.
210
+ var running: Int = 0
208
211
  var working: Bool = false
209
212
  var phase: CGFloat = 0
210
213
  /// Completion of the row a click would jump to, drawn as a ring; nil hides it.
@@ -228,10 +231,9 @@ final class PetView: NSView {
228
231
  // The meter is a gauge for the whole overlay, so it stays put while the pet
229
232
  // bobs, and it never competes with the count badge in the top-right corner.
230
233
  drawProgressMeter(ctx)
231
- if badge > 0 { drawBadge(ctx, text: badge > 9 ? "9+" : String(badge)) }
232
- // The badge counts what needs the user; when something is also running, the
233
- // badge alone hid that. A small dot beside it keeps both facts on the pet.
234
- if working && badge > 0 { drawRunningDot(ctx) }
234
+ // Two counts, two colours: what is waiting on the user, and what is running
235
+ // right now. A dot could not say how many, which is what the user asked for.
236
+ drawCounts(ctx)
235
237
  }
236
238
 
237
239
  /// A slim meter under the pet showing how much of the target Session's plan is
@@ -273,7 +275,7 @@ final class PetView: NSView {
273
275
  let nose = CGColor(srgbRed: 0.925, green: 0.639, blue: 0.675, alpha: 1)
274
276
 
275
277
  let alert = mood == "alert"
276
- let alarmed = alert && badge == 0
278
+ let alarmed = alert && attention == 0
277
279
  let asleep = mood == "sleeping"
278
280
 
279
281
  // Idle life: a slow breath, a swaying tail, the occasional blink.
@@ -430,7 +432,7 @@ final class PetView: NSView {
430
432
  ctx.setFillColor(CGColor(srgbRed: 1, green: 1, blue: 1, alpha: 1))
431
433
  fillRounded(ctx, CGRect(x: 49.1, y: 50.2, width: 1.8, height: 5.2), 0.9)
432
434
  fillRounded(ctx, CGRect(x: 49.1, y: 47.2, width: 1.8, height: 1.8), 0.9)
433
- } else if working && badge == 0 {
435
+ } else if working && attention == 0 {
434
436
  for (index, spot) in [(CGFloat(50), CGFloat(52), CGFloat(2.2)),
435
437
  (56, 48, 1.6),
436
438
  (60, 42, 1.1)].enumerated() {
@@ -448,33 +450,39 @@ final class PetView: NSView {
448
450
  }
449
451
  }
450
452
 
451
- /// A blue dot left of the count badge: "something is running right now".
452
- private func drawRunningDot(_ ctx: CGContext) {
453
- let badgeWidth: CGFloat = badge > 9 ? 24 : 20
454
- let x = bounds.width - badgeWidth - 2 - 12
455
- let rect = CGRect(x: x, y: bounds.height - 16, width: 8, height: 8)
456
- ctx.setFillColor(CGColor(srgbRed: 0.298, green: 0.565, blue: 0.949, alpha: 1))
457
- ctx.fillEllipse(in: rect)
458
- ctx.setStrokeColor(CGColor(srgbRed: 1, green: 1, blue: 1, alpha: 0.85))
459
- ctx.setLineWidth(1.2)
460
- ctx.strokeEllipse(in: rect.insetBy(dx: 0.6, dy: 0.6))
453
+ /// Draw the attention and running counts side by side in the top-right corner.
454
+ private func drawCounts(_ ctx: CGContext) {
455
+ // "Needs you" keeps the corner it has always had; "running" sits beside it,
456
+ // so the count that asks for action never moves.
457
+ var right = bounds.width - 2
458
+ if attention > 0 {
459
+ right = drawPill(ctx, count: attention,
460
+ fill: CGColor(srgbRed: 0.961, green: 0.729, blue: 0.196, alpha: 1),
461
+ ink: NSColor(srgbRed: 0.122, green: 0.102, blue: 0.031, alpha: 1), right: right) - 4
462
+ }
463
+ if running > 0 {
464
+ _ = drawPill(ctx, count: running,
465
+ fill: CGColor(srgbRed: 0.298, green: 0.565, blue: 0.949, alpha: 1),
466
+ ink: NSColor.white, right: right)
467
+ }
461
468
  }
462
469
 
463
- private func drawBadge(_ ctx: CGContext, text: String) {
470
+ /// One count pill, right-aligned at `right`.
471
+ /// @returns the pill's left edge, so the next one can be placed beside it.
472
+ @discardableResult
473
+ private func drawPill(_ ctx: CGContext, count: Int, fill: CGColor, ink: NSColor, right: CGFloat) -> CGFloat {
474
+ let text = count > 9 ? "9+" : String(count)
464
475
  let width: CGFloat = text.count > 1 ? 24 : 20
465
- let rect = CGRect(x: bounds.width - width - 2, y: bounds.height - 22, width: width, height: 20)
466
- ctx.setFillColor(attention > 0
467
- ? CGColor(srgbRed: 0.961, green: 0.729, blue: 0.196, alpha: 1)
468
- : CGColor(srgbRed: 0.129, green: 0.231, blue: 0.2, alpha: 0.92))
476
+ let rect = CGRect(x: right - width, y: bounds.height - 22, width: width, height: 20)
477
+ ctx.setFillColor(fill)
469
478
  fillRounded(ctx, rect, 10)
470
479
  let string = NSAttributedString(string: text, attributes: [
471
480
  .font: NSFont.systemFont(ofSize: 11, weight: .semibold),
472
- .foregroundColor: attention > 0
473
- ? NSColor(srgbRed: 0.122, green: 0.102, blue: 0.031, alpha: 1)
474
- : NSColor.white,
481
+ .foregroundColor: ink,
475
482
  ])
476
483
  let size = string.size()
477
484
  string.draw(at: CGPoint(x: rect.midX - size.width / 2, y: rect.midY - size.height / 2))
485
+ return rect.minX
478
486
  }
479
487
  }
480
488
 
@@ -1345,6 +1353,7 @@ final class PetWindowController: NSObject {
1345
1353
  if let mood = message.mood { view.mood = mood }
1346
1354
  if let badge = message.badge { view.badge = badge }
1347
1355
  if let attention = message.attention { view.attention = attention }
1356
+ if let running = message.running { view.running = running }
1348
1357
  if let light = message.light { usesLightSurface = light }
1349
1358
  if let summary = message.summary { summaryText = summary }
1350
1359
  if !summaryText.isEmpty || !sessions.isEmpty {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-task-cat",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Task cat: a floating white cat that watches every session's progress and jumps into the conversation that needs you.",
5
5
  "type": "module",
6
6
  "exports": {