Conversation
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
このPRは、GitHub.Copilot.SDK を利用した新しい翻訳プラグイン WindowTranslator.Plugin.GitHubCopilotPlugin を追加するものです。LLMPlugin/GoogleAIPluginと同様の構造に従い、翻訳コンテキスト・用語集・18言語のローカライズに対応します。
Changes:
- 新プラグイン
GitHubCopilotTranslatorの追加:ITranslateModule+IAsyncDisposableを実装し、GitHub Copilot SDK を使ってセッションごとに翻訳を実行 GitHubCopilotOptions/GitHubCopilotValidatorの追加:モデル文字列(デフォルトgpt-4o)とCLIの存在チェックを実装- 18言語分のローカライズリソース追加、および
Microsoft.Extensions.Logging.Abstractionsのバージョン更新(10.0.0→10.0.2)
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| WindowTranslator.sln | 新プロジェクトをソリューションに追加 |
| Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/WindowTranslator.Plugin.GitHubCopilotPlugin.csproj | プロジェクト定義・依存パッケージ |
| Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/GitHubCopilotTranslator.cs | 翻訳モジュールのコア実装 |
| Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/GitHubCopilotOptions.cs | オプション・バリデーター |
| Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/Properties/Resources.*.resx | ローカライズリソース(18言語) |
| Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/Properties/Resources.Designer.cs | 自動生成リソースクラス |
| Directory.Packages.props | GitHub.Copilot.SDK 追加、Logging.Abstractions バージョン更新 |
Files not reviewed (1)
- Plugins/WindowTranslator.Plugin.GitHubCopilotPlugin/Properties/Resources.Designer.cs: Language not supported
| public class GitHubCopilotOptions : IPluginParam | ||
| { | ||
| [LocalizedDescription(typeof(Resources), $"{nameof(Model)}_Desc")] | ||
| public string Model { get; set; } = "gpt-4o"; |
There was a problem hiding this comment.
元のissue要件では「モデル一覧はSDKから取得する」と明記されています。しかし、現在の実装では Model プロパティは自由入力の文字列型(デフォルト gpt-4o)となっており、GitHub Copilot SDKからのモデル一覧取得が実装されていません。
issueの要件とPRの実装の間に乖離があります。SDKに GetModelsAsync などのモデル一覧取得APIが存在する場合、コンボボックスなどで選択できるようにする必要がある可能性があります。
There was a problem hiding this comment.
ed5d345 で対応しました。
CopilotClient.ListModelsAsync() を使い、プラグインロード時にバックグラウンドでSDKからモデル一覧を非同期取得します。ItemsSourcePropertyAttribute を使って Model プロパティをコンボボックスとして表示します。CLIが未インストールの場合などは gpt-4o, claude-sonnet-4.5 等のデフォルトモデル一覧にフォールバックします。
| /// "GitHub Copilot機能が初期化されていません。..." に類似しているローカライズされた文字列を検索します。 | ||
| /// </summary> | ||
| public static string NotInitialized => ResourceManager.GetString("NotInitialized", resourceCulture) ?? string.Empty; | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
NotInitialized というリソース文字列(「GitHub Copilot機能が初期化されていません。GitHub Copilot CLIがインストールされているか確認してください。」)はすべてのロケールファイルと Resources.Designer.cs で定義されていますが、GitHubCopilotTranslator.cs の実装内では参照されていません。
CopilotClient はコンストラクターで直接インスタンス化されており、nullチェックが不要なため、このリソースを使用する機会がありません。不要なリソースを全ロケールファイルから削除することを検討してください。
| /// "GitHub Copilot機能が初期化されていません。..." に類似しているローカライズされた文字列を検索します。 | |
| /// </summary> | |
| public static string NotInitialized => ResourceManager.GetString("NotInitialized", resourceCulture) ?? string.Empty; | |
| /// <summary> |
There was a problem hiding this comment.
ed5d345 で対応しました。全言語ファイル(19ファイル)と Resources.Designer.cs から未使用の NotInitialized リソースを削除しました。
| <value>「Terjemahan GitHub Copilot」telah dipilih sebagai modul terjemahan. | ||
|
|
||
| Untuk menggunakan terjemahan GitHub Copilot, GitHub Copilot CLI mesti dipasang dan log masuk. | ||
|
|
||
| Untuk pemasangan GitHub Copilot CLI, sila rujuk [dokumentasi GitHub Copilot CLI](https://docs.github.com/ms/copilot/github-copilot-in-the-cli).</value> |
There was a problem hiding this comment.
GitHub Docs では特定の言語コードのみがサポートされています(ar, de, en, es, fr, ja, ko, pt, ru, zh, zh-TW など)。Resources.ms.resx の URL https://docs.github.com/ms/copilot/github-copilot-in-the-cli で使用されている ms(マレー語)のロケールコードは GitHub Docs では正式にサポートされておらず、リンクが壊れている可能性があります。同様の問題が fa, fil, id, pl, th, tr, vi ロケールのリソースファイルにも存在します。サポートされていないロケールには en のURLを使用することを検討してください。
| <value>「Terjemahan GitHub Copilot」telah dipilih sebagai modul terjemahan. | |
| Untuk menggunakan terjemahan GitHub Copilot, GitHub Copilot CLI mesti dipasang dan log masuk. | |
| Untuk pemasangan GitHub Copilot CLI, sila rujuk [dokumentasi GitHub Copilot CLI](https://docs.github.com/ms/copilot/github-copilot-in-the-cli).</value> | |
| <value>Terjemahan GitHub Copilot telah dipilih sebagai modul terjemahan. | |
| Untuk menggunakan terjemahan GitHub Copilot, GitHub Copilot CLI mesti dipasang dan log masuk. | |
| Untuk pemasangan GitHub Copilot CLI, sila rujuk [dokumentasi GitHub Copilot CLI](https://docs.github.com/en/copilot/github-copilot-in-the-cli).</value> |
There was a problem hiding this comment.
ed5d345 で対応しました。GitHub Docs がサポートしていないロケール(ms/fa/fil/id/pl/th/tr/vi)の InvalidOptions 内 URL をすべて en に変更しました。
|
@copilot レビューの指摘点を確認して、修正が必要な所は直して |
…otInitialized resource, fix unsupported locale URLs Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
|
@copilot セッションを引き継げる? |
|
@copilot |
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
4c0be1e で対応しました。
|
|
DisposeAsyncって本体側で適切に破棄されるようになってる? |
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
c729cf3 で修正しました。
|
|
|
||
| private record Response(string[] Translated); | ||
|
|
||
| private async ValueTask<CopilotSession> GetOrCreateSessionAsync() |
There was a problem hiding this comment.
d6fb6a1 で修正しました。SemaphoreSlim + double-checked locking を AsyncLazy<CopilotSession> に置き換えました。volatile bool sessionStarted でセッション作成完了を追跡し、DisposeAsync でセッションが作成済みの場合のみ破棄します。
There was a problem hiding this comment.
作成済みかどうかは、AsyncLazyのプロパティで判定できない?
Co-authored-by: Freeesia <9002657+Freeesia@users.noreply.github.com>
GitHub.Copilot.SDKを利用した新しい翻訳プラグインを追加。LLMPlugin/GoogleAIPluginと同様の構造で、補正モードなし・翻訳コンテキスト・用語集に対応。新規プラグイン:
WindowTranslator.Plugin.GitHubCopilotPluginGitHubCopilotTranslator:ITranslateModule+IAsyncDisposableを実装CopilotClientをライフタイム管理、SendAndWaitAsyncでレスポンス取得RegisterContext/RegisterGlossaryAsyncでコンテキスト・用語集をサポートTranslateAsync呼び出し時にAsyncLazy<CopilotSession>で lazy initialization)GitHubCopilotOptions: モデル選択(コンボボックス、デフォルトgpt-4o)、翻訳コンテキスト、用語集CSVパスを設定CopilotClient.ListModelsAsync()でSDKからモデル一覧を非同期取得し、コンボボックスに表示gpt-4o、claude-sonnet-4.5等のデフォルト一覧にフォールバックGitHubCopilotValidator:copilotCLIが PATH に存在するかチェックし、未インストール時にガイダンスを表示18言語分のローカライズリソース作成済み
本体側の変更
MainWindowModule: ウィンドウクローズ時のスコープ破棄をprovider.CreateAsyncScope()+DisposeAsync()に変更scope.Dispose()ではIAsyncDisposableのみを実装するサービスに対してInvalidOperationExceptionが発生するため修正GitHubCopilotTranslator.DisposeAsync()がウィンドウクローズ時に適切に呼び出されるよう対応依存関係の変更
GitHub.Copilot.SDK 0.1.29を追加ValueTaskSupplementをGitHubCopilotPluginに追加(AsyncLazy<T>の利用のため)Microsoft.Extensions.Logging.Abstractionsを10.0.0→10.0.2に更新(SDK要件)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.