dsh-task-cat 1.0.3 → 1.0.5

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,10 +34,10 @@ Harness 的桌面外壳并没有向插件开放窗口 API(preload 只暴露文
34
34
 
35
35
  行为细节:
36
36
 
37
- - 点一下桌面宠物 → 在**宠物正上方**弹出会话卡片,再点一下关闭(空间不够时自动翻到下方,并始终留在屏幕内)。卡片的层级和窗口内那份面板一致:标题「任务宠物」+ 一句话汇总 + 一句说明,下面依次是会话,每行是「状态点 + 标题 + 状态行 + 进度条」,当前打开的那一行用一张圆角卡片标出来,并带「· 当前会话」。状态点按类型上色(进行中=蓝色实心带呼吸光晕、待查看=琥珀、失败=红、已完成=绿、推进中但没在跑=薄荷空心、空闲=灰空心),状态行和窗口内那只宠物用的是同一句话(例如 `4m · 2/5 · bash`、`待查看`、`上次运行失败`),有 todo 的行下面还有一条进度条。清单**先排需要你的**(待查看 → 进行中 → 其余按最近更新),所以「N 个待查看」里的那几个永远在最上面;待查看一行会写清是「待查看」还是「等你回答」。默认显示 **5 个**,更多的收在底部「还有 N 个会话…」里,点一下展开全部、再点收起。点其中一行跳到那个对话,并把 Harness 窗口带到前台。卡片跟随应用的浅色/深色主题(页面把当前明暗传给助手),不会出现深色卡片压在白底应用上。
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
  - 卡片不会抢焦点:鼠标移开卡片和宠物一会儿就自动收起,再点宠物也能收起。
@@ -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
 
@@ -489,13 +497,19 @@ final class PetView: NSView {
489
497
  /// handling and outside-click closing while allowing real content.
490
498
  final class RosterRowView: NSView {
491
499
  static let width: CGFloat = 320
492
- static let rowHeight: CGFloat = 42
493
- static let progressRowHeight: CGFloat = 52
500
+ static let rowHeight: CGFloat = 46
494
501
 
495
502
  private let entry: SessionEntry
496
503
  /// Fired on click. A menu item's action was not enough: a view-based item
497
504
  /// swallows the mouse, so rows opened nothing at all.
498
505
  var onPick: (() -> Void)?
506
+ /// Whether this row earns a progress bar: only work in flight says something
507
+ /// a bar can express.
508
+ private var showsBar: Bool {
509
+ guard entry.ratio != nil else { return false }
510
+ return entry.kind == "running" || entry.kind == "progress"
511
+ }
512
+
499
513
  private var pressed = false
500
514
  private var hovered = false {
501
515
  didSet { if hovered != oldValue { needsDisplay = true } }
@@ -504,8 +518,7 @@ final class RosterRowView: NSView {
504
518
 
505
519
  init(entry: SessionEntry, width: CGFloat = RosterRowView.width) {
506
520
  self.entry = entry
507
- let height = entry.ratio == nil ? Self.rowHeight : Self.progressRowHeight
508
- super.init(frame: NSRect(x: 0, y: 0, width: width, height: height))
521
+ super.init(frame: NSRect(x: 0, y: 0, width: width, height: Self.rowHeight))
509
522
  autoresizingMask = [.width]
510
523
  }
511
524
 
@@ -645,8 +658,8 @@ final class RosterRowView: NSView {
645
658
  withAttributes: metaAttrs)
646
659
  }
647
660
 
648
- if let ratio = entry.ratio {
649
- let track = NSRect(x: textX, y: 5, width: textWidth, height: 3)
661
+ if let ratio = entry.ratio, showsBar {
662
+ let track = NSRect(x: textX, y: 4, width: textWidth, height: 3)
650
663
  let trackPath = NSBezierPath(roundedRect: track, xRadius: 1.5, yRadius: 1.5)
651
664
  (highlighted ? NSColor.selectedMenuItemTextColor.withAlphaComponent(0.28)
652
665
  : NSColor.quaternaryLabelColor).setFill()
@@ -1340,6 +1353,7 @@ final class PetWindowController: NSObject {
1340
1353
  if let mood = message.mood { view.mood = mood }
1341
1354
  if let badge = message.badge { view.badge = badge }
1342
1355
  if let attention = message.attention { view.attention = attention }
1356
+ if let running = message.running { view.running = running }
1343
1357
  if let light = message.light { usesLightSurface = light }
1344
1358
  if let summary = message.summary { summaryText = summary }
1345
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.3",
3
+ "version": "1.0.5",
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": {