@sanqianx/project-knowledge 5.0.32 → 5.0.34

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 (56) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +15 -0
  3. package/_site/_test/automatic-context-test.js +19 -0
  4. package/_site/_test/chat-claudecodeui-match-test.js +22 -3
  5. package/_site/_test/context-session-index-test.js +244 -0
  6. package/_site/_test/fixtures/retrieval-gold-queries.json +4 -0
  7. package/_site/_test/fresh-product-data-test.js +1 -1
  8. package/_site/_test/glm-ui-refresh-review-test.js +1 -1
  9. package/_site/_test/harness-isolation-test.js +1 -1
  10. package/_site/_test/home-overview-test.js +64 -0
  11. package/_site/_test/index-error-display-contract-test.js +23 -1
  12. package/_site/_test/knowledge-engine-client-test.js +1 -1
  13. package/_site/_test/memory-groups-ui-test.js +149 -0
  14. package/_site/_test/module-terminal-restart-test.js +1 -1
  15. package/_site/_test/packaged-ui-smoke-test.js +40 -2
  16. package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +94 -33
  17. package/_site/_test/parallel-knowledge-client-error-code-test.js +11 -1
  18. package/_site/_test/parallel-logging-acceptance-log008-test.js +23 -11
  19. package/_site/_test/parallel-memory-candidate-test.js +134 -84
  20. package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +100 -38
  21. package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +92 -32
  22. package/_site/_test/parallel-memory-manual-test.js +140 -34
  23. package/_site/_test/parallel-memory-scope-test.js +91 -23
  24. package/_site/_test/parallel-memory-source-test.js +54 -25
  25. package/_site/_test/parallel-memory-sync-test.js +102 -75
  26. package/_site/_test/parallel-nav-failure-test.js +36 -16
  27. package/_site/_test/parallel-nav-offline-test.js +37 -9
  28. package/_site/_test/parallel-nav-operability-test.js +12 -1
  29. package/_site/_test/parallel-nav-switch-test.js +65 -19
  30. package/_site/_test/parallel-nav-theme-test.js +52 -7
  31. package/_site/_test/parallel-nav-viewport-test.js +13 -4
  32. package/_site/_test/product-diagnostics-ui-test.js +15 -3
  33. package/_site/_test/product-empty-state-test.js +81 -15
  34. package/_site/_test/product-import-ui-test.js +35 -9
  35. package/_site/_test/product-navigation-test.js +78 -17
  36. package/_site/_test/product-progress-status-test.js +21 -5
  37. package/_site/_test/project-module-partial-recovery-test.js +22 -7
  38. package/_site/_test/project-unbind-late-read-ui-test.js +45 -14
  39. package/_site/_test/workspace-ui-contract-test.js +38 -5
  40. package/_site/lib/engine-connection.js +1 -1
  41. package/_site/lib/engine-knowledge-client.js +1 -1
  42. package/_site/lib/server-app.js +23 -0
  43. package/_site/scripts/ab-rank-v2-v3.js +142 -0
  44. package/_site/scripts/refresh-runtime-manifest.js +108 -0
  45. package/_site/scripts/run-retrieval-gold-isolated.js +221 -0
  46. package/_site/scripts/verify-retrieval-gold.js +57 -10
  47. package/module-runtime-manifest.json +22 -20
  48. package/package.json +2 -2
  49. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  50. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  51. package/plugins/project-knowledge/.mcp.json +1 -1
  52. package/plugins/project-knowledge/scripts/context-hook.cjs +9 -5
  53. package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +39 -28
  54. package/ui/index.html +14 -11
  55. package/ui/product.css +42 -0
  56. package/ui/product.js +830 -212
@@ -23,12 +23,36 @@
23
23
  // source record;
24
24
  // * 未确认不注入。 -> before the user confirms it the engine injects
25
25
  // nothing for that memory, and the real UI lists
26
- // it in 候选箱 with 审核确认 / 忽略.
26
+ // it in 候选箱 with the review actions.
27
27
  // MEM-005 expected:
28
28
  // * 状态ignored。 -> the real PATCH answers with status 'ignored';
29
29
  // * 来源保持记录(冻结)。 -> the ignored record keeps the same commit, entry,
30
30
  // quote, source event and eligibility, and injects
31
31
  // nothing.
