Skip to content

feat(transport): add sidepanel runtime context support#14

Merged
StyleT merged 3 commits intoStyleT:mainfrom
dmagunov:feat/sidepanel-transport
Feb 8, 2026
Merged

feat(transport): add sidepanel runtime context support#14
StyleT merged 3 commits intoStyleT:mainfrom
dmagunov:feat/sidepanel-transport

Conversation

@dmagunov
Copy link
Copy Markdown
Contributor

@dmagunov dmagunov commented Feb 7, 2026

Summary

Adds sidepanel as a first-class runtime context for @webext-pegasus/transport, implementing the planned sidepanel support noted in the README.

Chrome's Side Panel API is now widely adopted, and extensions using Pegasus currently have to work around the missing context by importing from @webext-pegasus/transport/popup — which works but is semantically incorrect and could cause issues if context-specific routing is ever added.

Changes

  • src/types.ts — Add 'sidepanel' to the RuntimeContext union type
  • src/utils/endpoint-utils.ts — Add sidepanel to ENDPOINT_RE regex and serializeEndpoint's non-tabId context list (sidepanel, like popup, is a singleton context without tab association)
  • sidepanel.ts — New entrypoint following the same pattern as popup.ts, using 'sidepanel' as the context identifier
  • package.json — Add sidepanel.ts to tsup-build, add ./sidepanel export map entry, add typesVersions entry
  • README.md (root + transport) — Update supported contexts, available entrypoints list, and security notes

Usage

// sidepanel.ts
import { initPegasusTransport } from '@webext-pegasus/transport/sidepanel';

initPegasusTransport();

Add sidepanel as a first-class runtime context alongside popup, options,
devtools, etc. This enables Chrome's Side Panel API to be used with
Pegasus transport without workarounds.

Changes:
- Add 'sidepanel' to RuntimeContext type union
- Add 'sidepanel' to ENDPOINT_RE regex for endpoint deserialization
- Add 'sidepanel' to serializeEndpoint's non-tabId context list
- Add sidepanel.ts entrypoint (same pattern as popup.ts)
- Add ./sidepanel export and typesVersions to package.json
- Add sidepanel.ts to tsup-build script
- Update README docs to reflect sidepanel support
Copy link
Copy Markdown
Owner

@StyleT StyleT left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@StyleT StyleT requested a review from Copilot February 8, 2026 05:05
@StyleT StyleT merged commit b774dfe into StyleT:main Feb 8, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds sidepanel as a supported runtime context in @webext-pegasus/transport, including a dedicated entrypoint and updated package exports/docs, so extensions can initialize transport in a semantically correct Side Panel context.

Changes:

  • Extend runtime-context typing and endpoint parsing/serialization to recognize sidepanel.
  • Add a new @webext-pegasus/transport/sidepanel entrypoint and wire it into build + exports.
  • Update READMEs to list sidepanel as supported and document the new entrypoint.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/transport/src/utils/endpoint-utils.ts Adds sidepanel to endpoint regex and singleton-context serialization list.
packages/transport/src/types.ts Extends RuntimeContext union with 'sidepanel'.
packages/transport/src/isInternalEndpoint.ts Treats sidepanel as an internal endpoint context.
packages/transport/sidepanel.ts New transport initializer entrypoint for sidepanel context.
packages/transport/package.json Adds sidepanel to tsup build inputs, export map, and typesVersions.
packages/transport/README.md Updates supported contexts, entrypoints list, and security note to include sidepanel.
packages/rpc/src/types.ts Extends RPC RuntimeContext union with 'sidepanel'.
README.md Updates root supported contexts list to include sidepanel (no longer “planned”).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 3 to 5
const ENDPOINT_RE =
/^((?:background$)|devtools|popup|options|content-script|window)(?:@(\d+)(?:\.(\d+))?)?$/;
/^((?:background$)|devtools|popup|sidepanel|options|content-script|window)(?:@(\d+)(?:\.(\d+))?)?$/;

Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

ENDPOINT_RE allows endpoints without an @tabId suffix (e.g. sidepanel, popup, background). In deserializeEndpoint, those cases currently produce tabId: NaN (because +tabId where tabId is undefined), which violates Endpoint.tabId: number | null and can leak into routing logic (e.g. deserializeEndpoint(connArgs.endpointName) in background.ts). Consider setting tabId to null when the capture group is missing (and optionally rejecting missing tabId for contexts that require it).

Copilot uses AI. Check for mistakes.
| 'devtools'
| 'background'
| 'popup'
| 'sidepanel'
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

RuntimeContext now includes 'sidepanel', but packages/rpc/README.md still lists sidepanel as "planned". Either update the RPC README to reflect current support, or (if RPC isn’t intended to support sidepanel yet) avoid advertising it via the public RuntimeContext type until the rest of the RPC surface is ready.

Suggested change
| 'sidepanel'

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants