dsh-task-cat 1.0.5 → 1.0.7
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 +8 -0
- package/client.js +188 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,14 @@ 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
|
+
|
|
65
|
+
标记的写入是幂等的、并按帧合并:观察器只在一帧里重画一次,值没变就不写 DOM。否则「写入 → 观察器 → 再写入」会自我触发成死循环,把主线程占满——表现就是点侧栏时整个应用卡住。
|
|
66
|
+
|
|
59
67
|
## 交互
|
|
60
68
|
|
|
61
69
|
- **点宠物**:展开/收起任务清单,按紧急程度排序:进行中 → 待查看 → 有进度 → 失败 → 已完成 → 空闲。
|
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,163 @@ 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
|
+
const text = String(count);
|
|
973
|
+
if (existing.textContent !== text) existing.textContent = text;
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
const badge = document.createElement('span');
|
|
977
|
+
badge.setAttribute('data-dsh-task-cat', 'workspace');
|
|
978
|
+
badge.className = 'dsh-task-cat-wsmark';
|
|
979
|
+
badge.textContent = String(count);
|
|
980
|
+
badge.title = t('ws.running', { count });
|
|
981
|
+
// Land it after the title block but before the row's actions: the row
|
|
982
|
+
// is a flex line whose last child is that action cluster. Appending to
|
|
983
|
+
// the row would put the badge to the right of hidden hover buttons.
|
|
984
|
+
const tail = row.lastElementChild;
|
|
985
|
+
if (tail !== null && tail !== row.firstElementChild) row.insertBefore(badge, tail);
|
|
986
|
+
else row.appendChild(badge);
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
// Painting writes badges into rows the sidebar owns, and those writes are
|
|
990
|
+
// themselves mutations. Feeding them straight back into `paintAll` is an
|
|
991
|
+
// endless loop on the main thread — the collapse button appeared to hang
|
|
992
|
+
// the whole app. Three rules keep it terminating: paint while flagged,
|
|
993
|
+
// coalesce callbacks into one frame, and write only on a real change.
|
|
994
|
+
let painting = false;
|
|
995
|
+
let frame = 0;
|
|
996
|
+
|
|
997
|
+
const paintAll = () => {
|
|
998
|
+
if (painting) return;
|
|
999
|
+
painting = true;
|
|
1000
|
+
try {
|
|
1001
|
+
for (const row of document.querySelectorAll('[data-row-key^="workspace:"]')) paint(row);
|
|
1002
|
+
} finally {
|
|
1003
|
+
painting = false;
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
const schedule = () => {
|
|
1008
|
+
if (painting || frame !== 0) return;
|
|
1009
|
+
const run = () => {
|
|
1010
|
+
frame = 0;
|
|
1011
|
+
paintAll();
|
|
1012
|
+
};
|
|
1013
|
+
frame = typeof requestAnimationFrame === 'function'
|
|
1014
|
+
? requestAnimationFrame(run)
|
|
1015
|
+
: setTimeout(run, 32);
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
paintAll();
|
|
1019
|
+
// Watch the list area when the sidebar exposes it; body only as a
|
|
1020
|
+
// fallback, so unrelated app activity cannot wake this up.
|
|
1021
|
+
const scope = document.querySelector('[data-sidebar-list-area]') ?? document.body;
|
|
1022
|
+
const observer = new MutationObserver(schedule);
|
|
1023
|
+
observer.observe(scope, {
|
|
1024
|
+
childList: true,
|
|
1025
|
+
subtree: true,
|
|
1026
|
+
attributes: true,
|
|
1027
|
+
attributeFilter: ['aria-expanded', 'data-row-key']
|
|
1028
|
+
});
|
|
1029
|
+
return () => {
|
|
1030
|
+
observer.disconnect();
|
|
1031
|
+
if (frame !== 0 && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame);
|
|
1032
|
+
for (const badge of document.querySelectorAll('[data-dsh-task-cat="workspace"]')) badge.remove();
|
|
1033
|
+
};
|
|
1034
|
+
}, [running, groups]);
|
|
1035
|
+
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Whether two id lists are the same set, so the overlay does not repaint on
|
|
1041
|
+
* every Session tick.
|
|
1042
|
+
* @param left - previous ids.
|
|
1043
|
+
* @param right - next ids.
|
|
1044
|
+
* @returns true when nothing changed.
|
|
1045
|
+
*/
|
|
1046
|
+
function sameIds(left, right) {
|
|
1047
|
+
if (left.length !== right.length) return false;
|
|
1048
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
1049
|
+
if (left[index] !== right[index]) return false;
|
|
1050
|
+
}
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Whether two workspace groups describe the same membership.
|
|
1056
|
+
* @param left - previous groups.
|
|
1057
|
+
* @param right - next groups.
|
|
1058
|
+
* @returns true when nothing changed.
|
|
1059
|
+
*/
|
|
1060
|
+
function sameGroups(left, right) {
|
|
1061
|
+
if (left.length !== right.length) return false;
|
|
1062
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
1063
|
+
if (left[index].id !== right[index].id) return false;
|
|
1064
|
+
if (!sameIds(left[index].sessions, right[index].sessions)) return false;
|
|
1065
|
+
}
|
|
1066
|
+
return true;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
888
1069
|
/**
|
|
889
1070
|
* The one-line status for a Session: elapsed time, todo progress, the tool
|
|
890
1071
|
* it is on, or why it is worth a look. Shared with the desktop pet so both
|
|
@@ -1508,6 +1689,13 @@ window.__ModuleLoader__.load({
|
|
|
1508
1689
|
openSession: (sessionId) => { ctx.uiWorkspace.openSession(sessionId); }
|
|
1509
1690
|
})
|
|
1510
1691
|
}, TaskPet));
|
|
1692
|
+
// Second entry, drawing nothing: it only marks collapsed workspace rows.
|
|
1693
|
+
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
1694
|
+
name: 'shell.overlay',
|
|
1695
|
+
id: `${NS}-workspaces`,
|
|
1696
|
+
order: 21,
|
|
1697
|
+
locale: NS
|
|
1698
|
+
}, WorkspaceMarkers));
|
|
1511
1699
|
}
|
|
1512
1700
|
};
|
|
1513
1701
|
}
|
package/package.json
CHANGED