Skip to content

チャット内ファイルパスを VS Code で開くリンクにする - #81

Merged
ktmage merged 6 commits into
developmentfrom
feature/80/file-path-link
Mar 7, 2026
Merged

ktmage merged 6 commits into
developmentfrom
feature/80/file-path-link

Conversation

@ktmage

@ktmage ktmage commented Mar 7, 2026

Copy link
Copy Markdown
Owner

概要

Issue #80 の実装。チャット UI 上でローカルファイルを参照しているパターンを検出し、クリックすると VS Code のエディタで該当ファイルが開くリンクとして表示する。

変更内容

1. プロトコル・インターフェース拡張

  • UIToHostMessage に openFile メッセージ型を追加(filePath + オプション line)
  • IPlatformServices に openFile メソッドシグネチャを追加

2. Extension 側

  • VscodePlatformServices に openFile メソッドを実装(vscode.workspace.openTextDocument + showTextDocument、行番号指定あればカーソル移動)
  • ChatViewProvider に openFile メッセージのハンドラーを追加

3. Webview 側

  • AppContext に onOpenFile コールバックを追加
  • App.tsx に handleOpenFile を実装
  • ToolPartView: タイトルに絶対パス(/始まり)が含まれる場合、クリック可能なリンクとして表示。クリック時に onOpenFile を呼び出す
  • TextPartView:
    • マークダウンリンク([text](/path))の href がローカル絶対パスの場合、data-file-path 属性付きリンクに変換してクリックインターセプト
    • テキスト中の絶対パス(/path/to/file.ext)を自動検出してリンク化(コードブロック内は除外)
    • 行番号付きパス(/path/to/file.ts:42)にも対応

4. テスト

  • ToolPartView: ファイルパスリンクの描画・クリックテスト追加
  • TextPartView: ファイルパスリンクの描画・クリック・行番号テスト追加
  • ChatViewProvider: openFile メッセージハンドラのテスト追加

Closes #80

@ktmage
ktmage merged commit 40a0791 into development Mar 7, 2026
1 check passed
@ktmage ktmage mentioned this pull request Mar 7, 2026
@ktmage
ktmage deleted the feature/80/file-path-link branch March 8, 2026 09:39
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.

1 participant