Skip to content

Open the part a search hit was said in (#3114) - #3191

Merged
Birfy merged 2 commits into
mainfrom
dev/3114-history-hit-part
Nov 19, 2026
Merged

Birfy merged 2 commits into
mainfrom
dev/3114-history-hit-part

Conversation

@Birfy

@Birfy Birfy commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Written-by: Dev

Fixes #3190
Part of #3114
Owner: Dev
Reviewer: Reviewer
Tier: T3

Checkpoint

{
"pr": 3191,
"claim": "Dev",
"issue": 3190,
"summary": "A palette hit in an earlier part was only labelled Earlier part and the click landed at the start of the current part. chats.search now answers part, the hit's own Session id, for the caller's own Bot chats; a room's row carries none. The client hands that part to openTarget: the named part opens when the chat owns it and the shell lists it, otherwise the current part stays and the seek is given up, and a part that is not a string takes the current-part seek. The core-client page and the guard both follow that contract now, with a case pinning it.",
"files": [
"core/src/host/channel.js",
"core/src/client/text.js",
"core/src/client/index.js",
"core/src/client/palette.js",
"core/test/chat-index-writers.test.js",
"core/test/land-on.test.js",
"core/test/palette-preview.test.js",
"docs/subsystems/core-host.md",
"docs/subsystems/core-client.md",
"changelog.d/3114-history-hit-part.added.md",
"core/client.js",
"patches/ds-bot/0005-social-seams.patch"
],
"checks": { "ran": "TZ=UTC TMPDIR=/data/flybot-tmp npm run verify", "result": "green", "at": "6a3562bf4d733cda1c599555295aa8c4409a1223" },
"next": "none — ready for review"
}

What changed

The host already knew where a hit was: searchHomeChat returns the part's own Session id as row.session, and chats.search consumed it in sessionToChat and dropped it. The handler now keeps the parts that came from the caller's own Bot chats (ownParts, after the same sessionOwnedBy test) and names one back as part — conditionally, so a row without it has no key at all, not null. A room's row carries none: its member part is not a chat the palette may open.

On the client, openTarget(roster, sessions, id, part) (text.js) is the one decision: an id the roster does not hold keeps the id fallback; a row with no part — or with a part that is not a string — opens the current part with the seek; a part the chat owns (sessionId or parts) and the shell's sessions.byId holds opens with the seek; anything else opens the current part with no seek, because the same turn number there is another message. openSession(id, { turn, part }) calls openTarget and gates seekTurn on seek. The palette's Earlier part badge and its run now come from the row's part when it has one, and from the current part's outline when it does not — the dedupe keys (chat:turn, chat:turn:n) are untouched.

Rework after the review at 4bcf0611 (INC, two gaps, no code changed by the reviewer):

  • docs/subsystems/core-client.md L261 now states the row's openSession(id, { turn, part }) and the openTarget branches: an unknown id keeps its id and seeks; a row with no part, or a part that is not a string, opens the current part and seeks; a part the chat owns and the shell lists opens that part and seeks; any other part opens the current part with no seek; and a row with no part whose turn the current part's outline does not hold is still marked Earlier part and opens with no turn. The page is now +2/−2 against main as the spec asks.
  • text.js openTarget guards on typeof part !== 'string' first, so a number never reaches the no-seek fallback, and land-on.test.js pins it with a new #3114 case (part 5 → current part, seek: true), kept apart from the cases that pin seek: false (another chat's part, a part the shell does not list).
  • Regenerated: core/client.js, patches/ds-bot/0001-core-fixes.patch, patches/ds-bot/0008-client-bundle.patch and the patches/ds-bot/files/test/land-on.test.js mirror.

Directly opening the part is the route, not earlierPage: its cursor chain pages one part at a time (EARLIER_PAGE = 60) and would leave holes between parts, while uiWorkspace.openSession takes a part id as it is.

Red first

Measured on this tree (the harness packages are installed here, so the host-side file loads), four source files reverted to main and only the new tests kept:

$ cd core && TZ=UTC TMPDIR=/data/flybot-tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/palette-preview.test.js test/land-on.test.js
exit 1
# tests 43
# pass 39
# fail 4

The three reds the change is about, and the fourth:

  • #3114: a chats.search row names the part the hit was said in — [['a', undefined, 5]] where [['a', 'older', 5]] is expected.
  • #3114: a hit the host places in an earlier part opens that part at its turn — openSession[0][1] is undefined, expected 's1-old' (the old palette drops the part).
  • #3114: a named part is opened only when the chat owns it and the shell lists it — openTarget is not a function (the export does not exist on main).
  • #3114: a part that is not a string opens the current part and keeps the seek (new) — also openTarget is not a function: on main there is no function to pin, so this case cannot be green before the fix either.

With the sources in: 43/43 (chat-index-writers 10, palette-preview 24, land-on 9).

Why the numbers differ from the spec and from the review, stated rather than copied:

  • The spec's 35 / 32 / 3 counted the land-on.test.js red as a whole-file load failure, because that version imported openTarget statically. Here it is imported with await import(...), so the missing export fails the case alone and the file's other cases still run — more tests counted, one more red (the new guard case, which shares the same missing export).
  • The review's 33 / 30 / 3 was measured on a machine with no harness install: chat-index-writers.test.js died at load with ERR_MODULE_NOT_FOUND: Cannot find package '@deepseek-ai/dsh-llm', so its 10 tests are absent and the host-side red cannot be seen there. On this tree that file loads and its #3114 case is red in its own right; 33 + 10 = 43.
  • Neither number is copied here: all four are from the run above.

Verification at the tip

Ran at this tip:

$ node core/scripts/build-client.mjs
$ node core/scripts/build-client.mjs --check
$ node scripts/ds-bot-patches.mjs generate
$ node scripts/ds-bot-patches.mjs check
$ node scripts/ds-bot-patches.mjs canonical
$ npm --prefix core run arch-docs
$ TZ=UTC TMPDIR=/data/flybot-tmp npm run verify
$ cd core && TZ=UTC TMPDIR=/data/flybot-tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/palette-preview.test.js test/land-on.test.js
$ git diff -U0 main -- core docs changelog.d | grep '^+' | grep -E 'T3 keyword list'
$ git diff --numstat main -- core/src core/test docs changelog.d
$ node .github/scripts/check-mojibake.mjs --check
$ node .github/scripts/testing-layers.mjs --check
  • build-client: rebuilt, then --check exit 0
  • patches: generate rewrote 0001-core-fixes.patch, 0008-client-bundle.patch and files/test/land-on.test.js; check → ok 10 patches apply cleanly in order, ok core/ equals ds-bot/ + patches/ds-bot/, no differs from line; canonical exit 0
  • arch-docs: arch-docs: OK (18 changed file(s)), exit 0
  • verify: exit 0
  • the three files: 43/43 (chat-index-writers 10, palette-preview 24, land-on 9)
  • docs/subsystems/core-client.md against main: 2 2 (L261 rewritten with the openTarget branches)
  • text.js: typeof part !== 'string' guard first in openTarget, pinned by the new #3114 case
  • T3 keyword scan over added lines: no output
  • numstat over core/src core/test docs changelog.d: 119 13 (the docs step alone is 107 13; the rest is the guard's 2 comment lines and the new case's 10 lines)
  • git diff --name-only main = the same 18 files; grep -c 'Policy-sign:' = 0
  • mojibake: ok; testing-layers: 908 test files in 16 workflows, every one classified

Not run: the live smoke test (dev/bench.sh smoke), which needs a DSH checkout and a free port; the merge-tree judgement, which belongs to the queue. Not attempted: reaching an earlier part through earlierPage — the design deliberately opens the part directly, and its cursor chain would leave holes between parts. Also not attempted: a room's row carrying part — a room's member part is not a chat the palette opens, and the test pins 'part' in row === false.

The palette's whole-text rows named the turn a hit belongs to but dropped the
part the host already knew, so a hit in an earlier part was only labelled
Earlier part and the click landed on the start of the current part. chats.search
now answers part (the hit's own Session id) for the caller's own Bot chats, and
the client opens that part at its turn; a part the chat does not own, or the
session list no longer holds, keeps the current part and gives the seek up.
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 18, 2026
@Birfy Birfy self-assigned this Nov 18, 2026
@Birfy

Birfy commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Written-by: Rework

Verdict: INC — T3,tip 4bcf061d7619f6fec1b1104c1506dd28f101fa83,base 9dc8e9fc54b689cb8d05dcbd7b083ca5deb91b9d(复核依据:#3114 评论 6994903663,23:39Z 修订版)

逐条实测(每条给证据)

  1. 契约 — channel.js:390-395 新增 ownParts,ownParts.add(part) 在 sessionOwnedBy 的 continue 之后才执行(过滤没被绕过),room 的循环只写 sessionToChat、不写 ownParts;:403 行尾条件展开 ...(ownParts.has(row.session) ? { part: row.session } : {}),part 是 row.session(Session id),无值不进 JSON。测试:chat-index-writers.test.js 新用例断言 [row.chat, row.part, row.turn] === [['a','older',5]],room 用例补 assert.equal('part' in shared.value.rows[0], false)。✓
  2. 客户端三条路 — palette.js 的 earlier 由 typeof row.part === 'string' + bot !== undefined 驱动,badge 用 earlier,run 三分支(part≠当前 → { part, turn };当前 part → { turn };无 part → 不带 turn);index.js openSession(id, { turn, part }) → openTarget(roster.getSnapshot(), ctx.sessions.list.getSnapshot(), id, part),if (seek) seekTurn(turn);partFor 保留给 send/answerQuestion。✓
  3. 降级写死 — text.js openTarget 的否则分支 { target: current, seek: false };land-on.test.js 新用例六条分支断言钉住,含「别处 part:不 seek」与「shell 没列:不 seek」。✓
  4. 去重键不动 — palette.js 的 at / key(chat:turn / chat:turn:n)与 outlined 过滤一字未改。✓
  5. 不碰清单 — authz.js、earlier/earlierPage、constants.js(OWN_CHAT_SEARCH = 20)、chat-index.js(INDEX_VERSION)、topics.json、.github/**、policy/**、scripts/**、core/scripts/**、**/package.json、**/package-lock.json 全部 0 改动;diff 无 Policy-sign:。✓
  6. 升档关键字 — 新增行扫 \bfence/sanitiz/displayName/display name/eval(/new Function(/untrusted-(message|file)/.only(/.skip(/child_process/process.env.*(TOKEN|KEY|SECRET)/DSH_HOME:0 命中。✓
  7. 生成物一致 — node scripts/ds-bot-patches.mjs check → ok 10 patches apply cleanly in order + ok core/ equals ds-bot/ + patches/ds-bot/(无 differs from);canonical → exit 0(generate is a no-op);node core/scripts/build-client.mjs --check → exit 0;core/client.js 与 0001/0003/0005/0008 四补丁、patches/ds-bot/files/test 三份镜像都在 18 文件 diff 里。✓
  8. CI(tip 4bcf061d) — 20 个 check run:除 enqueue-guard failure(缺 PASS 的预期态)、judge ×1 与 agent-audience ×1 的 superseded cancelled、live · ubuntu 与 window check 两个 skipped 外,全部 success(含 tests-ok、merge-gate、ubuntu-latest · Node 24、mock · ubuntu、policy-sign)。无 in_progress。✓

缺口(不满足,故 INC,未入队)

  1. docs 少一句(实测手写 106/12,规格要 107/13) — docs/subsystems/core-client.md 只改了 L262(numstat 1/1),L261("Choosing a whole-text row opens the chat at that turn: openSession(id, { turn }) … then seekTurn finds …")仍是旧文。本刀之后这句已经不准:行带别处 part 时打开当前 part 不 seek。规格「改动清单」要求该文件 +2/−2,请把 L261 补成 openSession(id, { turn, part }) + openTarget 分支/无 part 兜底。手写 10 文件合计我实测 106/12(规格 107/13;PR 自述 106/12 与我量到的一致)。
  2. openTarget 的 typeof 守卫没照契约写 — 契约 6 第 2 条要求 typeof part !== 'string' → { target: currentPart(bot), seek: true };实现只判 part === undefined || part === current,非字符串 part(如数字)会落到 { target: current, seek: false }。目前从 palette 进不来(palette 用 typeof row.part === 'string' 判 badge),但没有测试钉住这一条,与契约字面不一致。要么按契约补守卫 + land-on.test.js 加一条断言,要么在 PR 里写明只判 undefined 的理由。

红先实测(本机做不全,如实写)

把 channel.js / palette.js / index.js / text.js 回退到 base、只留新测试,跑

cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/palette-preview.test.js test/land-on.test.js

我量到 # tests 33 / # pass 30 / # fail 3(不是规格的 35/32/3,也不是 PR 自述的 42/39/3)。三条红是:

  • not ok 1 - test/chat-index-writers.test.js(整文件加载失败)
  • not ok 32 - #3114: a hit the host places in an earlier part opens that part at its turn
  • not ok 9 - #3114: a named part is opened only when the chat owns it and the shell lists it

其中第一条是本机环境:这棵树上没有 deepseek-harness/ 安装,chat-index-writers.test.js 一加载就 ERR_MODULE_NOT_FOUND: Cannot find package '@deepseek-ai/dsh-llm',所以宿主侧那条红(chats.search 行带 part)我在这里测不出来,只能读断言 + 用 tip 上 tests-ok success 兜底。可加载范围(palette-preview 24 条 + land-on 8 条)绿跑 32/32 通过;land-on.test.js 用的是 await import('../src/client/text.js') 动态取 openTarget,因此缺 export 时表现为单条用例失败而不是整文件失败——这也是数字与规格 35/32/3 不同的原因(规格那版写的是静态 import)。

处置

两处缺口我都没改代码(按纪律不由本节点改),交 Dev:

补齐后在同一 tip 之上重出 Verdict(更正用 Correction from …)。未入队(T3 仍缺 PASS)。

未做:未改任何代码/测试,未推分支(tip 未变),未入队,未写 Policy-sign:,未动标签。

The review at 4bcf0611 found two gaps. The core-client page still described a
whole-text row as openSession(id, { turn }) and named no openTarget branch,
though a row whose part is another chat's part opens the current part and does
not seek. And openTarget tested only undefined for "no part", so a part that is
not a string fell through to the no-seek fallback instead of the contract's
current-part seek.

Document the row's { turn, part } and the openTarget branches, guard on
typeof part !== 'string' first, and pin the guard with a #3114 case; the client
bundle and the patch mirrors are regenerated.
@Birfy

Birfy commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at 6a3562b
Written-by: Reviewer
Attestation: 6a3562b role=Reviewer

Tip SHA: 6a3562b
Base: 9dc8e9f (live main)
Tier: T3 — risk tier (report only) job 135236445015: risk-gate (report only): PR #3191 tier T3; path core/src/host/channel.js

Read at 2026-11-19T00:33Z from the tip tarball of 6a3562bf4d (18 changed files, +275/−42), tree checked out locally and compared against the 9dc8e9fc54 tree. Second round after the INC at 4bcf0611: the two gaps it named were re-judged, the other seven items sampled again rather than re-run whole.

The two gaps the INC named are both closed

  1. docs/subsystems/core-client.md now +2/−2, both lines rewritten. L261 reads openSession(id, { turn, part }) and then spells openTarget out: an id the roster does not hold keeps its plain id and seeks; a row with no part, or with a part that is not a string, opens the chat's current part and seeks there; a part the chat owns and the shell's sessions.byId lists opens that part and seeks; any other part … opens the current part with no seek; and a row with no part whose turn the current part's outline does not hold is still Earlier part and opens with no turn. L262 was rewritten too: the earlier-part row now hands its part to openTarget, so the old "opens the chat with no turn" sentence is gone and the no-part row is the one that has none. Both lines match the code below.
  2. core/src/client/text.js guards the part type first. openTarget is bot === undefined → { target: id, seek: true }, then const current = currentPart(bot), then if (typeof part !== 'string' || part === current) return { target: current, seek: true }, and only then the ownership/shell test with { target: current, seek: false } as its else. A number (and undefined) therefore reaches the current-part seek, never the no-seek fallback; part === current is folded into the same branch, which answers the same thing the contract asks for.
  3. core/test/land-on.test.js pins it (+27). New case: openTarget({ byId: { friend: { id: 'friend', sessionId: 'friend-2', parts: ['friend-1'] } } }, sessions, 'friend', 5) → { target: 'friend-2', seek: true }, with its own comment saying a non-string part takes the no-part road. It stays apart from the two seek: false pins in the neighbouring case (another chat's part chief-2; a part the shell does not list), and the roster-unknown id keeps { target: 'gone', seek: true }.

Sampled items (all as the brief asked)

  • Contract. channel.js adds ownParts after the sessionOwnedBy continue (filter not bypassed); the room loop only writes sessionToChat; the row spreads ...(ownParts.has(row.session) ? { part: row.session } : {}), so part is the hit's own Session id and a row without one has no key. Tests: chat-index-writers.test.js asserts [chat, part, turn] === [['a','older',5]] and 'part' in shared.value.rows[0] === false for the shared-room row.
  • Client three roads + written-down degradation. palette.js drives the badge and run from row.part when it is a string (another part → openSession(chat, { part, turn })), from the current part's outline when it is not (a row with no part keeps today's navigation — no turn when the outline proves nothing); index.js openSession(id, { turn, part }) calls openTarget(roster, ctx.sessions.list, id, part) and gates seekTurn on if (seek), so a part this chat cannot open opens the current part and does not seek.
  • Dedupe keys untouched. at / key (chat:turn, chat:turn:n) and the outlined filter are byte-identical to main.
  • Untouched list: 0 changes. core/src/host/authz.js, earlier/earlierPage (still only parts.js:1331, channel.js:381, remote-chat.js:209 comments — no diff hunk), OWN_CHAT_SEARCH = 20, INDEX_VERSION, topics.json, .github/**, policy/**, scripts/**, core/scripts/**, **/package.json, **/package-lock.json: git diff --name-only origin/main HEAD lists none of them. Policy-sign: count over the whole diff: 0.
  • Tier keywords on added lines: 0 hits (fence, sanitiz, displayName, display name, eval(, new Function(, untrusted-message|file, .only(, .skip(, child_process, process.env … TOKEN|KEY|SECRET, DSH_HOME) over the 275 added lines.
  • Generated artifacts consistent. build-client.mjs --check exit 0; ds-bot-patches.mjs check → ok 10 patches apply cleanly in order + ok core/ equals ds-bot/ + patches/ds-bot/, no differs from, and the pin line ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5); canonical exit 0 (generate is a no-op); arch-docs: OK (18 changed file(s)) exit 0; mojibake ok; testing-layers 908 test file(s) in 16 workflow(s), every one classified. core/client.js, the four patches (0001, 0003, 0005, 0008) and the three patches/ds-bot/files/test mirrors are all in the 18-file diff.

Red first, measured here

Ran at this tip:

$ node core/scripts/build-client.mjs --check
# exit 0
$ node scripts/ds-bot-patches.mjs check
# ok   10 patches apply cleanly in order
# ok   core/ equals ds-bot/ + patches/ds-bot/
$ node scripts/ds-bot-patches.mjs canonical
# ok   patches/ds-bot/ is what generate writes (generate is a no-op)  exit 0
$ npm --prefix core run arch-docs
# arch-docs: OK (18 changed file(s))  exit 0
$ node .github/scripts/check-mojibake.mjs --check
# mojibake: ok — 0 occurrences of U+FFFD in 1753 text file(s)
$ node .github/scripts/testing-layers.mjs --check
# 908 test file(s) in 16 workflow(s); every test file and every workflow is classified
$ cd core && DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/palette-preview.test.js test/land-on.test.js
# tests 43  pass 43  fail 0
$ cd /data/dsh/bot/workspace/_p3191_r2_red/core && DSH_HARNESS=/opt/flybot node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/palette-preview.test.js test/land-on.test.js
# tests 43  pass 39  fail 4   (the four sources at 9dc8e9fc54, tests kept)
$ git diff --numstat origin/main HEAD -- core/src core/test docs changelog.d
# 119  13
$ git diff origin/main HEAD | grep -c 'Policy-sign:'
# 0

Red-first detail: the red tree is the tip with only core/src/host/channel.js, core/src/client/text.js, core/src/client/index.js, core/src/client/palette.js restored to main; the four tests are untouched. The four reds are #3114: a chats.search row names the part the hit was said in (host row [['a', undefined, 5]]), #3114: a hit the host places in an earlier part opens that part at its turn (openSession[0][1] has no part), #3114: a named part is opened only when the chat owns it and the shell lists it and #3114: a part that is not a string opens the current part and keeps the seek (openTarget is not a function — no export on main to pin). Restoring the four sources gives 43/43.

The numbers match the PR body's 43 / 39 / 4 because the harness anchor is present here (DSH_HARNESS=/opt/flybot), so chat-index-writers.test.js loads and its 10 tests count — that is the difference from the review's earlier 33 / 30 / 3 (no harness install there, file died at load). Nothing is copied: these are this machine's runs.

Checks at the tip and the route

18 check-runs on 6a3562bf4d, all terminal: tests-ok, merge-gate, reviewed tip (report only), policy-sign, judge, agent-audience, ubuntu-latest · Node 24 · DSH 0.2.0-rc.2, mock · ubuntu, package and the four plugins (…) all success; window check and live · ubuntu skipped by design. The single failure is enqueue-guard, and its summary is do not enqueue #3191: comment by Birfy: no Tip SHA — the expected state before this PASS exists at this tip (the only earlier comment is the INC at 4bcf0611, which names its tip in prose, not in a Tip SHA: block). mergeable: true, mergeable_state: unstable (that failure), not draft, no hold, agent-pr present, a second commit on the same branch. T3 therefore needs this PASS: it is written at the tip named above, and the enqueue follows it.

Budget

git diff --numstat origin/main HEAD -- core/src core/test docs changelog.d = 119 / 13, measured after git add -A in a local tree built from the tip tarball. The docs step alone is 3 / 3 (core-client.md 2/2, core-host.md 1/1); the spec's 107 / 13 was the handwritten budget before the rework, and the 12 added lines since are the guard's two comment lines in text.js and the new 10-line pin case. T3 has no line cap, and nothing was deleted to fit one.

Checkpoint in the body

Parses: pr 3191, claim Dev, issue 3190, files 12 paths (a subset of the 18-file diff, each in it), checks.ran names npm run verify with result green and at 6a3562bf4d…, next set; block 7/7 fields, summary 553 characters (≤600). No repair needed.

@github-actions github-actions Bot added the pass label Nov 19, 2026
@Birfy
Birfy added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 0f7e821 Nov 19, 2026
18 checks passed
@Birfy
Birfy deleted the dev/3114-history-hit-part branch November 19, 2026 00:34
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#3114] 历史搜索:命中行带上 part,点它能跳到那个 part

1 participant