32
+ //
33
+ // 迁移说明(五页简化 UI,见 patches/ui-test-mapping-spec.md):
34
+ // * 候选箱 tab:[data-memory-tab="candidate"] 选择器不变(标签从「候选」/
35
+ // confirmed-tab 体系改为「记忆库/候选箱」,confirmed tab → library tab)。
36
+ // * 候选卡片:[data-memory-card=<id>] → 候选箱 .row 行(以
37
+ // [data-action="review-candidate"][data-id=<id>] 定位);行上的
38
+ // 「审核确认 / 忽略」两个按钮合并为一个「审核」按钮,审核动作移入
39
+ // #appDialog 内 #reviewForm 的动作区:确认收录 =
40
+ // #appDialogActions button.primary,忽略 = #appDialogActions
41
+ // button.danger,取消 = #appDialogActions button:not(.primary):not(.danger)。
42
+ // * 审核对话框:旧 #memoryDialog 内 #memoryText(可编辑正文)+
43
+ // #memoryEvidence/#memoryQuote/#memoryEvidenceDetails → #reviewForm 冻结
44
+ // 正文/来源行(#appDialogBody 文本含 commit 前 8 位、entryId)+
45
+ // details.agent-detail(点击 summary 展开冻结 quote)。等价断言改为读
46
+ // #appDialogBody 与展开后的 details。
47
+ // * 旧「保存候选」(#saveMemoryCandidate:改正文但不确认,PATCH 不带
48
+ // status)在新 UI 已移除(候选正文冻结,不可编辑)。等价语义保留为:
49
+ // 打开审核后点「取消」——不发任何 PATCH、记忆仍是 candidate、仍不注入。
50
+ // 「未确认不注入」本身始终由引擎注入门(/api/context)断言证明。
51
+ // * 确认收录仍 PATCH { status: 'confirmed' }、忽略仍 PATCH
52
+ // { status: 'ignored' }(网络捕获断言请求体不变);引擎侧冻结来源、
53
+ // 注入矩阵断言全部保持。
54
+ // * 「导入项目已列出」等待:旧首页项目面板已删除 → 顶栏 #projectSelect。
55
+ // * 确认后的列表断言:confirmed tab → [data-memory-tab="library"]。
32
56
 
33
57
  const fs = require('node:fs');
34
58
  const path = require('node:path');
@@ -40,26 +64,42 @@ const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_
40
64
  const CANDIDATE_TEXT = '对外错误信息使用中文表述,并优先复用已有模块。';
41
65
  const IGNORED_TEXT = '新增对外接口必须补充中文字段说明文档。';
42
66
 
67
+ /**
68
+ * Open the memory view with retries against the known reload commit-gap race
69
+ * (driver robustness only: the assertion stays "the view is really active").
70
+ */
43
71
  async function openMemoryView(harness) {
44
- await harness.nativeClick('nav [data-view="memory"]');
45
- await harness.waitFor(
46
- () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
47
- 'the memory view is open',
48
- 10000,
49
- );
72
+ let lastError = null;
73
+ for (let attempt = 0; attempt < 3; attempt += 1) {
74
+ await harness.nativeClick('nav [data-view="memory"]');
75
+ try {
76
+ await harness.waitFor(
77
+ () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
78
+ 'the memory view is open',
79
+ 5000,
80
+ );
81
+ return;
82
+ } catch (error) { lastError = error; }
83
+ }
84
+ throw lastError;
50
85
  }
51
86
 
52
87
  async function openCandidateBox(harness) {
53
88
  await openMemoryView(harness);
54
- await harness.nativeClick('[data-memory-tab="candidate"]');
89
+ await harness.waitFor(
90
+ () => harness.run("document.querySelector('#memoryContent [data-memory-tab=\"candidate\"]') !== null"),
91
+ 'the memory tab bar is rendered from real data',
92
+ 20000,
93
+ );
94
+ await harness.nativeClick('#memoryContent [data-memory-tab="candidate"]');
55
95
  }
56
96
 
57
- async function cardText(harness, memoryId) {
58
- return harness.run(`(() => {
59
- const el = document.querySelector('[data-memory-card=${JSON.stringify(memoryId)}]');
60
- return el ? el.textContent : null;
61
- })()`);
62
- }
97
+ /** The candidate-box row (.row) of one candidate, located by its review button. */
98
+ const candidateRowText = (harness, memoryId) => harness.run(`(() => {
99
+ const button = document.querySelector('#memoryContent [data-action="review-candidate"][data-id=${JSON.stringify(memoryId)}]');
100
+ const row = button ? button.closest('.row') : null;
101
+ return row ? row.textContent : null;
102
+ })()`);
63
103
 
