Skip to content

🧯 refactor: Retire Host Tool Outcome, Sibling, Branch Tail and Approval Members - #17867

Open
berry-13 wants to merge 3 commits into
refactor/chat-code-sendfrom
refactor/chat-host-rules
Open

berry-13 wants to merge 3 commits into
refactor/chat-code-sendfrom
refactor/chat-host-rules

Conversation

@berry-13

@berry-13 berry-13 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

ChatHost and SteerHost still asked the app for behavior a consumer of @librechat/chat should not have to supply: how a message's tool outcomes are mapped, which sibling is selected under a parent, which message is the tail of the branch on screen, and which code approval mode a queued turn runs under. This is the next link after #17797: the package now owns each of them and the host keeps only reads of app state.

The tool outcome rules and the attachment merge they read move into core/parts. ChatHost loses getMappingOptions, useSetSiblingIdx, useLatestMessage and useLatestMessageId; the package selects the sibling through its own atom and reads the tail through useBranchTail. SteerHost.useCodeApprovalMode becomes useCodeApprovalInputs, a storage read, and the steer path derives the mode with resolveCodeApprovalModes. SteerHost.useLatestMessage becomes useRouteConversationId. Behavior is unchanged.

How it works

useChatHelpers      useBranchTail(root, queryId)      package, reads the message query cache
useSteering         resolveCodeApprovalModes(inputs)  package, inputs from host.useCodeApprovalInputs
toView              getMappingOptions                 package core/parts

Type of change

  • Refactor
  • Tests / tooling / CI

Testing

Tested environments/configuration:

  • Mock e2e harness (in-process fake model), desktop light/dark and mobile via reviewctl verify

Automated tests:

  • New packages/chat/src/react/__tests__/latest.spec.tsx covers the default tail, a selected sibling and an absent query id
  • useSteering.spec.tsx now feeds raw approval inputs and asserts the queued mode, including the without-attached gate and that the saved conversation id wins over the route
  • npx jest in packages/chat: 174 suites, 2,601 tests pass; client hooks, utils and chat specs: 123 suites, 2,832 tests pass; npx tsc --noEmit in packages/chat and client: clean

Screenshots / recordings

No user-facing change.

Risk / compatibility

Hosts of the unreleased package lose the four ChatHost members and gain the SteerHost replacements above. This branch conflicts with current dev in the attachment helpers, which dev moved into the package; it will be rebased once #17797 merges.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • Required documentation PR: N/A

The package now owns the tool outcome rules and the attachment merge they
read, selects the visible sibling through its own atom, and derives the steer
path's code approval mode from raw inputs. ChatHost loses getMappingOptions and
useSetSiblingIdx; SteerHost.useCodeApprovalMode becomes useCodeApprovalInputs.
The tail of the branch on screen becomes package logic, read through
useBranchTail. ChatHost loses useLatestMessage and useLatestMessageId;
SteerHost.useLatestMessage becomes the useRouteConversationId adapter.
@berry-13 berry-13 added 🔨 refactor Code cleanup without new features 🧪 tests Unit/integration test updates labels Nov 6, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T18:30:30.894310Z 312e678 New commits
🔒 Security Review ✅ Completed 2026-11-06T16:35:20.935098Z a713c16 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a713c163ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +177 to +179
mockTailQueryKeys.push(key[1]);
const tail = mockLatestMessage == null ? [] : [mockLatestMessage];
return { data: select(mockLatestMessage === undefined ? (mockMessages ?? []) : tail) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exercise steering with a real React Query cache

The new React Query mock returns the same messages for every query key and bypasses cache subscriptions, so the steering tests cannot detect reading another conversation's messages or failing to update the branch anchor after history hydration. These are important behaviors of the branch-tail integration being changed here. This also violates AGENTS.md's testing requirement to use real logic and mock only external HTTP APIs or uncontrollable services. Use a real QueryClientProvider, seed distinct conversation caches, and update the cache to verify that steering follows the correct branch.

AGENTS.md reference: AGENTS.md:L211-L214

Useful? React with 👍 / 👎.

The steering spec mocked React Query to return one message list for every key, so
it could not notice a read of another conversation's cache or a tail that stops
following the cache. It now provides a real QueryClient, seeds each conversation
key, and covers the route and another chat holding different tails and a cache
that hydrates after mount.
@berry-13
berry-13 added this pull request to stack #17871 November 6, 2026 18:08
Copilot AI balanced review requested due to automatic review settings November 6, 2026 18:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 refactor Code cleanup without new features 🧪 tests Unit/integration test updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants