Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: ブラウザ版のConfigをBaseConfigManagerベースに #1629

Merged
merged 33 commits into from
Nov 13, 2023

Conversation

sevenc-nanashi
Copy link
Member

@sevenc-nanashi sevenc-nanashi commented Oct 28, 2023

内容

タイトル通り。

関連 Issue

スクリーンショット・動画など

(なし)

その他

(なし)

@sevenc-nanashi sevenc-nanashi marked this pull request as ready for review October 28, 2023 15:05
@sevenc-nanashi sevenc-nanashi requested a review from a team as a code owner October 28, 2023 15:05
@sevenc-nanashi sevenc-nanashi requested review from Hiroshiba and removed request for a team October 28, 2023 15:05
@sevenc-nanashi sevenc-nanashi marked this pull request as draft October 29, 2023 00:46
Co-authored-by: Hiroshiba <hihokaruta@gmail.com>
Comment on lines +82 to -83
sed -i -e 's|"074fc39e-678b-4c13-8916-ffca8d505d1d"|"208cf94d-43d2-4cf5-abc0-9783cac36d29"|' .env.test
sed -i -e 's|"../voicevox_engine/run.exe"|"${{ steps.download-engine.outputs.run_path }}"|' .env.test
sed -i -e 's|"executionArgs": \[\],|"executionArgs": ["--port=50021"],|' .env.test
cp .env.test .env
sed -i -e 's|"../voicevox_engine/run.exe"|"${{ steps.download-engine.outputs.run_path }}"|' .env
sed -i -e 's|"executionArgs": \[\],|"executionArgs": ["--port=50021"],|' .env
Copy link
Member

Choose a reason for hiding this comment

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

あ、このあたりも必要な変更だった感じでしょうか 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

色々試してたときのやつですね。問題自体はここには無かったのでいらないっちゃ要らないはず。

Copy link
Member

@Hiroshiba Hiroshiba Nov 5, 2023

Choose a reason for hiding this comment

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

なるほどです!
エンジンIDの変更が意図的かどうかパッとわからないので、やったほうが良さそうであればエンジンリポジトリと同様に環境変数へ、なくても良さそうであればこの行を消すはどうでしょう?

.env.testを書き換えるかはどちらでも良さそう。
(どっちかというと.envを自由に書き換えるほうがローカル変数っぽみがあって直感的だとは思います。.env.testは元からあるのでグローバルっぽみ。)

Copy link
Member Author

Choose a reason for hiding this comment

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

Viteは.envより.env.testの方が優先度が高いので、.env.env.testは同期しておきたいんですよね

Copy link
Member

Choose a reason for hiding this comment

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

あ、たしかに!!気をつけないといけない仕様ですね・・・。
(だとしたらexecutionArgsが元の.env.testの空っぽのに上書きされてそうですけど、なんで今まで動いてたんだろう)

.env.test直接書き換えで良い気がしました!

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

お疲れ様でした!!!
非常に有用なプルリクエストだと思います!!

ちょっとコーディング周りや設計周りでいろいろコメントさせていただきました。
よくわからなかったら言っていただければ 🙏

もしよければ @yamachu さんも見て頂けると心強いです!!

@Hiroshiba Hiroshiba requested a review from yamachu November 5, 2023 11:02
Comment on lines 114 to 121
async afterInitialize() {
if (this.config == null) {
throw new Error("assert: config != null");
}
this.config.engineSettings[defaultEngineId] ??= engineSettingSchema.parse(
{}
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

onupgradeneededに書くとconfigの初期化周りで処理が重複しそうだったのでフックを用意してそこに書きました。名前は変えても良いかも。

Co-authored-by: Hiroshiba <hihokaruta@gmail.com>
@sevenc-nanashi
Copy link
Member Author

lockでいい感じに書き直してみました。

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

ほぼLGTMです!!!

バックエンドが異なる共通部分の設計、難しいですね。。。。。。 😇

Comment on lines 18 to 20
export async function withConfigManager<T>(
callback: (configManager: BrowserConfigManager) => Promise<T>
): Promise<T> {
Copy link
Member

Choose a reason for hiding this comment

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

ここはどうしてもelectron側と実装が異なるので複雑性を1段階回すことになってしまうことに気づきました。
以下共有用メモです。


この辺り見てたんですが、
electron側はgetConfigManagerがasyncじゃなくて良い一方、
browser側はgetConfigManagerがasyncになる必要がありそうでした。

根本の課題は起動シーケンスの違いで、electronはバックエンドが最初なのに対し、browserはフロントエンドが最初なのでConfigManager初期化のタイミングがないんですよね・・・。
仮にバックエンドを初期化する関数を用意しても、Vueを初期化する前だとawaitできない・・・。

@sevenc-nanashi
Copy link
Member Author

レビューを反映しました。

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

LGTM!!!

コメント追加もありがとうございました!
テストが落ちていたのでrerunしてみました。また落ちるようでしたら再review requestいただけると・・・!

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

LGTM!!!

お疲れ様でした!!!

@Hiroshiba Hiroshiba removed the request for review from yamachu November 13, 2023 04:09
@Hiroshiba
Copy link
Member

@yamachu さんもレビューありがとうございました!
たぶん問題ないと思うので、マージします!

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.

壊れたconfig.jsonが保存されることがある
3 participants