Skip to content

feat: AiPromptコマンドの入力方法をDOM操作からURLクエリへ変更#367

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/change-ai-prompt-input-method
Draft

feat: AiPromptコマンドの入力方法をDOM操作からURLクエリへ変更#367
Copilot wants to merge 3 commits intomainfrom
copilot/change-ai-prompt-input-method

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

対応サービス(ChatGPT・Claude・Perplexity)のAiPromptコマンドで、プロンプト入力をDOM操作ではなくURLクエリパラメータ経由で行うよう変更。Perplexityはページ遷移と同時に処理されるため submit クリック不要。

変更内容

型・データ定義

  • AiService 型に queryUrl?: string%s プレースホルダー付きURLテンプレート)と autoSubmit?: boolean を追加
  • ai-services.json に各サービスの queryUrl を追加:
    • ChatGPT: https://chatgpt.com/?prompt=%s (autoSubmit: false)
    • Claude: https://claude.ai/new?q=%s (autoSubmit: false)
    • Perplexity: https://www.perplexity.ai/search/new?q=%s (autoSubmit: true)

normalizeServices の緩和

queryUrl が存在する場合、inputSelectors/submitSelectors を必須としないよう変更。

action/aiPrompt.ts のロジック変更

queryUrl あり && !needClipboard
  → URLクエリ方式:
      - promptテンプレートを同期変数 ({{SelectedText}}, {{Url}}, {{Lang}}) で展開
      - 展開済みプロンプトを %s に埋め込んだ URL を生成
      - DOM input ステップをスキップ
      - autoSubmit: false なら submit クリックを実行
      - autoSubmit: true (Perplexity) なら submit も不要

queryUrl なし || {{Clipboard}} を含む
  → 既存のDOM操作方式にフォールバック

SidePanelモードでも、pending.url に展開済みURLを使用することで正しく動作する。

Copilot AI and others added 2 commits April 13, 2026 03:32
- Add queryUrl and autoSubmit fields to AiService type
- Update ai-services.json with queryUrl for ChatGPT, Claude, Perplexity
- Update normalizeServices to allow entries with queryUrl without requiring selectors
- Update action/aiPrompt.ts to use URL query when queryUrl is present
- Add unit tests for new behavior

Agent-Logs-Url: https://github.com/ujiro99/selection-command/sessions/e86cfbca-0afe-4e5e-884f-a8400da9d40e

Co-authored-by: ujiro99 <677231+ujiro99@users.noreply.github.com>
Copilot AI changed the title [WIP] Change AiPrompt input method to URL query feat: AiPromptコマンドの入力方法をDOM操作からURLクエリへ変更 Apr 13, 2026
Copilot AI requested a review from ujiro99 April 13, 2026 03:35
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.

Ai-Promptコマンドの入力方法をDOM操作からURLクエリへ変更

2 participants