64
104
  async function main() {
65
105
  const harness = await startHarness({ tag: 'memcand', evidenceDir: EVIDENCE || undefined });
@@ -68,8 +108,10 @@ async function main() {
68
108
  const repo = makeRepo(harness.fixture, 'memcand-repo', { 'README.md': '# 候选甲\n' });
69
109
  const { projectId } = await harness.importProject(repo, '候选甲');
70
110
  await harness.requestRegistryRefresh();
111
+ // The new home page no longer lists projects; the registry projection is
112
+ // surfaced by the topbar project selector instead.
71
113
  await harness.waitFor(
72
- () => harness.run("document.getElementById('homeContent').textContent.includes('候选甲')"),
114
+ () => harness.run("document.getElementById('projectSelect').textContent.includes('候选甲')"),
73
115
  'the imported project is listed',
74
116
  20000,
75
117
  );
@@ -101,7 +143,7 @@ async function main() {
101
143
  `an unconfirmed candidate is never injected: ${JSON.stringify(beforeReview)}`,
102
144
  );
103
145
 
104
- // The real UI lists it in 候选箱 with the review actions.
146
+ // The real UI lists it in 候选箱 with the review action.
105
147
  await harness.reload();
106
148
  await openCandidateBox(harness);
107
149
  await harness.waitFor(
@@ -109,97 +151,94 @@ async function main() {
109
151
  'the candidate is listed in the candidate box',
110
152
  15000,
111
153
  );
112
- const listed = await cardText(harness, stored.id);
113
- assert.ok(listed, 'the candidate really has a card in the candidate box');
114
- assert.match(listed, /来源/, 'the card names the source of the candidate');
115
- assert.ok(listed.includes(produced.commitSha.slice(0, 8)), 'the card shows the frozen commit');
154
+ const listed = await candidateRowText(harness, stored.id);
155
+ assert.ok(listed, 'the candidate really has a row in the candidate box');
156
+ assert.match(listed, /来源/, 'the row names the source of the candidate');
157
+ assert.ok(listed.includes(produced.commitSha.slice(0, 8)), 'the row shows the frozen commit');
116
158
  assert.ok(
117
- await harness.run(`Boolean(document.querySelector('[data-memory-action="confirm"][data-memory-id=${JSON.stringify(stored.id)}]'))`),
118
- 'the candidate offers 审核确认',
119
- );
120
- assert.ok(
121
- await harness.run(`Boolean(document.querySelector('[data-memory-action="ignore"][data-memory-id=${JSON.stringify(stored.id)}]'))`),
122
- 'the candidate offers 忽略',
159
+ await harness.run(`Boolean(document.querySelector('#memoryContent [data-action="review-candidate"][data-id=${JSON.stringify(stored.id)}]'))`),
160
+ 'the candidate offers 审核 (the review entry point)',
123
161
  );
124
162
  if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem003-candidate-box.png'));
125
163
 
126
- // The step's own path first: edit the candidate and click 保存候选 WITHOUT
127
- // confirming — the memory has to stay a candidate and stay un-injected.
128
- const EDIT_SUFFIX = '(修订)';
129
- await harness.nativeClick(`[data-memory-action="confirm"][data-memory-id="${stored.id}"]`);
164
+ // The old card-level 审核确认/忽略 pair became the review dialog's action
165
+ // buttons: open the review and check the frozen source plus both actions.
166
+ await harness.nativeClick(`#memoryContent [data-action="review-candidate"][data-id="${stored.id}"]`);
130
167
  await harness.waitFor(
131
- () => harness.run("document.getElementById('memoryDialog').open === true"),
168
+ () => harness.run("document.getElementById('appDialog').open === true && document.getElementById('reviewForm') !== null"),
132
169
  'the review dialog is open',
133
170
  10000,
134
171
  );
135
- await harness.nativeClick('#memoryText');
136
- await harness.pressKey('End', { code: 'End', keyCode: 35 });
137
- await harness.typeText(EDIT_SUFFIX);
138
- const editedBody = await harness.run("document.getElementById('memoryText').value");
139
- assert.equal(editedBody, CANDIDATE_TEXT + EDIT_SUFFIX, 'the real edit reached the textarea');
140
-
141
- await harness.nativeClick('#saveMemoryCandidate');
142
- await harness.waitFor(
143
- () => harness.run("document.getElementById('memoryDialog').open === false"),
144
- 'the dialog closes after saving the candidate',
145
- 15000,
146
- );
147
- const saveCandidatePatch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).pop();
148
- assert.ok(saveCandidatePatch, 'the shell really patched the candidate');
149
- assert.deepEqual(Object.keys(saveCandidatePatch.body).sort(), ['scopeId', 'scopeType', 'text'], '保存候选 sends no status at all');
150
- const saveCandidateBody = await harness.network.body(saveCandidatePatch);
151
- assert.equal(saveCandidatePatch.status, 200, `保存候选 answers 200: ${JSON.stringify(saveCandidatePatch.body)}`);
152
- assert.equal(saveCandidateBody.memory.status, 'candidate', '保存候选 keeps the memory a candidate');
153
- assert.equal(saveCandidateBody.memory.text, CANDIDATE_TEXT + EDIT_SUFFIX, '保存候选 keeps the edited text');
154
- assert.equal(saveCandidateBody.memory.originalText, CANDIDATE_TEXT, '保存候选 keeps the frozen original summary');
155
- const saveToast = await harness.run("document.getElementById('toast').textContent");
156
- assert.match(String(saveToast), /候选已保存,尚未生效。/, `the toast says the candidate is not yet effective: ${saveToast}`);
157
-
158
- const afterSaveCandidate = await harness.injectedMemories(projectId);
172
+ const dialogBody = await harness.run("document.getElementById('appDialogBody').textContent");
173
+ assert.ok(dialogBody.includes(CANDIDATE_TEXT), `the review dialog freezes the candidate body: ${dialogBody}`);
174
+ assert.ok(dialogBody.includes(produced.commitSha.slice(0, 8)), `the dialog shows the frozen commit: ${dialogBody}`);
175
+ assert.ok(dialogBody.includes(stored.evidence.entryId), 'the dialog shows the frozen entry');
176
+ // The frozen quote is folded into a details element; a real click unfolds it.
159
177
  assert.ok(
160
- !afterSaveCandidate.some(entry => entry.memoryId === stored.id),
161
- `a saved-but-unconfirmed candidate is never injected: ${JSON.stringify(afterSaveCandidate)}`,
178
+ await harness.run("Boolean(document.querySelector('#reviewForm details.agent-detail summary'))"),
179
+ 'the frozen quote is offered behind a details toggle',
162
180
  );
163
- const stillCandidate = (await harness.productMemories()).find(memory => memory.id === stored.id);
164
- assert.equal(stillCandidate.status, 'candidate', 'the stored memory is still a candidate after 保存候选');
165
- await harness.waitFor(
166
- () => harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT + EDIT_SUFFIX)})`),
167
- 'the edited candidate is listed in the candidate box',
168
- 15000,
181
+ await harness.nativeClick('#reviewForm details.agent-detail summary');
182
+ assert.equal(
183
+ await harness.run("document.querySelector('#reviewForm details.agent-detail').open === true"),
184
+ true,
185
+ 'the frozen source is really visible for a candidate',
169
186
  );
170
- if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem003-saved-candidate.png'));
187
+ const shownQuote = await harness.run("document.querySelector('#reviewForm details.agent-detail').textContent");
188
+ assert.ok(shownQuote.includes(stored.evidence.quote), `the dialog shows the frozen quote: ${shownQuote}`);
189
+ assert.equal(await harness.run("document.querySelector('#appDialogActions button.primary').textContent"), '确认收录', 'the review offers 审核确认 (确认收录)');
190
+ assert.equal(await harness.run("document.querySelector('#appDialogActions button.danger').textContent"), '忽略', 'the review offers 忽略');
191
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem003-review-dialog.png'));
171
192
 
172
- // 审核确认: the dialog shows the frozen source, and confirming confirms it.
173
- await harness.nativeClick(`[data-memory-action="confirm"][data-memory-id="${stored.id}"]`);
193
+ // The step's own path first: leave the review WITHOUT confirming (the old
194
+ // 保存候选 button is gone; the frozen candidate cannot be edited) — the
195
+ // memory has to stay a candidate and stay un-injected, and no PATCH leaves
196
+ // the page at all.
197
+ const patchesBeforeCancel = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).length;
198
+ await harness.nativeClick('#appDialogActions button:not(.primary):not(.danger)');
174
199
  await harness.waitFor(
175
- () => harness.run("document.getElementById('memoryDialog').open === true"),
176
- 'the review dialog is open',
200
+ () => harness.run("document.getElementById('appDialog').open === false"),
201
+ 'cancelling the review closes the dialog',
177
202
  10000,
178
203
  );
179
- const shownEvidence = await harness.run("document.getElementById('memoryEvidence').textContent");
180
- assert.ok(shownEvidence.includes(produced.commitSha), `the dialog shows the frozen commit: ${shownEvidence}`);
181
- assert.ok(shownEvidence.includes(stored.evidence.entryId), 'the dialog shows the frozen entry');
182
- const shownQuote = await harness.run("document.getElementById('memoryQuote').textContent");
183
- assert.ok(shownQuote.includes(stored.evidence.quote), 'the dialog shows the frozen quote');
204
+ assert.equal(
205
+ harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).length,
206
+ patchesBeforeCancel,
207
+ 'cancelling the review sends no PATCH at all',
208
+ );
209
+ const afterCancel = (await harness.productMemories()).find(memory => memory.id === stored.id);
210
+ assert.equal(afterCancel.status, 'candidate', 'the memory is still a candidate after leaving the review unconfirmed');
211
+ assert.equal(afterCancel.text, CANDIDATE_TEXT, 'the candidate text is untouched (frozen in the new review form)');
212
+ const notInjectedAfterCancel = await harness.injectedMemories(projectId);
184
213
  assert.ok(
185
- await harness.run("document.getElementById('memoryEvidenceDetails').hidden === false"),
186
- 'the frozen source is really visible for a candidate',
214
+ !notInjectedAfterCancel.some(entry => entry.memoryId === stored.id),
215
+ `a candidate left unconfirmed is never injected: ${JSON.stringify(notInjectedAfterCancel)}`,
187
216
  );
188
- if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem003-review-dialog.png'));
189
217
 
190
- await harness.nativeClick('#confirmMemory');
218
+ // 审核确认: reopen the review and confirm — the confirmation keeps the
219
+ // frozen source and only changes the status.
220
+ await harness.nativeClick(`#memoryContent [data-action="review-candidate"][data-id="${stored.id}"]`);
191
221
  await harness.waitFor(
192
- () => harness.run("document.getElementById('memoryDialog').open === false"),
222
+ () => harness.run("document.getElementById('appDialog').open === true && document.getElementById('reviewForm') !== null"),
223
+ 'the review dialog is open again',
224
+ 10000,
225
+ );
226
+ await harness.nativeClick('#appDialogActions button.primary');
227
+ await harness.waitFor(
228
+ () => harness.run("document.getElementById('appDialog').open === false"),
193
229
  'the dialog closes after the confirmation',
194
230
  15000,
195
231
  );
