Skip to content

Add keyboard shortcut to toggle call recording from other tabs #140

@rosscado

Description

@rosscado

A user has requested the ability to start/stop SayPi recording via a keyboard shortcut even when the Pi tab is not active.

User Request

"I often switch between Pi and other sites while talking to it, and it's GREAT that it continues recording in the background! However, I frequently forget to turn off the microphone (end the convo). A shortcut to start and stop recording while I'm browsing another website on another tab would be much more convenient than going back on the Pi tab and clicking the green/red call icon!"

Technical Assessment

This is technically feasible using Chrome's Extension Commands API:

  1. Add commands to manifest.json:
"commands": {
  "toggle-call": {
    "suggested_key": {
      "default": "Ctrl+Shift+9"
    },
    "description": "Toggle call recording"
  }
}
  1. Add a command listener in the background script:
chrome.commands.onCommand.addListener((command) => {
  if (command === "toggle-call") {
    // Send message to Pi tab to toggle recording
    chrome.tabs.query({url: "https://pi.ai/*"}, (tabs) => {
      if (tabs.length > 0) {
        chrome.tabs.sendMessage(tabs[0].id, {action: "toggle-recording"});
      }
    });
  }
});
  1. Implement message handling in the content script:
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.action === "toggle-recording") {
    // Determine current state and toggle
    if (/*recording is active*/) {
      EventBus.emit("audio:stopRecording");
    } else {
      EventBus.emit("audio:startRecording");
    }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions