dsh-task-cat 1.0.1 → 1.0.3

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
@@ -34,9 +34,10 @@ Harness 的桌面外壳并没有向插件开放窗口 API(preload 只暴露文
34
34
 
35
35
  行为细节:
36
36
 
37
- - 点一下桌面宠物 → 在**宠物正上方**弹出会话卡片,再点一下关闭(空间不够时自动翻到下方,并始终留在屏幕内)。卡片的层级和窗口内那份面板一致:标题「任务宠物」+ 一句话汇总 + 一句说明,下面依次是会话,每行是「状态点 + 标题 + 状态行 + 进度条」,当前打开的那一行用一张圆角卡片标出来,并带「· 当前会话」。状态点按类型上色(进行中=蓝色实心带呼吸光晕、待查看=琥珀、失败=红、已完成=绿、推进中但没在跑=薄荷空心、空闲=灰空心),状态行和窗口内那只宠物用的是同一句话(例如 `4m · 2/5 · bash`、`待查看`、`上次运行失败`),有 todo 的行下面还有一条进度条。清单**按最近更新排序**(新开的会话排在最上面),默认显示 **5 个**,更多的收在底部「还有 N 个会话…」里,点一下展开全部、再点收起。点其中一行跳到那个对话,并把 Harness 窗口带到前台。卡片跟随应用的浅色/深色主题(页面把当前明暗传给助手),不会出现深色卡片压在白底应用上。
37
+ - 点一下桌面宠物 → 在**宠物正上方**弹出会话卡片,再点一下关闭(空间不够时自动翻到下方,并始终留在屏幕内)。卡片的层级和窗口内那份面板一致:标题「任务宠物」+ 一句话汇总 + 一句说明,下面依次是会话,每行是「状态点 + 标题 + 状态行 + 进度条」,当前打开的那一行用一张圆角卡片标出来,并带「· 当前会话」。状态点按类型上色(进行中=蓝色实心带呼吸光晕、待查看=琥珀、失败=红、已完成=绿、推进中但没在跑=薄荷空心、空闲=灰空心),状态行和窗口内那只宠物用的是同一句话(例如 `4m · 2/5 · bash`、`待查看`、`上次运行失败`),有 todo 的行下面还有一条进度条。清单**先排需要你的**(待查看 → 进行中 → 其余按最近更新),所以「N 个待查看」里的那几个永远在最上面;待查看一行会写清是「待查看」还是「等你回答」。默认显示 **5 个**,更多的收在底部「还有 N 个会话…」里,点一下展开全部、再点收起。点其中一行跳到那个对话,并把 Harness 窗口带到前台。卡片跟随应用的浅色/深色主题(页面把当前明暗传给助手),不会出现深色卡片压在白底应用上。
38
38
  - 宠物本身下方也有一条细进度条,显示「点它就会跳到的那个会话」的完成度;不用打开清单就能看出走到哪一步了。
39
39
  - 按住拖动可换位置;位置记在 `$DSH_HOME/cache/dsh-task-pet/position.txt`,换屏、拔掉显示器后会自动拉回可视区域。
40
+ - 宠物右上角:琥珀色数字是「需要你」的会话数;同时有会话在跑时,数字左边会多一个蓝点,两个状态同时可见。
40
41
  - 菜单栏也有一项「任务宠物」:图标是那只宠物,待处理时带上数字,点开能看汇总和说明,以及隐藏 / 移到当前屏幕 / 打开 Harness。
41
42
  - 右键:动作菜单(打开 Harness / 移到当前屏幕 / 隐藏桌面宠物)。
42
43
  - 卡片不会抢焦点:鼠标移开卡片和宠物一会儿就自动收起,再点宠物也能收起。
package/client.js CHANGED
@@ -37,15 +37,27 @@ window.__ModuleLoader__.load({
37
37
  * @returns true for a light surface, false for dark, null when unknowable.
38
38
  */
39
39
  function surfaceIsLight() {
40
- try {
41
- const background = getComputedStyle(document.body).backgroundColor;
42
- const match = /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/.exec(background);
40
+ const read = (element) => {
41
+ if (element === null || element === undefined) return null;
42
+ const color = getComputedStyle(element).backgroundColor;
43
+ const match = /rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/.exec(color);
43
44
  if (match === null) return null;
44
45
  const alpha = match[4] === undefined ? 1 : Number(match[4]);
45
- // A transparent body says nothing about the surface underneath.
46
+ // A transparent element says nothing about the surface underneath.
46
47
  if (alpha < 0.2) return null;
47
48
  const luminance = (0.2126 * Number(match[1]) + 0.7152 * Number(match[2]) + 0.0722 * Number(match[3])) / 255;
48
49
  return luminance > 0.55;
50
+ };
51
+ try {
52
+ for (const element of [document.body, document.documentElement]) {
53
+ const light = read(element);
54
+ if (light !== null) return light;
55
+ }
56
+ // Last resort: the app follows the system unless the user overrode it,
57
+ // and a wrong answer is worse than the system's own opinion.
58
+ return typeof window.matchMedia === 'function'
59
+ ? !window.matchMedia('(prefers-color-scheme: dark)').matches
60
+ : null;
49
61
  } catch {
50
62
  return null;
51
63
  }
@@ -100,6 +112,8 @@ window.__ModuleLoader__.load({
100
112
  'list.step': '第 {step} 步',
101
113
  'list.goal': '目标:{objective}',
102
114
  'list.jump': '打开对话',
115
+ 'list.ask': '等你回答',
116
+ 'list.behind': 'N 个待查看',
103
117
  'list.more': '还有 {count} 个会话',
104
118
  'list.less': '收起',
105
119
  'empty.title': '暂无任务',
@@ -134,7 +148,8 @@ window.__ModuleLoader__.load({
134
148
  'list.current': 'Current session',
135
149
  'list.step': 'Step {step}',
136
150
  'list.goal': 'Goal: {objective}',
137
- 'list.jump': 'Open conversation',
151
+ 'list.ask': 'Waiting for your answer',
152
+ 'list.behind': '{count} need review',
138
153
  'list.more': '{count} more sessions',
139
154
  'list.less': 'Show less',
140
155
  'empty.title': 'No tasks yet',
@@ -169,7 +184,8 @@ window.__ModuleLoader__.load({
169
184
  'list.current': '現在の会話',
170
185
  'list.step': 'ステップ {step}',
171
186
  'list.goal': '目標:{objective}',
172
- 'list.jump': '会話を開く',
187
+ 'list.ask': '回答待ち',
188
+ 'list.behind': '未確認 {count} 件',
173
189
  'list.more': '他 {count} 件',
174
190
  'list.less': '折りたたむ',
175
191
  'empty.title': 'タスクはまだありません',
@@ -204,7 +220,8 @@ window.__ModuleLoader__.load({
204
220
  'list.current': 'Conversación actual',
205
221
  'list.step': 'Paso {step}',
206
222
  'list.goal': 'Objetivo: {objective}',
207
- 'list.jump': 'Abrir conversación',
223
+ 'list.ask': 'Esperando tu respuesta',
224
+ 'list.behind': '{count} por revisar',
208
225
  'list.more': '{count} conversaciones más',
209
226
  'list.less': 'Mostrar menos',
210
227
  'empty.title': 'Aún no hay tareas',
@@ -239,7 +256,8 @@ window.__ModuleLoader__.load({
239
256
  'list.current': 'Conversation actuelle',
240
257
  'list.step': 'Étape {step}',
241
258
  'list.goal': 'Objectif : {objective}',
242
- 'list.jump': 'Ouvrir la conversation',
259
+ 'list.ask': 'En attente de votre réponse',
260
+ 'list.behind': '{count} à vérifier',
243
261
  'list.more': '{count} autres conversations',
244
262
  'list.less': 'Afficher moins',
245
263
  'empty.title': 'Aucune tâche pour le moment',
@@ -274,7 +292,8 @@ window.__ModuleLoader__.load({
274
292
  'list.current': 'Aktuelle Unterhaltung',
275
293
  'list.step': 'Schritt {step}',
276
294
  'list.goal': 'Ziel: {objective}',
277
- 'list.jump': 'Unterhaltung öffnen',
295
+ 'list.ask': 'Wartet auf deine Antwort',
296
+ 'list.behind': '{count} zu prüfen',
278
297
  'list.more': '{count} weitere Unterhaltungen',
279
298
  'list.less': 'Weniger anzeigen',
280
299
  'empty.title': 'Noch keine Aufgaben',
@@ -309,7 +328,8 @@ window.__ModuleLoader__.load({
309
328
  'list.current': 'Текущий диалог',
310
329
  'list.step': 'Шаг {step}',
311
330
  'list.goal': 'Цель: {objective}',
312
- 'list.jump': 'Открыть диалог',
331
+ 'list.ask': 'Ждёт вашего ответа',
332
+ 'list.behind': '{count} требуют внимания',
313
333
  'list.more': 'Ещё диалогов: {count}',
314
334
  'list.less': 'Свернуть',
315
335
  'empty.title': 'Задач пока нет',
@@ -344,7 +364,8 @@ window.__ModuleLoader__.load({
344
364
  'list.current': 'Conversa atual',
345
365
  'list.step': 'Passo {step}',
346
366
  'list.goal': 'Meta: {objective}',
347
- 'list.jump': 'Abrir conversa',
367
+ 'list.ask': 'Aguardando sua resposta',
368
+ 'list.behind': '{count} para revisar',
348
369
  'list.more': 'Mais {count} conversas',
349
370
  'list.less': 'Mostrar menos',
350
371
  'empty.title': 'Nenhuma tarefa ainda',
@@ -548,7 +569,6 @@ window.__ModuleLoader__.load({
548
569
  }
549
570
 
550
571
  /** Display priority of one kind; the roster lists the most urgent first. */
551
- const KIND_ORDER = { running: 0, attention: 1, progress: 2, failed: 3, finished: 4, idle: 5 };
552
572
 
553
573
  /**
554
574
  * Format an elapsed duration for the roster.
@@ -880,7 +900,12 @@ window.__ModuleLoader__.load({
880
900
  const pet = row.pet;
881
901
  const todos = pet === null || pet === undefined ? null : pet.todos;
882
902
  const goal = pet === null || pet === undefined ? null : pet.goal;
883
- if (kind === 'attention') return t('list.attention');
903
+ if (kind === 'attention') {
904
+ // Distinguish a question from an unread completion: both are attention,
905
+ // but only one of them is blocked on the user.
906
+ const pending = status?.pendingInteraction;
907
+ return pending !== undefined && pending !== null ? t('list.ask') : t('list.attention');
908
+ }
884
909
  if (kind === 'running') {
885
910
  const parts = [];
886
911
  if (pet !== null && pet !== undefined && pet.startedAt !== null) parts.push(elapsedLabel(now - pet.startedAt));
@@ -1043,12 +1068,15 @@ window.__ModuleLoader__.load({
1043
1068
  };
1044
1069
  }, [open]);
1045
1070
 
1046
- // Newest first. A freshly opened conversation used to sink to the bottom
1047
- // of the kind buckets, which is the one place the user is most likely to
1048
- // look — the badge and the dots still carry urgency.
1071
+ // Action first, then recency. Pure recency buried both the sessions that
1072
+ // need an answer and the one that is running under a pile of finished
1073
+ // ones — the card then showed a count nobody could locate.
1049
1074
  const ranked = rows
1050
1075
  .map((row) => ({ row, kind: rowKind(row, statuses.get(row.id)) }))
1051
- .sort((a, b) => (b.row.updatedAt - a.row.updatedAt) || (KIND_ORDER[a.kind] - KIND_ORDER[b.kind]));
1076
+ .sort((a, b) => {
1077
+ const weight = (kind) => (kind === 'attention' ? 0 : kind === 'running' ? 1 : 2);
1078
+ return (weight(a.kind) - weight(b.kind)) || (b.row.updatedAt - a.row.updatedAt);
1079
+ });
1052
1080
  const running = ranked.filter((entry) => entry.kind === 'running').length;
1053
1081
  const attention = ranked.filter((entry) => entry.kind === 'attention').length;
1054
1082
  const failed = ranked.filter((entry) => entry.kind === 'failed').length;
@@ -229,6 +229,9 @@ final class PetView: NSView {
229
229
  // bobs, and it never competes with the count badge in the top-right corner.
230
230
  drawProgressMeter(ctx)
231
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) }
232
235
  }
233
236
 
234
237
  /// A slim meter under the pet showing how much of the target Session's plan is
@@ -445,6 +448,18 @@ final class PetView: NSView {
445
448
  }
446
449
  }
447
450
 
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))
461
+ }
462
+
448
463
  private func drawBadge(_ ctx: CGContext, text: String) {
449
464
  let width: CGFloat = text.count > 1 ? 24 : 20
450
465
  let rect = CGRect(x: bounds.width - width - 2, y: bounds.height - 22, width: width, height: 20)
@@ -704,12 +719,35 @@ final class RosterFooterView: NSView {
704
719
  .font: NSFont.systemFont(ofSize: 11),
705
720
  .foregroundColor: NSColor.secondaryLabelColor,
706
721
  ]
722
+ effectiveAppearance.performAsCurrentDrawingAppearance {
723
+ // draw below uses the attributes above
724
+ }
707
725
  let size = (label as NSString).size(withAttributes: attrs)
708
726
  let point = NSPoint(x: (bounds.width - size.width) / 2, y: (bounds.height - size.height) / 2)
709
727
  (label as NSString).draw(at: point, withAttributes: attrs)
710
728
  }
711
729
  }
712
730
 
731
+ /// A card surface with an opaque fill chosen from the resolved appearance, so
732
+ /// the card looks the same over any desktop behind it.
733
+ final class CardView: NSView {
734
+ override var isOpaque: Bool { false }
735
+
736
+ override func draw(_ dirtyRect: NSRect) {
737
+ let dark = effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua
738
+ let fill = dark
739
+ ? NSColor(srgbRed: 0.145, green: 0.149, blue: 0.165, alpha: 0.985)
740
+ : NSColor(srgbRed: 0.992, green: 0.994, blue: 0.996, alpha: 0.985)
741
+ fill.setFill()
742
+ NSBezierPath(roundedRect: bounds, xRadius: 16, yRadius: 16).fill()
743
+ // A hairline keeps the edge visible when the card sits on a similar shade.
744
+ (dark ? NSColor.white.withAlphaComponent(0.10) : NSColor.black.withAlphaComponent(0.10)).setStroke()
745
+ let edge = NSBezierPath(roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5), xRadius: 16, yRadius: 16)
746
+ edge.lineWidth = 1
747
+ edge.stroke()
748
+ }
749
+ }
750
+
713
751
  final class RosterPanel: NSPanel {
714
752
  /// Like the pet itself, the card never becomes key: the pet receives clicks
715
753
  /// reliably precisely because it never takes focus, and the card must behave
@@ -722,7 +760,7 @@ final class RosterPanel: NSPanel {
722
760
  /// Owns the roster panel: layout, scrolling, hover, click, dismissal.
723
761
  final class RosterController: NSObject {
724
762
  private let panel: RosterPanel
725
- private let card = NSVisualEffectView()
763
+ private let card = CardView()
726
764
  private let scroll = NSScrollView()
727
765
  private let document = FlippedView()
728
766
  private let head = NSView()
@@ -763,9 +801,6 @@ final class RosterController: NSObject {
763
801
  panel.isReleasedWhenClosed = false
764
802
  panel.collectionBehavior = [.canJoinAllSpaces, .stationary, .fullScreenAuxiliary]
765
803
 
766
- card.material = .popover
767
- card.blendingMode = .behindWindow
768
- card.state = .active
769
804
  card.wantsLayer = true
770
805
  card.layer?.cornerRadius = 16
771
806
  card.layer?.masksToBounds = true
@@ -904,19 +939,26 @@ final class RosterController: NSObject {
904
939
  height: max(40, height - headHeight - Self.padding * 1.5))
905
940
 
906
941
  document.frame = NSRect(x: 0, y: 0, width: Self.width - Self.padding * 2 - 2, height: listHeight)
907
- var cursor = listHeight - Self.padding
942
+ var cursor = CGFloat(2)
908
943
  for row in rows {
909
- cursor -= row.frame.height
910
944
  row.frame.origin = NSPoint(x: 0, y: cursor)
911
945
  document.addSubview(row)
946
+ cursor += row.frame.height
912
947
  }
913
948
  if let footer {
914
- cursor -= footer.frame.height
915
949
  footer.frame.origin = NSPoint(x: 0, y: cursor)
916
950
  document.addSubview(footer)
917
951
  }
918
952
  scroll.documentView?.scroll(NSPoint(x: 0, y: 0))
919
953
 
954
+ // Colours resolve against the effective appearance; anything created before
955
+ // it settled must repaint or it stays invisible.
956
+ for piece in rows + [document, scroll] {
957
+ piece.needsDisplay = true
958
+ }
959
+ footer?.needsDisplay = true
960
+ head.needsDisplay = true
961
+
920
962
  panel.orderFrontRegardless()
921
963
  startHoverWatch(petFrame: petFrame)
922
964
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-task-cat",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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": {