196
- const patch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes('/api/engine/memories/')).pop();
232
+ const patch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).pop();
197
233
  assert.ok(patch, 'the shell really patched the candidate');
234
+ assert.deepEqual(patch.body, { status: 'confirmed' }, 'the confirmation only changes the status');
198
235
  assert.equal(patch.status, 200, `the confirmation answers 200: ${JSON.stringify(patch.body)}`);
199
236
  const patchBody = await harness.network.body(patch);
200
237
  assert.ok(patchBody && patchBody.memory, `the confirmation answers with the memory: ${JSON.stringify(patchBody)}`);
201
238
  assert.equal(patchBody.memory.status, 'confirmed', 'the confirmed memory is confirmed');
202
239
  assert.equal(patchBody.memory.evidence.commitSha, produced.commitSha, 'the confirmation keeps the frozen source');
240
+ const confirmToast = await harness.run("document.getElementById('toast').textContent");
241
+ assert.match(String(confirmToast), /已确认/, `the toast reports the confirmation: ${confirmToast}`);
203
242
 
204
243
  const afterConfirm = await harness.injectedMemories(projectId);
205
244
  assert.ok(
@@ -207,8 +246,9 @@ async function main() {
207
246
  `the confirmed memory is injected: ${JSON.stringify(afterConfirm)}`,
208
247
  );
209
248
 
210
- // The confirmed memory is listed in the confirmed tab of the real UI.
211
- await harness.nativeClick('[data-memory-tab="confirmed"]');
249
+ // The confirmed memory is listed in the library tab (旧 confirmed tab) of
250
+ // the real UI.
251
+ await harness.nativeClick('#memoryContent [data-memory-tab="library"]');
212
252
  await harness.waitFor(
213
253
  () => harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
214
254
  'the confirmed memory is listed',
@@ -220,9 +260,9 @@ async function main() {
220
260
  case: 'MEM-003',
221
261
  run: { commitSha: produced.commitSha, memoryCapture: produced.capture },
222
262
  candidate: { id: stored.id, status: stored.status, scopeType: stored.scopeType, scopeId: stored.scopeId, evidence: stored.evidence, sourceEventId: stored.sourceEventId, sourceHash: stored.sourceHash, eligibility: stored.eligibility },
223
- saveCandidateWithoutConfirm: { method: saveCandidatePatch.method, url: saveCandidatePatch.url.replace(harness.base, ''), status: saveCandidatePatch.status, request: saveCandidatePatch.body, response: saveCandidateBody },
224
- injectedBeforeReview: beforeReview.map(entry => entry.memoryId),
263
+ reviewLeftUnconfirmed: { patchesSent: 0, stillCandidate: afterCancel.status, injected: notInjectedAfterCancel.map(entry => entry.memoryId) },
225
264
  confirmation: { method: patch.method, url: patch.url.replace(harness.base, ''), status: patch.status, request: patch.body, response: patchBody },
265
+ injectedBeforeReview: beforeReview.map(entry => entry.memoryId),
226
266
  injectedAfterReview: afterConfirm.map(entry => entry.memoryId),
227
267
  scopeLabel: 'honest: the analysis step is the lane stand-in analyzer, not a model',
228
268
  });
@@ -243,7 +283,15 @@ async function main() {
243
283
  );
244
284
  if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-candidate-before-ignore.png'));
245
285
 
246
- await harness.nativeClick(`[data-memory-action="ignore"][data-memory-id="${toIgnore.id}"]`);
286
+ // 忽略 is the review dialog's danger action now (the old card-level ignore
287
+ // button is gone); it still PATCHes exactly { status: 'ignored' }.
288
+ await harness.nativeClick(`#memoryContent [data-action="review-candidate"][data-id="${toIgnore.id}"]`);
289
+ await harness.waitFor(
290
+ () => harness.run("document.getElementById('appDialog').open === true && document.getElementById('reviewForm') !== null"),
291
+ 'the review dialog is open for the second candidate',
292
+ 10000,
293
+ );
294
+ await harness.nativeClick('#appDialogActions button.danger');
247
295
  await harness.waitFor(
248
296
  () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(IGNORED_TEXT)})`),
249
297
  'the ignored candidate leaves the candidate box',
@@ -255,6 +303,8 @@ async function main() {
255
303
  assert.deepEqual(ignorePatch.body, { status: 'ignored' }, 'the ignore only changes the status');
256
304
  const ignoreBody = await harness.network.body(ignorePatch);
257
305
  assert.equal(ignoreBody.memory.status, 'ignored', 'the ignored memory is ignored');
306
+ const ignoreToast = await harness.run("document.getElementById('toast').textContent");
307
+ assert.match(String(ignoreToast), /已忽略候选。/, `the toast reports the ignore: ${ignoreToast}`);
258
308
 
259
309
  const ignored = (await harness.productMemories()).find(memory => memory.id === toIgnore.id);
260
310
  assert.ok(ignored, 'the ignored memory is still stored');
@@ -34,6 +34,27 @@
34
34
  // analyzer. This case is evidence about the engine's admission, the ignore
35
35
  // action, the persistence of that state and the frozen source — never about
36
36
  // the model's judgement.
37
+ //
38
+ // 迁移说明(五页简化 UI,见 patches/ui-test-mapping-spec.md):
39
+ // * 导入项目已列出的等待:旧首页项目面板(homeContent 含项目名)已删除,
40
+ // 等价为顶栏 #projectSelect 选项里出现项目名(同一 registry projection)。
41
+ // * 候选卡片:[data-memory-card=<id>] → 候选箱行(.row)内的
42
+ // [data-action="review-candidate"][data-id=<id>]「审核」按钮(行存在 ⇔
43
+ // 按钮存在);已确认卡片 → 记忆库 .memory-item 内的
44
+ // [data-action="memory-detail"][data-id=<id>]。
45
+ // * 忽略动作:旧行内 [data-memory-action="ignore"][data-memory-id=<id>] →
46
+ // 新审核流:点候选行的「审核」打开 #appDialog 内 #reviewForm,忽略 =
47
+ // #appDialogActions button.danger(引擎 PATCH {status:'ignored'} 不变)。
48
+ // * 候选计数:旧 #candidateCount(已删除)→ 导航徽标 #memoryCount
49
+ // (overview.totals.candidates;无候选时整个徽标 hidden)。为避免读到
50
+ // overview 尚未加载的空窗,重载后先等首页「待确认记忆」面板渲染完成。
51
+ // * 确认 tab:[data-memory-tab="confirmed"] → [data-memory-tab="library"]
52
+ // (旧 confirmed tab);空态文案「还没有已确认的长期记忆」→「没有匹配的
53
+ // 记忆。」。重载后记忆页先渲染离线横幅,tab 栏要等 boot snapshot 应答
54
+ // 后才存在,点击前先等 tab 栏出现。
55
+ // * 引擎/冻结源/注入断言(productMemories、engineApi、engineStateOnDisk、
56
+ // sourceFingerprint/compareFrozen、injectedMemories)完全不变;本测试
57
+ // 使用真实引擎(dataSchemaVersion 由引擎自报,当前为 4)。
37
58
 
38
59
  const fs = require('node:fs');
39
60
  const path = require('node:path');
@@ -46,18 +67,44 @@ const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_
46
67
  const CANDIDATE_TEXT = 'R3 忽略持久性:对外错误信息使用中文表述,并优先复用已有模块。';
47
68
  const REPO_NAME = 'mem005r3-repo';
48
69
 
49
- async function openMemoryView(harness) {
50
- await harness.nativeClick('nav [data-view="memory"]');
70
+ /**
71
+ * Open a nav view with retries against the known reload commit-gap race
72
+ * (the shell's reload() gate proves the FRESH document, but a CDP click
73
+ * dispatched right at the commit boundary can still be lost — see the
74
+ * parallel-memory-shell.js reload comment). Driver robustness only: the
75
+ * assertion stays "the view is really active".
76
+ */
77
+ async function openView(harness, view) {
78
+ let lastError = null;
79
+ for (let attempt = 0; attempt < 3; attempt += 1) {
80
+ await harness.nativeClick(`nav [data-view="${view}"]`);
81
+ try {
82
+ await harness.waitFor(
83
+ () => harness.run(`document.getElementById('view-${view}').classList.contains('active')`),
84
+ `the ${view} view is open`,
85
+ 5000,
86
+ );
87
+ return;
88
+ } catch (error) { lastError = error; }
89
+ }
90
+ throw lastError;
91
+ }
92
+
93
+ const openMemoryView = harness => openView(harness, 'memory');
94
+
95
+ /** The memory tab bar exists only after the reloaded page read engine data. */
96
+ async function waitForMemoryTabs(harness) {
51
97
  await harness.waitFor(
52
- () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
53
- 'the memory view is open',
54
- 10000,
98
+ () => harness.run("document.querySelector('#memoryContent [data-memory-tab=\"candidate\"]') !== null"),
99
+ 'the memory tab bar is rendered from real engine data',
100
+ 20000,
55
101
  );
56
102
  }
57
103
 
58
104
  async function openCandidateBox(harness) {
59
105
  await openMemoryView(harness);
60
- await harness.nativeClick('[data-memory-tab="candidate"]');
106
+ await waitForMemoryTabs(harness);
107
+ await harness.nativeClick('#memoryContent [data-memory-tab="candidate"]');
61
108
  await harness.waitFor(
62
109
  () => harness.run("document.getElementById('memoryContent').textContent.length > 0"),
63
110
  'the candidate box is rendered',
@@ -65,9 +112,15 @@ async function openCandidateBox(harness) {
65
112
  );
66
113
  }
67
114
 
68
- async function cardPresent(harness, memoryId) {
69
- return harness.run(`Boolean(document.querySelector('[data-memory-card=${JSON.stringify(memoryId)}]'))`);
70
- }
115
+ /** A candidate is offered by the real UI iff its 审核 (review) button exists. */
116
+ const candidateOffered = (harness, memoryId) => harness.run(
117
+ `Boolean(document.querySelector('#memoryContent [data-action="review-candidate"][data-id=${JSON.stringify(memoryId)}]'))`,
118
+ );
119
+
120
+ /** A confirmed memory is listed in the library iff its detail card exists. */
121
+ const libraryCardPresent = (harness, memoryId) => harness.run(
122
+ `Boolean(document.querySelector('#memoryContent [data-action="memory-detail"][data-id=${JSON.stringify(memoryId)}]'))`,
123
+ );
71
124
 
72
125
  async function main() {
73
126
  const harness = await startHarness({ tag: 'mem005r3', evidenceDir: EVIDENCE || undefined });
@@ -76,8 +129,10 @@ async function main() {
76
129
  const repo = makeRepo(harness.fixture, REPO_NAME, { 'README.md': '# R3 忽略持久性夹具\n' });
77
130
  const { projectId, knowledgePath } = await harness.importProject(repo, 'R3忽略持久性');
78
131
  await harness.requestRegistryRefresh();
132
+ // The new home page no longer lists projects; the registry projection is
133
+ // surfaced by the topbar project selector instead.
79
134
  await harness.waitFor(
80
- () => harness.run("document.getElementById('homeContent').textContent.includes('R3忽略持久性')"),
135
+ () => harness.run("document.getElementById('projectSelect').textContent.includes('R3忽略持久性')"),
81
136
  'the imported project is listed',
82
137
  20000,
83
138
  );
@@ -112,7 +167,9 @@ async function main() {
112
167
  assert.ok(before.source.event, 'the frozen conversation event really exists');
113
168
  assert.equal(before.source.event.contentHash, candidate.sourceHash, 'the frozen event hash matches the memory');
114
169
 
115
- // 3. The real UI ignores the real candidate.
170
+ // 3. The real UI ignores the real candidate: the candidate row's 审核
171
+ // button opens the review dialog (#appDialog > #reviewForm) and the
172
+ // danger action sends the same engine PATCH {status:'ignored'}.
116
173
  await harness.reload();
117
174
  await openCandidateBox(harness);
118
175
  await harness.waitFor(
@@ -120,12 +177,18 @@ async function main() {
120
177
  'the candidate is listed in the candidate box',
121
178
  15000,
122
179
  );
123
- assert.equal(await cardPresent(harness, candidate.id), true, 'the candidate really has a card');
180
+ assert.equal(await candidateOffered(harness, candidate.id), true, 'the candidate really has a card (review button)');
124
181
  if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r3-before-ignore.png'));
125
182
 
126
- await harness.nativeClick(`[data-memory-action="ignore"][data-memory-id="${candidate.id}"]`);
183
+ await harness.nativeClick(`#memoryContent [data-action="review-candidate"][data-id="${candidate.id}"]`);
127
184
  await harness.waitFor(
128
- () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
185
+ () => harness.run("document.getElementById('appDialog').open === true && document.getElementById('reviewForm') !== null"),
186
+ 'the candidate review dialog is open',
187
+ 10000,
188
+ );
189
+ await harness.nativeClick('#appDialogActions button.danger');
190
+ await harness.waitFor(
191
+ () => harness.run(`document.getElementById('appDialog').open === false && !document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
129
192
  'the ignored candidate leaves the candidate box',
130
193
  15000,
131
194
  );
@@ -144,47 +207,46 @@ async function main() {
144
207
  20000,
145
208
  );
146
209
  // Re-open the view the way a user does: leave the memory view and come
147
- // back, so the check is not a stale render of the old view.
148
- await harness.nativeClick('nav [data-view="home"]');
149
- await harness.waitFor(
150
- () => harness.run("document.getElementById('view-home').classList.contains('active')"),
151
- 'the home view is open after the reload',
152
- 10000,
153
- );
154
- await harness.nativeClick('nav [data-view="memory"]');
210
+ // back, so the check is not a stale render of the old view. Opening home
211
+ // first also loads the overview, so the #memoryCount badge read below is
212
+ // never taken from an unloaded boot state.
213
+ await openView(harness, 'home');
155
214
  await harness.waitFor(
156
- () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
157
- 'the memory view is re-opened after the reload',
158
- 10000,
215
+ () => harness.run("document.getElementById('homeContent').textContent.includes('待确认记忆')"),
216
+ 'the home overview really answered after the reload',
217
+ 20000,
159
218
  );
160
- await harness.nativeClick('[data-memory-tab="candidate"]');
219
+ await openCandidateBox(harness);
161
220
  await harness.waitFor(
162
- () => harness.run("document.getElementById('memoryContent').textContent.length > 0"),
163
- 'the candidate box is rendered after the reload',
221
+ () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
222
+ 'the candidate box is rendered without the ignored candidate',
164
223
  15000,
165
224
  );
166
225
 
167
226
  // 5. The UI after the reload: the ignored candidate does not come back,
168
- // and it is not presented as a confirmed memory either.
227
+ // and it is not presented as a confirmed memory either. The new UI has
228
+ // no per-row ignore/confirm buttons — the row's only action is 审核
229
+ // (review-candidate), so "no card" also means "no ignore action".
169
230
  const afterReload = {
170
- candidateCardPresent: await cardPresent(harness, candidate.id),
231
+ candidateCardPresent: await candidateOffered(harness, candidate.id),
171
232
  textInMemoryView: await harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
172
- candidateCountBadge: await harness.run("document.getElementById('candidateCount').textContent"),
173
- ignoreButtonPresent: await harness.run(`Boolean(document.querySelector('[data-memory-action="ignore"][data-memory-id=${JSON.stringify(candidate.id)}]'))`),
233
+ candidateBadgeHidden: await harness.run("document.getElementById('memoryCount').hidden"),
234
+ candidateBadgeText: await harness.run("document.getElementById('memoryCount').textContent"),
235
+ ignoreButtonPresent: await candidateOffered(harness, candidate.id),
174
236
  };
175
237
  assert.equal(afterReload.candidateCardPresent, false, 'the ignored candidate has no card after the reload');
176
238
  assert.equal(afterReload.textInMemoryView, false, 'the ignored candidate is not in the memory view after the reload');
177
- assert.equal(String(afterReload.candidateCountBadge).trim(), '', 'the candidate counter is empty after the reload');
178
- assert.equal(afterReload.ignoreButtonPresent, false, 'the ignored candidate offers no ignore button after the reload');
239
+ assert.equal(afterReload.candidateBadgeHidden, true, 'the candidate counter badge is hidden after the reload (no candidates left)');
240
+ assert.equal(afterReload.ignoreButtonPresent, false, 'the ignored candidate offers no ignore (review) action after the reload');
179
241
 
180
- await harness.nativeClick('[data-memory-tab="confirmed"]');
242
+ await harness.nativeClick('#memoryContent [data-memory-tab="library"]');
181
243
  await harness.waitFor(
182
- () => harness.run("document.getElementById('memoryContent').textContent.length > 0 || document.querySelectorAll('[data-memory-card]').length === 0"),
183
- 'the confirmed tab is rendered after the reload',
244
+ () => harness.run(`(!document.getElementById('memoryContent').textContent.includes(${JSON.stringify('知识引擎暂时不可用')}) && (document.getElementById('memoryContent').textContent.includes('没有匹配的记忆。') || document.querySelectorAll('#memoryContent .memory-item').length > 0))`),
245
+ 'the library tab (old confirmed tab) is rendered after the reload',
184
246
  15000,
185
247
  );
186
248
  const confirmedTab = {
187
- cardPresent: await cardPresent(harness, candidate.id),
249
+ cardPresent: await libraryCardPresent(harness, candidate.id),
188
250
  textPresent: await harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
189
251
  };
190
252
  assert.equal(confirmedTab.cardPresent, false, 'the ignored candidate is not shown as a confirmed memory');