refactor: shared webview IPC helpers with enforced exhaustiveness#911
Draft
EhabY wants to merge 2 commits intofeat/speedtest-visualization-888from
Draft
refactor: shared webview IPC helpers with enforced exhaustiveness#911EhabY wants to merge 2 commits intofeat/speedtest-visualization-888from
EhabY wants to merge 2 commits intofeat/speedtest-visualization-888from
Conversation
781bd7a to
8c6204a
Compare
df4afc3 to
abfbedc
Compare
4e7be71 to
973e57a
Compare
abfbedc to
f890b00
Compare
973e57a to
83a1ca1
Compare
f890b00 to
30594e4
Compare
83a1ca1 to
1ce0401
Compare
…ness - Add isIpcCommand/Request, notifyWebview, dispatchCommand/Request, and onWhileVisible in src/webviews/util.ts; migrate tasksPanelProvider and speedtestPanel off their local copies. - Add sendCommand/onNotification in @repo/webview-shared for vanilla webviews; useIpc stays for React. - speedtestPanel calls buildCommandHandlers AND buildRequestHandlers, so adding a new action to SpeedtestApi is a compile error until a handler is wired. - Document the contract and the visibility/theme re-send guarantee in packages/webview-shared/README.md; AGENTS.md and CONTRIBUTING.md point at it. - Expand speedtestPanel tests (payload, visibility/theme re-send, viewJson dispatch, cleanup) and add ipc.test.ts for the new helpers.
Define ChatApi in shared and replace the ad-hoc {type, ...} message
handling with buildCommandHandlers / buildRequestHandlers plus
dispatchCommand / dispatchRequest. Outgoing notifications route
through a private notify() wrapper, mirroring tasksPanelProvider.
The iframe shim in the inline HTML keeps its own {type, payload}
contract with the Coder server, but its shim-to-extension side now
speaks the IPC wire format. Split the handler into handleFromIframe /
handleFromExtension + a toIframe helper + a showRetry builder so the
dispatch reads straight through.
Tests updated to the new wire format.
30594e4 to
6647e51
Compare
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.
isIpcCommand,isIpcRequest,notifyWebview,dispatchCommand,dispatchRequest,onWhileVisible) intosrc/webviews/util.ts.tasksPanelProvider/speedtestPanel/chatPanelProviderall migrate to them.sendCommand/onNotificationin@repo/webview-sharedfor non-React webviews (speedtest uses them; React webviews keepuseIpc).buildCommandHandlersandbuildRequestHandlers(empty{}is fine): any newdefineCommand/defineRequeston anApiproduces a compile error at the panel missing a handler, so the extension can't silently drop a future action.packages/webview-shared/README.md.CONTRIBUTING.mdandAGENTS.mdpoint at it as the single source of truth.{type, ...}protocol; it now usesChatApi+ shared dispatchers. The iframe shim still speaks the Coder server's{type, payload}contract, but the shim-to-extension side is IPC. The shim was split intotoIframe/handleFromIframe/handleFromExtension/showRetryso dispatch reads straight through.