@suifei/dsh-ai-team 0.4.111 → 0.4.112

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/client.js +75 -42
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.112 - 2026-11-16
4
+
5
+ **任务记录同样打开即在最新回帖(#33 后续)**
6
+
7
+ - 实机:0.4.108 起主对话已贴底,右侧任务记录(Thread 面板)打开仍停在顶部的完成信息,最新回帖要手动拖到底;
8
+ - 跟随接线抽成 `useFollowLatest`(主对话与任务记录共用一份,内部仍是 `createStreamFollower`),任务记录按
9
+ 任务切换重置贴底,新回帖或状态变化时按是否停在底部决定跟随,上翻时底部浮出「↓ N 条新消息」;
10
+ 内容变高改为观察滚动容器的每个直接子块(任务记录不是单一内层容器);
11
+ - 测试:`test/client-stream-follow.test.js` 新增接线契约 1 例,`test/client.render.test.js` 增加「打开任务后 Thread
12
+ 面板渲染且带跟随接线」(换回旧 client.js 两处即失败);
13
+
3
14
  ## 0.4.111 - 2026-11-16
4
15
 
5
16
  **SkillOpt 一次性子代理不再逐个唤醒 PMO**
package/client.js CHANGED
@@ -2250,6 +2250,13 @@ window.__ModuleLoader__.load({
2250
2250
  const headSeq = thread?.headSeq ?? thread?.entries?.length ?? 0;
2251
2251
  const stale = replyBase !== null && replyBase !== undefined && headSeq > replyBase;
2252
2252
  const entries = Array.isArray(thread?.entries) ? thread.entries : [];
2253
+ // #33 任务记录同样打开即在最新回帖:换任务重置,新回帖到达时按是否停在底部决定跟随。
2254
+ const threadFollow = useFollowLatest({
2255
+ key: task.id,
2256
+ shown: !converting,
2257
+ count: entries.length,
2258
+ tail: entries.length > 0 ? String(entries[entries.length - 1]?.seq ?? '') + '|' + task.status : task.status,
2259
+ });
2253
2260
  return h('aside', { className: 'at-right', role: 'complementary', 'aria-label': t('threadAria'), tabIndex: -1, ref: panelRef },
2254
2261
  h('div', { className: 'at-rhead' },
2255
2262
  h('div', { className: 'at-rh' },
@@ -2264,7 +2271,7 @@ window.__ModuleLoader__.load({
2264
2271
  h('button', { className: 'at-noteclose', type: 'button', 'aria-label': t('dismiss'), title: t('dismiss'), onClick: onDismissNote }, h(Ico, { name: 'close', size: 12 }))) : null,
2265
2272
  converting
2266
2273
  ? h(ConvertForm, { t, project, task, thread, title: convert.title, dod: convert.dod, onTitle: convert.onTitle, onDod: convert.onDod, onCancel: convert.onCancel, onSubmit: convert.onSubmit })
2267
- : h('div', { className: 'at-rbody' },
2274
+ : h('div', { className: 'at-rbody', ref: threadFollow.ref, onScroll: threadFollow.onScroll },
2268
2275
  stale ? h(ConflictBanner, { t, thread, baseSeq: replyBase, headSeq, onContinue }) : null,
2269
2276
  task.status === 'done' ? h(DoneSummary, { t, task }) : h(TaskDetail, { t, task }),
2270
2277
  entries.length
@@ -2311,6 +2318,7 @@ window.__ModuleLoader__.load({
2311
2318
  h('span', { className: 'at-peopleprojectname' }, '#' + event.seq),
2312
2319
  h('span', { className: 'at-peoplestate' }, event.type),
2313
2320
  h('span', { className: 'at-peopletasks' }, fmtTime(event.at) + actorSuffix(event.actor)))))) : null,
2321
+ !converting ? h(JumpToLatest, { t, unseen: threadFollow.unseen, onJump: threadFollow.jump }) : null,
2314
2322
  !converting ? h('div', { className: 'at-rfoot' },
2315
2323
  h('div', { className: 'at-box at-rbox' },
2316
2324
  h('textarea', {
@@ -2666,6 +2674,60 @@ window.__ModuleLoader__.load({
2666
2674
  }
2667
2675
  // </stream-follow>
2668
2676
 
2677
+ /**
2678
+ * 滚动容器「跟随最新」的 React 接线(主对话、任务记录共用这一份)。
2679
+ * key 变化即重置并贴底(切项目/标签/任务);
2680
+ * shown 容器在场时才量尺寸;
2681
+ * count/tail 条目数与最后一条的标识,变化即按 follower 判定贴底或累计未读。
2682
+ * 只用 useLayoutEffect:尺寸读写要在绘制前完成,避免先闪到顶部再跳到底。
2683
+ */
2684
+ function useFollowLatest({ key, shown, count, tail }) {
2685
+ const ref = React.useRef(null);
2686
+ const followerRef = React.useRef(null);
2687
+ if (followerRef.current === null) followerRef.current = createStreamFollower();
2688
+ const [unseen, setUnseen] = React.useState(0);
2689
+ React.useLayoutEffect(() => {
2690
+ followerRef.current.reset();
2691
+ setUnseen(0);
2692
+ }, [key]);
2693
+ React.useLayoutEffect(() => {
2694
+ const el = ref.current;
2695
+ if (!shown || el === null || el === undefined) return;
2696
+ const step = followerRef.current.onContent(el, count);
2697
+ if (step.scrollTo !== null) el.scrollTop = step.scrollTo;
2698
+ setUnseen(step.unseen);
2699
+ }, [key, shown, count, tail]);
2700
+ React.useLayoutEffect(() => {
2701
+ const el = ref.current;
2702
+ if (!shown || el === null || el === undefined || typeof ResizeObserver !== 'function') return undefined;
2703
+ // 观察每个直接子块:容器自身高度固定,内容变高(卡片展开、字体晚到)只体现在子块上。
2704
+ const observer = new ResizeObserver(() => {
2705
+ const to = followerRef.current.onResize(el);
2706
+ if (to !== null) el.scrollTop = to;
2707
+ });
2708
+ for (const child of Array.from(el.children ?? [])) observer.observe(child);
2709
+ return () => observer.disconnect();
2710
+ }, [key, shown, count]);
2711
+ return {
2712
+ ref,
2713
+ unseen,
2714
+ onScroll: (event) => setUnseen(followerRef.current.onScroll(event.currentTarget)),
2715
+ jump: () => {
2716
+ const el = ref.current;
2717
+ if (el !== null && el !== undefined) el.scrollTop = followerRef.current.jump(el);
2718
+ setUnseen(0);
2719
+ },
2720
+ };
2721
+ }
2722
+
2723
+ /** 「↓ N 条新消息」:零高度锚点 + 绝对定位按钮,不进文档流,不改变任何滚动位置。 */
2724
+ function JumpToLatest({ t, unseen, onJump }) {
2725
+ if (!(unseen > 0)) return null;
2726
+ return h('div', { className: 'at-streamjumpanchor' },
2727
+ h('button', { className: 'at-streamjump', type: 'button', onClick: onJump },
2728
+ h(Ico, { name: 'down', size: 12 }), tf(t, 'streamUnseen', { count: unseen })));
2729
+ }
2730
+
2669
2731
  function Workbench({ t, ctx }) {
2670
2732
  const [phase, setPhase] = React.useState('loading');
2671
2733
  const [data, setData] = React.useState(null);
@@ -2820,42 +2882,18 @@ window.__ModuleLoader__.load({
2820
2882
  const replyRef = React.useRef(null);
2821
2883
  const triggerRef = React.useRef(null);
2822
2884
  const mobileRef = React.useRef(null);
2823
- // #33 主对话跟随最新(算法见 createStreamFollower)。
2824
- const streamRef = React.useRef(null);
2825
- const followerRef = React.useRef(null);
2826
- if (followerRef.current === null) followerRef.current = createStreamFollower();
2827
- const [streamUnseen, setStreamUnseen] = React.useState(0);
2885
+ // #33 主对话跟随最新(useFollowLatest / createStreamFollower)。
2828
2886
  const streamItems = Array.isArray(data?.stream) ? data.stream : [];
2829
- const streamTail = streamItems.length > 0 ? streamItems[streamItems.length - 1]?.id ?? '' : '';
2830
- const streamShown = scope === 'project' && tab === 'main';
2831
- React.useLayoutEffect(() => {
2832
- followerRef.current.reset();
2833
- setStreamUnseen(0);
2834
- }, [projectId, scope, tab]);
2835
- React.useLayoutEffect(() => {
2836
- const el = streamRef.current;
2837
- if (!streamShown || el === null || el === undefined) return;
2838
- const step = followerRef.current.onContent(el, streamItems.length);
2839
- if (step.scrollTo !== null) el.scrollTop = step.scrollTo;
2840
- setStreamUnseen(step.unseen);
2841
- }, [projectId, streamShown, streamItems.length, streamTail]);
2842
- React.useLayoutEffect(() => {
2843
- const el = streamRef.current;
2844
- const inner = el?.firstElementChild;
2845
- if (!streamShown || inner === null || inner === undefined || typeof ResizeObserver !== 'function') return undefined;
2846
- const observer = new ResizeObserver(() => {
2847
- const to = followerRef.current.onResize(el);
2848
- if (to !== null) el.scrollTop = to;
2849
- });
2850
- observer.observe(inner);
2851
- return () => observer.disconnect();
2852
- }, [projectId, streamShown, data !== null]);
2853
- const onStreamScroll = (event) => setStreamUnseen(followerRef.current.onScroll(event.currentTarget));
2854
- const jumpToLatest = () => {
2855
- const el = streamRef.current;
2856
- if (el !== null && el !== undefined) el.scrollTop = followerRef.current.jump(el);
2857
- setStreamUnseen(0);
2858
- };
2887
+ const mainFollow = useFollowLatest({
2888
+ key: projectId + '|' + scope + '|' + tab,
2889
+ shown: scope === 'project' && tab === 'main' && data !== null,
2890
+ count: streamItems.length,
2891
+ tail: streamItems.length > 0 ? streamItems[streamItems.length - 1]?.id ?? '' : '',
2892
+ });
2893
+ const streamRef = mainFollow.ref;
2894
+ const streamUnseen = mainFollow.unseen;
2895
+ const onStreamScroll = mainFollow.onScroll;
2896
+ const jumpToLatest = mainFollow.jump;
2859
2897
  // R-08 快捷键:composer 聚焦句柄 + `?` 帮助浮层开关。
2860
2898
  const composerInputRef = React.useRef(null);
2861
2899
  const [shortcutsOpen, setShortcutsOpen] = React.useState(false);
@@ -4314,12 +4352,7 @@ window.__ModuleLoader__.load({
4314
4352
  onSetWorkspace: openWorkspaceEditor,
4315
4353
  onExample: () => setDraft(t('emptyStreamExample')),
4316
4354
  }))),
4317
- // 零高度锚点 + 绝对定位按钮:不进文档流,不改变任何滚动位置。
4318
- streamUnseen > 0
4319
- ? h('div', { className: 'at-streamjumpanchor' },
4320
- h('button', { className: 'at-streamjump', type: 'button', onClick: jumpToLatest },
4321
- h(Ico, { name: 'down', size: 12 }), tf(t, 'streamUnseen', { count: streamUnseen })))
4322
- : null);
4355
+ h(JumpToLatest, { t, unseen: streamUnseen, onJump: jumpToLatest }));
4323
4356
 
4324
4357
  return h('div', { className: 'at-root', role: 'region', 'aria-label': t('panel') },
4325
4358
  h('div', { className: 'at-top' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.111",
3
+ "version": "0.4.112",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",