Skip to content

Add window.postMessage interface for command add/delete from Command Hub#386

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-command-download-remove-interface
Draft

Add window.postMessage interface for command add/delete from Command Hub#386
Copilot wants to merge 3 commits intomainfrom
copilot/add-command-download-remove-interface

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

Enables Selection Command Hub (and other trusted web pages) to programmatically add or delete extension commands via window.postMessage, with toast feedback on success/error.

Changes

New IPC command

  • Added BgCommand.removeCommand enum value to ipc.ts

Background handler (background_script.ts)

  • Added removeCommand handler: filters commands by ID in a single pass, returns false if ID not found, persists and returns true on success

postMessage listener (DownloadButton.tsx)

  • Added window.message listener scoped to Hub origin (new URL(HUB_URL).origin) — rejects messages from any other origin
  • Handles two actions:
    • AddCommand — delegates to existing BgCommand.addCommand
    • DeleteCommand — calls new BgCommand.removeCommand with command id
  • Shows sonner toast on success/error; added <Toaster> to component render tree

i18n

  • Added 4 keys (commandHub_add_success, commandHub_add_error, commandHub_delete_success, commandHub_delete_error) to all 14 supported locales

Usage (Hub side)

// Add a command
window.postMessage({ action: "AddCommand", command: JSON.stringify(cmd) }, "*")

// Delete a command by ID
window.postMessage({ action: "DeleteCommand", id: "command-id" }, "*")

Copilot AI changed the title [WIP] Add interface for command download and removal Add window.postMessage interface for command add/delete from Command Hub Apr 29, 2026
Copilot AI requested a review from ujiro99 April 29, 2026 23:10
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.

コマンドダウンロード、削除用のインタフェースの追加

2 participants