Repository navigation
fix(plugin-chatbot): draft card Publish (N) refreshes after a publish it did not run - #26539
Merged
Merged
Conversation
…adata pulse The draft tool card's Publish (N) count was fetched once per toolCallId and only refreshed by the card's own publish/discard, so a publish from the chat banner left a stale Publish (N). ChatbotEnhanced takes an optional subscribeMetadataRefresh prop and re-reads every on-screen draft package's count through fetchPendingDraftCount on each pulse; AiChatPage passes the assistant bus's subscriber. Claude-Session: https://claude.ai/code/session_01ADHkmRirVxTgwfMT99xmtc Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
席位核对 · ACCEPT · seat
|
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.
Requested by Steve · project thread
Fixes #26471
Clause-②: no
Metadata-protocol: none
维护者速读
ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx新增的订阅 effect;ui/packages/app-shell/src/console/ai/AiChatPage.tsx的两行接线;新测试文件。cd ui && pnpm exec vitest run packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.pendingCountPulse-26471.test.tsx,预期 2 条全绿。What changes
ChatbotEnhanced(plugin-chatbot) takes a new optional propsubscribeMetadataRefresh?: (listener) => unsubscribe, the same signature as app-shell's assistant-bussubscribeMetadataRefresh. The draft card's pending-count block records every package a draft card is bound to; one effect subscribes to the pulse and, on each pulse, re-reads those packages through the existingrefreshPendingCount/fetchPendingDraftCount. No second count source. The effect is keyed on the subscriber and the fetcher, so it subscribes once and unsubscribes on unmount; a re-render fetches nothing.AiChatPage.tsx(app-shell), the only host that wiresfetchPendingDraftCount, passes the bus'ssubscribeMetadataRefresh(2 lines: the existing assistantBus import and the prop at theChatbotEnhancedmount).src/assistant/assistantBus.ts), and app-shell depends on plugin-chatbot, so importing it from plugin-chatbot would be a dependency cycle. The seat widened the file surface to those 2 app-shell lines (option A).26471-draft-card-pending-count-pulse.md: patch for@object-ui/plugin-chatbotand@object-ui/app-shell.Tests
ui/packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.pendingCountPulse-26471.test.tsx: (1) a card shows 发布 (2); a re-render fetches nothing; the pulse fires, the fetch now answers 0, and the card no longer offers 发布 (Published shown); (2) unmount unsubscribes, and a later pulse fetches nothing.scripts/ablation-replace.mjs(anchor 1 → 0, blob f6afd3b0aaa4 → 778b78f95853). Both new tests went red ("expected vi.fn() to be called 2 times, but got 1 times"; "expected +0 to be 1"). Restored: blob == HEAD andgit diff HEADempty.Acceptance notes
Verification
All on head
ecc34812.Local runs
cd ui && pnpm exec vitest runnew test +ChatbotEnhanced.changeCardV2-12894+ChatbotEnhanced.draftPreviewAny-12968: Test Files 3 passed, Tests 27 passed (lock VERDICT command-exit 0).pnpm --filter @object-ui/plugin-chatbot test --maxWorkers=2: Test Files 85 passed, Tests 807 passed (VERDICT command-exit 0).console/ai/__tests__/AiChatPage.*files: Test Files 21 passed, Tests 98 passed (VERDICT command-exit 0). The full app-shell suite is left to CITest UI.pnpm --filter @object-ui/plugin-chatbot type-check: exit 0.pnpm --filter @object-ui/app-shell type-check: exit 0 (after building@object-ui/app-shell^...).node scripts/pm/dispatch-gates.mjs --commands: 35 families, every one run with exit 0;--ranreconciliation: 35 derived, 35 run, 0 NOT-MEASURED, 0 UNRUN (a derived zero, all exit codes recorded).Generated by Claude Code