Skip to content

Conversation

@azu
Copy link
Owner

@azu azu commented Aug 2, 2025

概要

  • 1Password初期化処理を並列化して高速化
  • 非同期サービス設定に対応
  • 初期化時間を約13秒から数秒に短縮

変更内容

1. 1Password CLI呼び出しの並列化

  • 複数のシークレットを一度のコマンドで取得(バッチ処理)
  • セッション管理で認証を一度だけに最適化
  • キャッシュ機能で重複取得を防止

2. 非同期初期化への対応

  • service.jsがPromiseを返すように変更
  • waitForInitialization関数でサービス初期化を待機
  • ローディング画面を追加してUXを改善

3. テストの更新

  • Playwrightテストを非同期初期化に対応
  • 初期化待機ヘルパー関数を追加
  • ローディング画面のテストケースを追加

パフォーマンス改善

  • 初期化時間: 約13秒 → 数秒
  • 1Password認証: 複数回 → 1回

🤖 Generated with Claude Code

- 複数の1Passwordシークレットを並列で取得するように改善
- service.jsがPromiseを返すように変更し、非同期初期化に対応
- バッチ処理で一度の認証で全てのシークレットを取得
- キャッシュ機能で重複した取得を防止
- ローディング画面を追加し、初期化中のUXを改善
- Playwrightテストを非同期初期化に対応
- 初期化時間を大幅に短縮(約13秒→数秒)
Copilot AI review requested due to automatic review settings August 2, 2025 04:10
@azu azu enabled auto-merge August 2, 2025 04:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements parallel initialization of 1Password secrets and asynchronous service configuration to improve application startup performance. The initialization time is reduced from approximately 13 seconds to just a few seconds.

  • Parallelize 1Password CLI calls with batch processing and session management
  • Implement asynchronous service initialization with Promise-based loading
  • Add loading screen and update tests to handle async initialization

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tests/integration/app.play.js Add helper function and test cases for async initialization, including loading screen verification
src/browser/service-instance.js Refactor service loading to support async initialization with Promise handling
src/browser/App.js Add loading screen component and async initialization logic in componentDidMount

);

// サービスの初期化状態は別管理(ServiceStoreの変更で上書きされないように)
this._serviceInitialized = false;
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using instance variable _serviceInitialized instead of component state can lead to inconsistent rendering. Consider using this.state.serviceInitialized instead to ensure proper React lifecycle management and re-rendering.

Copilot uses AI. Check for mistakes.
try {
await waitForInitialization();
this._serviceInitialized = true;
this.forceUpdate();
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using forceUpdate() is generally discouraged in React as it bypasses the normal component lifecycle. Consider using setState() to trigger re-renders in a more predictable way.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +44
this._serviceInitialized = false;
}

componentDidMount() {
async componentDidMount() {
// サービスの初期化を待つ
try {
await waitForInitialization();
this._serviceInitialized = true;
this.forceUpdate();
} catch (error) {
console.error("Failed to initialize services:", error);
// エラーが発生しても表示(シークレットがフォールバック値になる)
this._serviceInitialized = true;
this.forceUpdate();
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using forceUpdate() is generally discouraged in React as it bypasses the normal component lifecycle. Consider using setState() to trigger re-renders in a more predictable way.

Suggested change
this._serviceInitialized = false;
}
componentDidMount() {
async componentDidMount() {
// サービスの初期化を待つ
try {
await waitForInitialization();
this._serviceInitialized = true;
this.forceUpdate();
} catch (error) {
console.error("Failed to initialize services:", error);
// エラーが発生しても表示(シークレットがフォールバック値になる)
this._serviceInitialized = true;
this.forceUpdate();
// this._serviceInitialized is now managed in state as 'initialized'
}
async componentDidMount() {
// サービスの初期化を待つ
try {
await waitForInitialization();
this.setState({ initialized: true });
} catch (error) {
console.error("Failed to initialize services:", error);
// エラーが発生しても表示(シークレットがフォールバック値になる)
this.setState({ initialized: true });

Copilot uses AI. Check for mistakes.

// ローディング画面の存在を確認(すぐに確認)
const loadingText = window.locator("text=Loading...");
const isLoadingVisible = await loadingText.isVisible().catch(() => false);
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using .catch(() => false) to handle potential exceptions silently can mask real errors. Consider using a more explicit try-catch block or checking if the element exists first.

Suggested change
const isLoadingVisible = await loadingText.isVisible().catch(() => false);
const isLoadingVisible = await loadingText.isVisible();

Copilot uses AI. Check for mistakes.
@azu azu merged commit 97134cb into master Aug 2, 2025
5 checks passed
@azu azu deleted the feat/parallel-1password-init branch August 2, 2025 04:12
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