dsh-task-cat 1.0.6 → 1.0.8
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 +3 -1
- package/client.js +72 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,10 +58,12 @@ Harness 的桌面外壳并没有向插件开放窗口 API(preload 只暴露文
|
|
|
58
58
|
|
|
59
59
|
## 侧栏工作区标记
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
工作区折叠后,标题右侧会出现一个蓝色胶囊(与宠物进行中计数同色,`#4c90f2`)显示该工作区里**正在进行中**的会话数。展开时标记消失(此时每个会话行自己带状态点);数量归零也会消失。
|
|
62
62
|
|
|
63
63
|
实现上它是只读标注:侧栏工作区行由应用自己渲染、没有暴露插槽,所以插件读 `useSessions` / `useWorkspaces` 算出每个工作区的进行中数量,再往对应行(`data-row-key="workspace:<id>"`、`aria-expanded="false"`)里插入一个徽章,并用 MutationObserver 在重渲染后补回。插件不改写、不替换行内任何应用内容。
|
|
64
64
|
|
|
65
|
+
标记的写入是幂等的、并按帧合并:观察器只在一帧里重画一次,值没变就不写 DOM。否则「写入 → 观察器 → 再写入」会自我触发成死循环,把主线程占满——表现就是点侧栏时整个应用卡住。
|
|
66
|
+
|
|
65
67
|
## 交互
|
|
66
68
|
|
|
67
69
|
- **点宠物**:展开/收起任务清单,按紧急程度排序:进行中 → 待查看 → 有进度 → 失败 → 已完成 → 空闲。
|
package/client.js
CHANGED
|
@@ -22,6 +22,28 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
const React = require('react');
|
|
23
23
|
const h = React.createElement;
|
|
24
24
|
|
|
25
|
+
/** Stylesheet for the workspace marker, independent of any React render. */
|
|
26
|
+
const MARKER_CSS = `
|
|
27
|
+
.dsh-task-cat-wsmark {
|
|
28
|
+
flex: none;
|
|
29
|
+
margin-left: 6px;
|
|
30
|
+
min-width: 17px;
|
|
31
|
+
height: 17px;
|
|
32
|
+
padding: 0 5px;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
border-radius: 9px;
|
|
35
|
+
background: #4c90f2;
|
|
36
|
+
color: #fff;
|
|
37
|
+
font-size: 10.5px;
|
|
38
|
+
font-weight: 600;
|
|
39
|
+
line-height: 17px;
|
|
40
|
+
text-align: center;
|
|
41
|
+
font-variant-numeric: tabular-nums;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
25
47
|
/** Locale namespace, also used for slot ids and CSS prefixes. */
|
|
26
48
|
const NS = 'dsh-task-cat';
|
|
27
49
|
|
|
@@ -863,22 +885,6 @@ window.__ModuleLoader__.load({
|
|
|
863
885
|
}
|
|
864
886
|
.dsh-task-pet-fab:hover { color: var(--dsw-alias-label-primary); }
|
|
865
887
|
.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
|
-
}
|
|
882
888
|
@keyframes dsh-task-pet-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
|
|
883
889
|
/* The cat keeps moving between state changes: a tail on its own tempo, a slow
|
|
884
890
|
breath, and the occasional blink, all slower than the bob so they never sync. */
|
|
@@ -969,7 +975,8 @@ window.__ModuleLoader__.load({
|
|
|
969
975
|
return;
|
|
970
976
|
}
|
|
971
977
|
if (existing !== null) {
|
|
972
|
-
|
|
978
|
+
const text = String(count);
|
|
979
|
+
if (existing.textContent !== text) existing.textContent = text;
|
|
973
980
|
return;
|
|
974
981
|
}
|
|
975
982
|
const badge = document.createElement('span');
|
|
@@ -985,14 +992,49 @@ window.__ModuleLoader__.load({
|
|
|
985
992
|
else row.appendChild(badge);
|
|
986
993
|
};
|
|
987
994
|
|
|
995
|
+
// Painting writes badges into rows the sidebar owns, and those writes are
|
|
996
|
+
// themselves mutations. Feeding them straight back into `paintAll` is an
|
|
997
|
+
// endless loop on the main thread — the collapse button appeared to hang
|
|
998
|
+
// the whole app. Three rules keep it terminating: paint while flagged,
|
|
999
|
+
// coalesce callbacks into one frame, and write only on a real change.
|
|
1000
|
+
let painting = false;
|
|
1001
|
+
let frame = 0;
|
|
1002
|
+
|
|
988
1003
|
const paintAll = () => {
|
|
989
|
-
|
|
1004
|
+
if (painting) return;
|
|
1005
|
+
painting = true;
|
|
1006
|
+
try {
|
|
1007
|
+
for (const row of document.querySelectorAll('[data-row-key^="workspace:"]')) paint(row);
|
|
1008
|
+
} finally {
|
|
1009
|
+
painting = false;
|
|
1010
|
+
}
|
|
990
1011
|
};
|
|
1012
|
+
|
|
1013
|
+
const schedule = () => {
|
|
1014
|
+
if (painting || frame !== 0) return;
|
|
1015
|
+
const run = () => {
|
|
1016
|
+
frame = 0;
|
|
1017
|
+
paintAll();
|
|
1018
|
+
};
|
|
1019
|
+
frame = typeof requestAnimationFrame === 'function'
|
|
1020
|
+
? requestAnimationFrame(run)
|
|
1021
|
+
: setTimeout(run, 32);
|
|
1022
|
+
};
|
|
1023
|
+
|
|
991
1024
|
paintAll();
|
|
992
|
-
|
|
993
|
-
|
|
1025
|
+
// Watch the list area when the sidebar exposes it; body only as a
|
|
1026
|
+
// fallback, so unrelated app activity cannot wake this up.
|
|
1027
|
+
const scope = document.querySelector('[data-sidebar-list-area]') ?? document.body;
|
|
1028
|
+
const observer = new MutationObserver(schedule);
|
|
1029
|
+
observer.observe(scope, {
|
|
1030
|
+
childList: true,
|
|
1031
|
+
subtree: true,
|
|
1032
|
+
attributes: true,
|
|
1033
|
+
attributeFilter: ['aria-expanded', 'data-row-key']
|
|
1034
|
+
});
|
|
994
1035
|
return () => {
|
|
995
1036
|
observer.disconnect();
|
|
1037
|
+
if (frame !== 0 && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame);
|
|
996
1038
|
for (const badge of document.querySelectorAll('[data-dsh-task-cat="workspace"]')) badge.remove();
|
|
997
1039
|
};
|
|
998
1040
|
}, [running, groups]);
|
|
@@ -1644,6 +1686,16 @@ window.__ModuleLoader__.load({
|
|
|
1644
1686
|
}
|
|
1645
1687
|
};
|
|
1646
1688
|
ctx.effect(() => ctx.locale.register(NS, DICT), 'dsh-task-pet: dictionaries');
|
|
1689
|
+
// Workspace markers are drawn outside the pet's React tree, so their CSS
|
|
1690
|
+
// cannot ride on that component: it returns null whenever the desktop pet
|
|
1691
|
+
// is showing, which left the badge as a bare digit.
|
|
1692
|
+
ctx.effect(() => {
|
|
1693
|
+
const style = document.createElement('style');
|
|
1694
|
+
style.setAttribute('data-dsh-task-cat', 'markers');
|
|
1695
|
+
style.textContent = MARKER_CSS;
|
|
1696
|
+
document.head.appendChild(style);
|
|
1697
|
+
return () => { style.remove(); };
|
|
1698
|
+
}, 'dsh-task-pet: workspace marker styles');
|
|
1647
1699
|
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
1648
1700
|
name: 'shell.overlay',
|
|
1649
1701
|
id: NS,
|
package/package.json
CHANGED