@yolk_vat-y/dsh-project-memory 0.7.1 → 0.7.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/CHANGELOG.md +19 -0
- package/LICENSE +0 -0
- package/README.md +9 -9
- package/README.zh-CN.md +8 -8
- package/client/client.js +139 -43
- package/client/client.js.map +1 -1
- package/cordis.patch.yml +0 -0
- package/package.json +2 -2
- package/scripts/bench-edits.mjs +0 -0
- package/scripts/bench-store.mjs +0 -0
- package/skills/project-memory/SKILL.md +38 -10
- package/src/audit.js +2 -2
- package/src/auto-inject.js +10 -5
- package/src/client/MemoryView.tsx +5 -14
- package/src/client/TaskComponents.tsx +109 -99
- package/src/client/TaskPanel.module.css +10 -4
- package/src/client/TaskPanel.tsx +49 -2
- package/src/client/locales.ts +2 -0
- package/src/client/task-data-store.ts +2 -0
- package/src/client/task-window.js +33 -0
- package/src/commands/insight-actions.js +43 -41
- package/src/commands/task-actions.js +42 -21
- package/src/commands/tasks.js +24 -10
- package/src/index-pipeline.js +5 -3
- package/src/inject-visible.js +16 -18
- package/src/insight-store.js +90 -72
- package/src/readiness.js +2 -2
- package/src/setup/taskbridge.js +51 -5
- package/src/setup/team-task.js +220 -0
- package/src/store.js +105 -82
- package/src/symbols.js +0 -0
- package/src/tools/forget.js +9 -1
- package/src/tools/index-doc.js +37 -41
- package/src/tools/lesson-tools.js +119 -22
- package/src/tools/query-memory.js +115 -14
- package/src/tools/task-tools.js +83 -16
- package/src/util/fs.js +57 -17
- package/src/util/hash.js +12 -0
- package/src/util/insight-fields.js +56 -1
- package/src/util/merge-by-id.js +56 -0
- package/src/util/persist.js +2 -1
- package/src/util/session-cache.js +4 -3
- package/src/util/task-view.js +18 -0
- package/src/vector-index.js +6 -5
- package/src/watch.js +4 -2
package/cordis.patch.yml
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolk_vat-y/dsh-project-memory",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Persistent project memory for dsh agents: index docs (PDF/Markdown/text) and code symbols into a searchable per-workspace store, recall them with cited sources, and keep experience entries (problems -> solutions) searchable on demand.",
|
|
5
5
|
"author": "00080000 <3388065969@qq.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"url": "https://github.com/00080000/dsh-project-memory.git"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-kind-label.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
|
|
23
|
+
"test": "node test/run-test.mjs && node test/taskbridge.test.mjs && node test/team-task.test.mjs && node test/insight-store.test.mjs && node test/util-value.test.mjs && node test/insight-fields.test.mjs && node test/reflection-pipeline.test.mjs && node test/auto-inject.test.mjs && node test/insight-actions.test.mjs && node test/insight-paging.test.mjs && node test/config-schema.test.mjs && node test/host-contract.test.mjs && node test/session-dir.test.mjs && node test/llm-route.test.mjs && node test/doc-index.test.mjs && node test/chunker.test.mjs && node test/client-hints.test.mjs && node test/client-paging.test.mjs && node test/client-task-sync.test.mjs && node test/client-task-window.test.mjs && node test/recall.test.mjs && node test/recall-vector-fusion.test.mjs && node test/vector-index.test.mjs && node test/readiness.test.mjs && node test/insight-derive.test.mjs && node test/readiness-eval.test.mjs && node test/ops.test.mjs && node test/injection-audit.test.mjs && node test/signal-source.test.mjs && node test/skill.test.mjs && node test/injection-budget.test.mjs && node test/injection-scenarios.test.mjs && node test/bugfix-0.5.7.test.mjs && node test/client-icons.test.mjs && node test/client-slash.test.mjs && node test/client-kind-label.test.mjs && node test/client-toolview.test.mjs && node test/workflow-command.test.mjs && node test/client-session-id.test.mjs && node test/client-degraded.test.mjs && node test/settings-card.test.mjs && node test/watch-idle.test.mjs && node test/citation-paths.test.mjs && node test/task-view.test.mjs && node test/merge-by-id.test.mjs && node test/task-order.test.mjs && node test/root-guards.test.mjs && node test/root-policy.test.mjs && node test/gitignore-index.test.mjs && node test/store-gitignore.test.mjs && node test/atomic-write.test.mjs && node test/read-json-file.test.mjs && node test/store-cache.test.mjs && node test/store-concurrent.test.mjs && node test/store-lock.test.mjs && node test/windows-compat.test.mjs && node test/tool-schema-size.test.mjs && node test/enhancer.test.mjs && node test/multilingual-ru.test.mjs && node test/tokenizer-equivalence.test.mjs && node test/lazy-batch.test.mjs && node test/pdfjs-host.test.mjs && node test/index-failures.test.mjs && node test/audit-2026-11-02.test.mjs && node test/memorydir-guard.test.mjs && node test/audit-2026-11-05.test.mjs && node test/fix-2026-11-10-shell-write-ops.test.mjs && node test/fix-2026-11-10-trigger-derived-refresh.test.mjs && node test/fix-2026-11-10-manual-promote-dedup.test.mjs && node test/fix-2026-11-10-old-host-human.test.mjs && node test/fix-2026-11-10-project-memory-service.test.mjs && node test/lazy-ignore-scope.test.mjs && node test/watch-missing-root-warn.test.mjs && node test/inject-visible.test.mjs && node test/inject-reconcile.test.mjs && node test/shard-bucket.test.mjs && node test/audit-2026-11-10.test.mjs && node test/audit-2026-11-11.test.mjs",
|
|
24
24
|
"eval:injection": "node test/injection-scenarios.test.mjs",
|
|
25
25
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
|
|
26
26
|
"selfcheck:triggers": "node test/injection-scenarios.test.mjs --selfcheck",
|
package/scripts/bench-edits.mjs
CHANGED
|
File without changes
|
package/scripts/bench-store.mjs
CHANGED
|
File without changes
|
|
@@ -22,16 +22,29 @@ Query it before re-deriving; write to it only after something has been verified.
|
|
|
22
22
|
- Before changing a subsystem: there may be a lesson about its failure modes.
|
|
23
23
|
- Before an irreversible action (commit / publish / release / push / deploy / migrate): the store may
|
|
24
24
|
know a prerequisite you would otherwise miss.
|
|
25
|
-
- When resuming: call `list_tasks`, then `select_task` if one matches the current work.
|
|
25
|
+
- When resuming: call `list_tasks`, then `select_task` if one matches the current work. In a team,
|
|
26
|
+
bind the host team task (`select_task task-<n>`) so the lead and teammates share its task-level
|
|
27
|
+
memory (the returned memory task id starts with `team:`; use that id with the other tools).
|
|
28
|
+
A team task's memory stays inside that team: another team's sessions see no such task in
|
|
29
|
+
`list_tasks` / the panel and cannot read or write it by id.
|
|
30
|
+
Binding is still what drives automatic injection (task card + task-level memories), todo sync
|
|
31
|
+
and the default task scope; for one-off access, `query_memory` / `save_lesson` also accept
|
|
32
|
+
`task_id` (local id or host `task-<n>`) to reach the same task-level memory directly.
|
|
26
33
|
|
|
27
34
|
## Workflow
|
|
28
35
|
|
|
29
36
|
1. **Locate context**
|
|
30
37
|
- `query_memory` with `query` = what you actually need ("how are shards written", "why store
|
|
31
|
-
scope", "where is X implemented").
|
|
38
|
+
scope", "where is X implemented"). Use it before grepping for orientation, a spec constraint,
|
|
39
|
+
or a past decision.
|
|
32
40
|
- `type`: `all` (default) / `doc` / `symbol` / `experience` / `insight` / `task`.
|
|
41
|
+
- `task_id` (optional): read one task's task-level memory by id — local `tsk_…` or host team
|
|
42
|
+
`task-<n>` — without binding the session. `type: 'task'` lists task records instead; do not
|
|
43
|
+
combine it with `task_id`.
|
|
44
|
+
- `limit`: per layer, default 8, max 20; `type: all` can return up to 3x (docs/symbols, insights,
|
|
45
|
+
experience).
|
|
33
46
|
- Results carry ids and citations. Treat them as evidence: read the cited file when the answer
|
|
34
|
-
matters.
|
|
47
|
+
matters. If a result is stale or wrong, update that entry in place (`save_lesson` with its id).
|
|
35
48
|
2. **Refresh the index if it looks empty or stale**
|
|
36
49
|
- `index_repo root:"<project>"` — incremental; unchanged files are skipped.
|
|
37
50
|
- `index_doc file_path:"…"` — one document, even outside the corpus.
|
|
@@ -39,16 +52,29 @@ Query it before re-deriving; write to it only after something has been verified.
|
|
|
39
52
|
3. **Write back what will still be true next session**
|
|
40
53
|
- `save_lesson` — one insight. Give `kind` (`lesson` / `decision` / `procedure`), a one-line
|
|
41
54
|
`title`, and the body: `pattern` + `fix`, or `choice` + `reason`, or `steps`.
|
|
42
|
-
- `remember problem solution` — shorthand for `kind: experience
|
|
55
|
+
- `remember problem solution` — shorthand for `kind: experience`; it always writes project
|
|
56
|
+
scope, so use `save_lesson` with `scope: 'task'` + `task_id` for task-level experience.
|
|
43
57
|
- `files`: project-relative paths the conclusion is about.
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
- Similar entries are merged or overwritten automatically; a near match returns its id instead
|
|
59
|
+
of creating a duplicate.
|
|
60
|
+
- `trigger.when`: when this should be recalled. `ops` (action names: `file-write` / `file-delete` /
|
|
61
|
+
`shell-run` / `git-commit` / `git-push` / `release` / `npm-publish` / `go-public` / `deploy` /
|
|
62
|
+
`migrate` / `render-doc` / `index-doc` / `read-image` / `fetch-web` / `run-bench` / `query-memory`),
|
|
63
|
+
`writes` (project-relative paths about to change; `*` wildcards allowed), `intents` (words the
|
|
64
|
+
human would use; CJK ≥2 chars, latin ≥5 chars). **`when` is the only trigger surface: without
|
|
65
|
+
it the entry is retrieval-only.** `guard` only narrows and all conditions must hold: `paths`
|
|
66
|
+
(write target must match one), `not_paths`, `hosts` (e.g. `wsl`), `tags` (profile tag
|
|
67
|
+
intersection). `prevents` records what breaks without it. Do **not** write a trigger you have
|
|
68
|
+
not seen fire.
|
|
69
|
+
- `scope`: `task` (bound task, or pass `task_id` — a host `task-<n>` gets its memory anchor on
|
|
70
|
+
first task-scope write, no `select_task` needed), `project` (the default when there is no
|
|
71
|
+
bound task and no `task_id`), `global` (rarely).
|
|
48
72
|
4. **Correct or delete**
|
|
49
73
|
- Same `id` + new fields = in-place update (old value kept in `prev`).
|
|
50
|
-
- `forget id_or_query` is a real delete, no undo. Prefer ids
|
|
51
|
-
|
|
74
|
+
- `forget id_or_query` is a real delete, no undo. Prefer ids. Keyword matching is query-side
|
|
75
|
+
coverage (matched query terms ÷ query terms); over the cap (default 10) nothing is deleted and
|
|
76
|
+
candidates are listed. The 5 most recently deleted entries are kept in that layer's
|
|
77
|
+
`deleted.json` (the result prints the path) — read it and save again to recover a mis-delete.
|
|
52
78
|
|
|
53
79
|
## Rules
|
|
54
80
|
|
|
@@ -56,6 +82,8 @@ Query it before re-deriving; write to it only after something has been verified.
|
|
|
56
82
|
- Do not save: progress narration, temporary state, secrets/credentials, anything derivable from the
|
|
57
83
|
code in one read.
|
|
58
84
|
- One durable entry beats five observations. Merge by updating the existing id.
|
|
85
|
+
- Keep the criterion and the command; run-specific values (versions, counts, branch names) stay
|
|
86
|
+
out of the entry.
|
|
59
87
|
- Write in the same language the project uses; keep titles short and searchable.
|
|
60
88
|
- The store self-ignores in git; do not commit it unless the human explicitly wants memory in the repo.
|
|
61
89
|
|
package/src/audit.js
CHANGED
|
@@ -116,8 +116,8 @@ export function shadowRecordFrom(input) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* 审计只为"已存在"或"带项目标记"的根建 store
|
|
120
|
-
*
|
|
119
|
+
* 审计只为"已存在"或"带项目标记"的根建 store 目录:否则在容器目录里开会话会留下只装审计日志的
|
|
120
|
+
* 空 store(`PROJECT_MARKERS` 不含 store 目录,它本身不会让根变成项目根,但空目录仍是垃圾)。
|
|
121
121
|
* 标记判据 `hasProjectMarker`,与 `rootNotice` 一致。
|
|
122
122
|
* @param {string} memoryDir `<root>/.dsh-project-memory`
|
|
123
123
|
* @param {string} [root] 项目根;省略时退回 `path.dirname(memoryDir)`
|
package/src/auto-inject.js
CHANGED
|
@@ -185,7 +185,8 @@ export function buildEntryContent(task, cfg, { withEdited = true } = {}) {
|
|
|
185
185
|
if (!task) return ''
|
|
186
186
|
const c = cfg || {}
|
|
187
187
|
const steps = (task.steps || []).map((s) => stepContent(s).slice(0, 80))
|
|
188
|
-
|
|
188
|
+
// 团队锚点不存步骤(宿主团队任务板才是唯一来源),别在卡上留一个空的“进度: ”。
|
|
189
|
+
const progress = steps.length ? `${steps.length} 步` : (task.teamTaskId ? '见宿主团队任务板' : '')
|
|
189
190
|
const card = [
|
|
190
191
|
`任务: ${task.title || '(untitled)'}`,
|
|
191
192
|
`进度: ${progress}`,
|
|
@@ -357,7 +358,10 @@ function scoreHints({ cands, query, humanText, hintQuery, cfg, dropped, rerank =
|
|
|
357
358
|
}
|
|
358
359
|
|
|
359
360
|
// ---- 影子候选(只读、无副作用):重放全部被评分的条目,标出它卡在哪一关 ----
|
|
360
|
-
//
|
|
361
|
+
// 真实路径是:relative 预筛(下方 `relativeHits(scored, …)`)→ 循环内 support → coverage → thin → vector。
|
|
362
|
+
// 影子为了给每条都留一行,把 relative 放到末级再判(前面的关先命中就先记),所以同一条可能
|
|
363
|
+
// 在真实路径被 relative 滤掉、影子却记成更早的关卡——按 `decision` 归因阈值时要记住这个偏差。
|
|
364
|
+
// 'cand' 不等于"真的注入了"(还要过去重/预算/冷却)。
|
|
361
365
|
{
|
|
362
366
|
// 两个分母必须分开:真实判据(`relative`)用**融合后**的分,而影子记录的 `rel` 承诺**词法**相对分;
|
|
363
367
|
// 共用会让 `rel` 到 5.925(应当 ≤1),离线拿它重放阈值全歪。
|
|
@@ -449,7 +453,8 @@ export function buildInjection(opts) {
|
|
|
449
453
|
// 会话级限流命中:条目通道本轮整体沉默,但把"本该注入什么"记进 dropped——不做静默降级。
|
|
450
454
|
for (const { it } of triggered) dropped.push({ id: it.id, channel: 'trigger', reason: opts.silenceReason || 'cooldown' })
|
|
451
455
|
}
|
|
452
|
-
// procedure
|
|
456
|
+
// procedure 不进提示通道:它只走 authored trigger 全文通道。提示通道没有 trigger.scope 的画像过滤,
|
|
457
|
+
// 放进来就等于绕过作用域(将来要放宽,先把那套过滤搬进提示通道)。
|
|
453
458
|
const consumed = new Set(triggered.map((t) => t.it.id))
|
|
454
459
|
// 限流命中时**照旧评分**(只算不注入,`place()` 仍按 skipItems 跳过):影子记录要能回答"这一步
|
|
455
460
|
// 如果不限流会注入什么"——那正是限流期间最需要回答的问题。
|
|
@@ -528,7 +533,7 @@ export function buildInjection(opts) {
|
|
|
528
533
|
return { text: clamp(total.join('\n')), entry, labels, reasons, dropped, candidates, scoreQuery, dedupeText, itemChars: itemUsed }
|
|
529
534
|
}
|
|
530
535
|
|
|
531
|
-
//
|
|
536
|
+
// 每会话状态的会话数上限:所有每会话表共用。
|
|
532
537
|
const SESSION_STATE_MAX = 200
|
|
533
538
|
// 单会话已注入条目表的条数上限。
|
|
534
539
|
const INJECTED_ITEMS_MAX = 600
|
|
@@ -537,7 +542,7 @@ const OBSERVED_CALLS_MAX = 8
|
|
|
537
542
|
|
|
538
543
|
/**
|
|
539
544
|
* 注入引擎的「每会话一份」状态。
|
|
540
|
-
*
|
|
545
|
+
* 全部表都由 SessionCache 管容量,容量只在这里定义一次。
|
|
541
546
|
*/
|
|
542
547
|
class InjectionSessions {
|
|
543
548
|
constructor() {
|
|
@@ -10,6 +10,7 @@ import { useEffect, useCallback, useRef, useState } from 'react'
|
|
|
10
10
|
import { Button } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
11
11
|
import { invokeCommand } from './commands.ts'
|
|
12
12
|
import { insightKindLabel } from './kind-label.js'
|
|
13
|
+
import { bodyFieldOf, titleFieldOf } from '../util/insight-fields.js'
|
|
13
14
|
import { HOST_PAGE_MAX, PAGE_SIZE, PREFETCH_MARGIN, SPINNER_DELAY_MS, appendUnique, createRequestGate, insightListLine, normalizeWindow, progressCounts } from './paging.js'
|
|
14
15
|
import css from './TaskPanel.module.css'
|
|
15
16
|
|
|
@@ -378,12 +379,7 @@ export function MemoryView({
|
|
|
378
379
|
// 正文按 kind 取专属字段(fix/solution/reason),避免把与标题相同的 pattern/problem 当正文。
|
|
379
380
|
// procedure 的 row.body 是服务端 insSummary 合成的“步骤 N 条:…”——它不是正文,
|
|
380
381
|
// 表单里也没有对应输入框;预填后提交会把合成摘要写进真实 body,所以这里不预填。
|
|
381
|
-
const main =
|
|
382
|
-
row.kind === 'lesson' ? row.fix
|
|
383
|
-
: row.kind === 'experience' ? row.solution
|
|
384
|
-
: row.kind === 'decision' ? row.reason
|
|
385
|
-
: row.kind === 'procedure' ? ''
|
|
386
|
-
: row.body
|
|
382
|
+
const main = row.kind === 'procedure' ? '' : row[bodyFieldOf(row.kind)]
|
|
387
383
|
const body = main && main !== row.title ? main : ''
|
|
388
384
|
return {
|
|
389
385
|
title: row.title || '',
|
|
@@ -433,19 +429,14 @@ export function MemoryView({
|
|
|
433
429
|
// 标题镜像只用于**新建**:编辑时 pattern/choice/problem 不出现在表单里,
|
|
434
430
|
// 无条件回传会把它们静默覆盖成标题(且宿主的 edit 路径不写 prev,无法还原)。
|
|
435
431
|
if (!editingId) {
|
|
436
|
-
|
|
437
|
-
if (
|
|
438
|
-
if (form.kind === 'experience') fields.problem = title
|
|
432
|
+
const titleField = titleFieldOf(form.kind)
|
|
433
|
+
if (titleField) fields[titleField] = title
|
|
439
434
|
}
|
|
440
435
|
// procedure 的正文由 steps 表达;不要把 body 一起提交(它只可能是合成摘要)。
|
|
441
436
|
// 编辑时必须把本表单拥有的字段都带上(空串/空数组表示清空):宿主只合并出现的键,
|
|
442
437
|
// 省略会让“清空正文/步骤”变成静默空操作。
|
|
443
438
|
if (form.kind !== 'procedure' && (editingId || form.body.trim())) {
|
|
444
|
-
|
|
445
|
-
if (form.kind === 'lesson') fields.fix = body
|
|
446
|
-
else if (form.kind === 'decision') fields.reason = body
|
|
447
|
-
else if (form.kind === 'experience') fields.solution = body
|
|
448
|
-
else fields.body = body
|
|
439
|
+
fields[bodyFieldOf(form.kind)] = form.body.trim()
|
|
449
440
|
}
|
|
450
441
|
const editingRow = editingId ? rows.find((r) => r.id === editingId) : null
|
|
451
442
|
// procedure 的列表载荷被宿主截到 50 条:编辑标题/正文时若整份回传,会删掉第 51 条起。
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { createTranslate } from './locales.ts'
|
|
16
16
|
import { insightKindLabel } from './kind-label.js'
|
|
17
17
|
import { useTaskDrag } from './task-hooks.ts'
|
|
18
|
-
import { type Task, type
|
|
18
|
+
import { type Task, type TaskStep } from './task-data-store.ts'
|
|
19
19
|
import { timeAgo } from '../util/relative-time.js'
|
|
20
20
|
import css from './TaskPanel.module.css'
|
|
21
21
|
|
|
@@ -209,6 +209,13 @@ export function TaskCard({
|
|
|
209
209
|
|
|
210
210
|
const done = steps.filter((s) => s.status === 'completed').length
|
|
211
211
|
const pct = steps.length > 0 ? Math.round((done / steps.length) * 100) : 0
|
|
212
|
+
// 展开后到底有没有东西可看:团队卡不渲染空的“步骤”段,若又没有文件/记忆条目,
|
|
213
|
+
// 展开只会留一个带边框的空框,所以直接不渲染正文,也不显示展开箭头。
|
|
214
|
+
const showStepsSection = !(task.teamTaskId && steps.length === 0)
|
|
215
|
+
const showFilesSection = (task.files?.length ?? 0) > 0
|
|
216
|
+
const insights = Array.isArray(task.insights) ? task.insights : []
|
|
217
|
+
const showInsightsSection = Boolean(onInsightAction) && insights.length > 0
|
|
218
|
+
const hasBody = showStepsSection || showFilesSection || showInsightsSection
|
|
212
219
|
|
|
213
220
|
const commitStepEdit = (index: number) => {
|
|
214
221
|
if (!stepEdit || stepEdit.index !== index) return
|
|
@@ -311,7 +318,7 @@ export function TaskCard({
|
|
|
311
318
|
<div className={css.cardMeta}>
|
|
312
319
|
{steps.length > 0 && <span className={css.progressText}>{done}/{steps.length}</span>}
|
|
313
320
|
<span className={css.updated}>{timeAgo(task.updatedAt || task.lastActiveAt, '')}</span>
|
|
314
|
-
<span className={css.chevron}>{expanded ? <IconChevronUpOutline14 /> : <IconChevronDownOutline14 />}</span>
|
|
321
|
+
{hasBody && <span className={css.chevron}>{expanded ? <IconChevronUpOutline14 /> : <IconChevronDownOutline14 />}</span>}
|
|
315
322
|
</div>
|
|
316
323
|
</div>
|
|
317
324
|
{steps.length > 0 && (
|
|
@@ -319,104 +326,107 @@ export function TaskCard({
|
|
|
319
326
|
<div className={css.trackFill} style={{ width: `${pct}%` }} />
|
|
320
327
|
</div>
|
|
321
328
|
)}
|
|
322
|
-
{expanded && (
|
|
329
|
+
{expanded && hasBody && (
|
|
323
330
|
<div className={css.cardBody}>
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
331
|
+
{/* 团队任务卡不渲染空的“步骤”段(步骤由宿主团队任务板维护),其余卡片保持原样。 */}
|
|
332
|
+
{showStepsSection && (
|
|
333
|
+
<div className={css.section}>
|
|
334
|
+
<div className={css.sectionLabel}>
|
|
335
|
+
{t('task.steps')}
|
|
336
|
+
{steps.length > 0 && <span className={css.sectionCount}>{steps.length}</span>}
|
|
337
|
+
</div>
|
|
338
|
+
{steps.length > 0 ? (
|
|
339
|
+
<>
|
|
340
|
+
<ol className={css.stepsList}>
|
|
341
|
+
{steps.map((step, i) => {
|
|
342
|
+
const stepIsEditing = stepEdit !== null && stepEdit.index === i
|
|
343
|
+
const stepIsDragging = dragState?.dragging && dragState.fromIndex === i
|
|
344
|
+
const isDropTarget = dropTargetIndex === i
|
|
345
|
+
const isDropTargetAfter = dropTargetIndex === i + 1
|
|
346
|
+
return (
|
|
347
|
+
<li
|
|
348
|
+
key={i}
|
|
349
|
+
data-step-row
|
|
350
|
+
className={`${css.stepRow}${stepIsDragging ? ` ${css.stepDragging}` : ''}${isDropTarget ? ` ${css.dropTargetBefore}` : ''}${isDropTargetAfter ? ` ${css.dropTargetAfter}` : ''}`}
|
|
351
|
+
onMouseDown={(e) => {
|
|
352
|
+
if (e.button !== 0) return
|
|
353
|
+
if (!isBound || syncing) return
|
|
354
|
+
// 交互控件(状态图标、编辑输入框等)上不进入拖拽
|
|
355
|
+
const el = e.target as HTMLElement
|
|
356
|
+
if (el.closest('button, input, textarea, a')) return
|
|
357
|
+
startDrag(i, step.content, e)
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
{isBound ? (
|
|
361
|
+
<button
|
|
362
|
+
type="button"
|
|
363
|
+
className={css.stepToggle}
|
|
364
|
+
disabled={syncing}
|
|
365
|
+
onClick={(e) => { e.stopPropagation(); onCycleStatus(i) }}
|
|
366
|
+
title={showHints ? `${t('step.completed')}/${t('step.in-progress')}/${t('step.pending')}` : undefined}
|
|
367
|
+
>
|
|
368
|
+
<StepIcon status={step.status} />
|
|
369
|
+
</button>
|
|
370
|
+
) : (
|
|
359
371
|
<StepIcon status={step.status} />
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
>
|
|
408
|
-
×
|
|
409
|
-
</button>
|
|
372
|
+
)}
|
|
373
|
+
{stepIsEditing ? (
|
|
374
|
+
<InlineEditor
|
|
375
|
+
className={css.editorArea}
|
|
376
|
+
value={stepEdit!.value}
|
|
377
|
+
maxRows={10}
|
|
378
|
+
disabled={syncing}
|
|
379
|
+
onValueChange={(value) => setStepEdit({ index: i, value })}
|
|
380
|
+
onCommit={() => commitStepEdit(i)}
|
|
381
|
+
onCancel={() => setStepEdit(null)}
|
|
382
|
+
/>
|
|
383
|
+
) : (
|
|
384
|
+
<span
|
|
385
|
+
className={`${css.stepContent}${step.status === 'completed' ? ` ${css.stepContentDone}` : ''}${step.status === 'in_progress' ? ` ${css.stepContentRun}` : ''}${isBound ? ` ${css.stepEditable}` : ''}`}
|
|
386
|
+
title={isBound && showHints ? t('step.edit-hint') : undefined}
|
|
387
|
+
onDoubleClick={(e) => {
|
|
388
|
+
e.stopPropagation()
|
|
389
|
+
if (isBound && !syncing) setStepEdit({ index: i, value: String(step.content ?? '') })
|
|
390
|
+
}}
|
|
391
|
+
>
|
|
392
|
+
{step.content}
|
|
393
|
+
</span>
|
|
394
|
+
)}
|
|
395
|
+
</li>
|
|
396
|
+
)
|
|
397
|
+
})}
|
|
398
|
+
</ol>
|
|
399
|
+
{dragState && dragState.dragging && (
|
|
400
|
+
<div
|
|
401
|
+
className={css.dragGhost}
|
|
402
|
+
style={{
|
|
403
|
+
left: dragState.clientX + 12,
|
|
404
|
+
top: dragState.clientY - 20,
|
|
405
|
+
}}
|
|
406
|
+
>
|
|
407
|
+
<div className={css.dragGhostCard}>
|
|
408
|
+
<span className={css.dragGhostContent}>{dragState.stepContent}</span>
|
|
409
|
+
<button
|
|
410
|
+
type="button"
|
|
411
|
+
className={css.dragGhostClose}
|
|
412
|
+
style={{ pointerEvents: 'auto' }}
|
|
413
|
+
onClick={(e) => { e.stopPropagation(); cancelDrag() }}
|
|
414
|
+
title={showHints ? t('drag.cancel') : undefined}
|
|
415
|
+
aria-label={t('drag.cancel')}
|
|
416
|
+
>
|
|
417
|
+
×
|
|
418
|
+
</button>
|
|
419
|
+
</div>
|
|
410
420
|
</div>
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
421
|
+
)}
|
|
422
|
+
</>
|
|
423
|
+
) : (
|
|
424
|
+
<div className={css.muted}>{t('panel.empty-desc')}</div>
|
|
425
|
+
)}
|
|
426
|
+
</div>
|
|
427
|
+
)}
|
|
418
428
|
|
|
419
|
-
{
|
|
429
|
+
{showFilesSection && (
|
|
420
430
|
<div className={css.section}>
|
|
421
431
|
<div className={css.sectionLabel}>
|
|
422
432
|
{t('task.files')}
|
|
@@ -443,14 +453,14 @@ export function TaskCard({
|
|
|
443
453
|
</div>
|
|
444
454
|
)}
|
|
445
455
|
|
|
446
|
-
{onInsightAction &&
|
|
456
|
+
{onInsightAction && showInsightsSection && (
|
|
447
457
|
<div className={css.section}>
|
|
448
458
|
<div className={css.sectionLabel}>
|
|
449
459
|
{t('mem.section-label')}
|
|
450
|
-
<span className={css.sectionCount}>{
|
|
460
|
+
<span className={css.sectionCount}>{insights.length}</span>
|
|
451
461
|
</div>
|
|
452
462
|
<ul className={css.memList}>
|
|
453
|
-
{
|
|
463
|
+
{insights.map((ins) => (
|
|
454
464
|
<li key={ins.id} className={css.memRow}>
|
|
455
465
|
<div className={css.memTitle}>
|
|
456
466
|
<span className={css.kindBadge}>{insightKindLabel(ins.kind, t)}</span>
|
|
@@ -163,10 +163,9 @@
|
|
|
163
163
|
background: var(--dsw-alias-bg-base, transparent);
|
|
164
164
|
overflow: hidden;
|
|
165
165
|
transition: border-color 0.15s ease;
|
|
166
|
-
/*
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
contain-intrinsic-size: auto 140px;
|
|
166
|
+
/* 0.7.1 就有的隐患:content-visibility:auto + 卡片高度随展开变化 + 内层滚动,
|
|
167
|
+
Chromium 会把卡片正文当作"离屏内容"跳过——标题和"步骤"标签还在、步骤行空白,
|
|
168
|
+
控制台无报错。任务卡最多百来张,关掉它换取稳定渲染;不动任何尺寸/间距。 */
|
|
170
169
|
}
|
|
171
170
|
.cardBound {
|
|
172
171
|
border-color: var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.35));
|
|
@@ -398,10 +397,17 @@
|
|
|
398
397
|
.taskList {
|
|
399
398
|
flex: 1 1 auto;
|
|
400
399
|
min-height: 0;
|
|
400
|
+
/* 高度与其他视图(项目记忆 480px)一致;卡片保持原高度,展开的卡片按正常文档流
|
|
401
|
+
把后面的任务往下推,列表自己滚。 */
|
|
402
|
+
max-height: min(480px, 56vh);
|
|
401
403
|
}
|
|
402
404
|
.card {
|
|
403
405
|
display: flex;
|
|
404
406
|
flex-direction: column;
|
|
407
|
+
/* 关键:卡片不能是 flex-shrink 的。否则内容超过列表高度时浏览器会**压缩每张卡**,
|
|
408
|
+
展开一张就会把其他任务挤扁(截图里的重叠/挤压就是这么来的);让它保持自身高度,
|
|
409
|
+
溢出交给列表滚动。 */
|
|
410
|
+
flex: 0 0 auto;
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
/* —— 错误边界兜底按钮 —— */
|
package/src/client/TaskPanel.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import { useTaskData, useTaskDataActions, parseTaskPayloadText } from './task-da
|
|
|
20
20
|
import { useTaskUI, useTaskUIActions, PANEL_VIEWS } from './task-ui-store.ts'
|
|
21
21
|
import { MiniBar, TaskCard } from './TaskComponents.tsx'
|
|
22
22
|
import { MemoryView, invalidateInsightCache, type InsightScope } from './MemoryView.tsx'
|
|
23
|
+
import { TASK_PAGE_SIZE, TASK_PREFETCH_MARGIN, nextTaskCount } from './task-window.js'
|
|
23
24
|
import { pickSessionId } from './session-id.js'
|
|
24
25
|
import css from './TaskPanel.module.css'
|
|
25
26
|
|
|
@@ -98,6 +99,12 @@ function TaskPanelView({ ctx }: { ctx: any }) {
|
|
|
98
99
|
const tasks = Array.isArray(data.tasks) ? data.tasks : []
|
|
99
100
|
const activeTasks = tasks.filter((task) => !task.archived)
|
|
100
101
|
const boundTask = data.boundTaskId ? tasks.find((task) => task.id === data.boundTaskId) ?? null : null
|
|
102
|
+
// 渐进渲染:首屏一批卡,滚到列表底部由哨兵放出下一批。数据本来就在 `/tasks` 载荷里
|
|
103
|
+
// (单任务的步骤/文件已由服务端截断),这里控的是 DOM 数量,不是请求。
|
|
104
|
+
const [shownCount, setShownCount] = useState(TASK_PAGE_SIZE)
|
|
105
|
+
const listRef = useRef<HTMLDivElement>(null)
|
|
106
|
+
const sentinelRef = useRef<HTMLDivElement>(null)
|
|
107
|
+
const visibleTasks = activeTasks.slice(0, Math.min(shownCount, activeTasks.length))
|
|
101
108
|
|
|
102
109
|
const applyPayload = (text: string | undefined, requestSessionId: string | null): boolean => {
|
|
103
110
|
// 旧会话的响应不得落到新会话:applyPayload 是旧闭包,sessionId 也已过期。
|
|
@@ -270,6 +277,29 @@ function TaskPanelView({ ctx }: { ctx: any }) {
|
|
|
270
277
|
refreshRef.current()
|
|
271
278
|
}, [ui.closed, ui.view, sessionId])
|
|
272
279
|
|
|
280
|
+
// 换会话回到首屏;同一会话里的动作刷新不收回已放的批次(用户滚到哪就停在哪)。
|
|
281
|
+
useEffect(() => {
|
|
282
|
+
setShownCount(TASK_PAGE_SIZE)
|
|
283
|
+
}, [sessionId])
|
|
284
|
+
|
|
285
|
+
// 哨兵进视口就放出下一批(数据在本地,无需预取)。root 必须是列表自己的滚动容器,
|
|
286
|
+
// 用视口当 root 会无视面板 480px 的上限、一次放光。没有 IntersectionObserver 时由页脚按钮兜底。
|
|
287
|
+
// deps 里必须带 closed/minimized:收到迷你条或彻底隐藏时列表 DOM 会卸载,组件实例却还活着,
|
|
288
|
+
// 不重跑这个 effect 的话,重新展开后新哨兵没人观察——列表会停在第一批,而且没有任何报错。
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (ui.closed || ui.minimized || view !== 'task' || shownCount >= activeTasks.length) return
|
|
291
|
+
const sentinel = sentinelRef.current
|
|
292
|
+
if (!sentinel || typeof IntersectionObserver === 'undefined') return
|
|
293
|
+
const observer = new IntersectionObserver(
|
|
294
|
+
(entries) => {
|
|
295
|
+
if (entries.some((e) => e.isIntersecting)) setShownCount((n) => nextTaskCount(n, activeTasks.length))
|
|
296
|
+
},
|
|
297
|
+
{ root: listRef.current ?? null, rootMargin: TASK_PREFETCH_MARGIN },
|
|
298
|
+
)
|
|
299
|
+
observer.observe(sentinel)
|
|
300
|
+
return () => observer.disconnect()
|
|
301
|
+
}, [ui.closed, ui.minimized, view, shownCount, activeTasks.length])
|
|
302
|
+
|
|
273
303
|
// 彻底隐藏:不渲染任何东西
|
|
274
304
|
if (ui.closed) {
|
|
275
305
|
return null
|
|
@@ -412,8 +442,8 @@ function TaskPanelView({ ctx }: { ctx: any }) {
|
|
|
412
442
|
{syncing && <p className={css.syncHint}>{t('panel.syncing')}</p>}
|
|
413
443
|
</div>
|
|
414
444
|
) : (
|
|
415
|
-
<div className={css.taskList}>
|
|
416
|
-
{
|
|
445
|
+
<div ref={listRef} className={css.taskList}>
|
|
446
|
+
{visibleTasks.map((task) => {
|
|
417
447
|
const expanded = ui.expandedTaskIds.includes(task.id)
|
|
418
448
|
const isBound = data.boundTaskId === task.id
|
|
419
449
|
return (
|
|
@@ -438,6 +468,23 @@ function TaskPanelView({ ctx }: { ctx: any }) {
|
|
|
438
468
|
)
|
|
439
469
|
})}
|
|
440
470
|
{syncing && <div className={css.syncHint}>{t('panel.syncing')}</div>}
|
|
471
|
+
{shownCount < activeTasks.length && (
|
|
472
|
+
<>
|
|
473
|
+
<div ref={sentinelRef} className={css.memSentinel} aria-hidden="true" />
|
|
474
|
+
{/* 老浏览器/测试替身没有 IntersectionObserver:给个按钮,绝不静默停住。 */}
|
|
475
|
+
{typeof IntersectionObserver === 'undefined' && (
|
|
476
|
+
<div className={css.memFooter}>
|
|
477
|
+
<Button
|
|
478
|
+
variant="outline"
|
|
479
|
+
size="sm"
|
|
480
|
+
onClick={() => setShownCount((n) => nextTaskCount(n, activeTasks.length))}
|
|
481
|
+
>
|
|
482
|
+
{t('panel.loadMore')}
|
|
483
|
+
</Button>
|
|
484
|
+
</div>
|
|
485
|
+
)}
|
|
486
|
+
</>
|
|
487
|
+
)}
|
|
441
488
|
</div>
|
|
442
489
|
)}
|
|
443
490
|
</div>
|
package/src/client/locales.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const zh = {
|
|
|
14
14
|
'style.brutal': '粗野',
|
|
15
15
|
'style.mono': '终端',
|
|
16
16
|
'panel.syncing': '同步中…',
|
|
17
|
+
'panel.loadMore': '加载更多',
|
|
17
18
|
'panel.sync-failed': '同步失败',
|
|
18
19
|
'panel.hints-on': '显示提示信息',
|
|
19
20
|
'panel.hints-off': '隐藏提示信息',
|
|
@@ -119,6 +120,7 @@ export const en = {
|
|
|
119
120
|
'style.brutal': 'Brutal',
|
|
120
121
|
'style.mono': 'Mono',
|
|
121
122
|
'panel.syncing': 'Syncing…',
|
|
123
|
+
'panel.loadMore': 'Load more',
|
|
122
124
|
'panel.sync-failed': 'Sync failed',
|
|
123
125
|
'panel.hints-on': 'Show hints',
|
|
124
126
|
'panel.hints-off': 'Hide hints',
|
|
@@ -34,6 +34,8 @@ export interface Task {
|
|
|
34
34
|
insights?: TaskInsight[]
|
|
35
35
|
/** 载荷被截断时的真实总量;正常任务没有这个键。 */
|
|
36
36
|
totals?: { steps: number; files: number; insights: number; completedSteps: number }
|
|
37
|
+
/** 宿主团队任务锚点:面板不渲染空的步骤段(步骤由团队任务板维护)。 */
|
|
38
|
+
teamTaskId?: string
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export interface TaskPayload {
|