feat(message-service): add getPathThrough for branch-aware path queries#14739
Open
feat(message-service): add getPathThrough for branch-aware path queries#14739
Conversation
`getPathThrough(topicId, nodeId)` returns the conversation path passing through `nodeId`, descending into its subtree to the leaf with the greatest `created_at` (skipping deleted nodes). If `nodeId` has no live children, the leaf is `nodeId` itself. This is the read-only counterpart to setActiveNode's removed descend mode: it lets navigation UI compute "the path through this sibling" without persisting to topic.activeNodeId. Callers that want to persist the result follow up with setActiveNode on the returned leaf. Exposed as GET /topics/:topicId/path?nodeId=X via DataApi. Tests cover: leaf-of-subtree selection, deleted-child skip, leaf-itself edge case, global newest descent, NOT_FOUND for unknown ids, and cross-topic isolation. Signed-off-by: suyao <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Signed-off-by: suyao <[email protected]>
Member
|
Note This comment was translated by Claude. What the current code does: starting from nodeId, it traverses upward to find the root, and downward to find the latest child node until reaching a leaf node, forming a single path to return. The code implementation itself is largely fine. However, the actual product requirements and interactions for such a path are extremely unclear (I cannot think of any use scenario for it). Therefore, the source of actual requirements and use scenarios need to be clarified first before we can determine whether the code implementation is correct. Original Content当前代码做的事情:从nodeId向上找到root,从nodeId向下寻最新子节点一直到叶子节点,组成单一路径返回。其代码实现本身问题不大。 但是,对于这样的路径,其在产品中实际的需求和交互是什么,是极其不明确的(我想不到其使用场景)。 因此,需要先澄清实际需求来源和使用场景,才能明确代码实现是否正确。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
Branch-aware navigation in the chat tree had no read-only way to compute "the path through this sibling". The previous workaround was a
descendmode onsetActiveNode, which both resolved the path AND persisted it totopic.activeNodeId— unsuitable for hover/preview UI.After this PR:
MessageService.getPathThrough(topicId, nodeId)returns the conversation path passing throughnodeId, descending into its subtree to the leaf with the greatestcreated_at(skipping deleted nodes). IfnodeIdhas no live children, the leaf isnodeIditself. Pure read — does not touchtopic.activeNodeId. Callers that want to persist the result follow up withsetActiveNodeon the returned leaf.Exposed as
GET /topics/:topicId/path?nodeId=Xvia DataApi.Fixes #
Why we need it and why it was done in this way
The following tradeoffs were made:
nodeIdis unknown or belongs to a different topic — surfaces caller bugs early instead of silently returning[].The following alternatives were considered:
setActiveNodewith a non-persisting flag — rejected; mixing read and write semantics on the same method was the original confusion.Links to places where the discussion took place: N/A
Breaking changes
None.
Special notes for your reviewer
This commit was cherry-picked out of
DeJeune/ai-serviceso thegetPathThroughAPI can land onv2independently of the larger AI service work. The receiving callers (SiblingNavigator/MessageGroupwiring) remain onDeJeune/ai-serviceand will rebase once this lands.The conflict during cherry-pick was a co-located
reserveAssistantTurntest from a different commit on the source branch — dropped from this PR. Also adapted the test seed toorigin/v2's topic schema (noorderKeycolumn on v2).Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note