Skip to content

アプリ再起動後に前回のウィンドウサイズを維持したまま起動する#46

Merged
0suu merged 1 commit into
mainfrom
45-アプリ再起動後に前回のウィンドウサイズを維持したまま起動する
Apr 13, 2026

Hidden character warning

The head ref may contain hidden characters: "45-\u30a2\u30d7\u30ea\u518d\u8d77\u52d5\u5f8c\u306b\u524d\u56de\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u7dad\u6301\u3057\u305f\u307e\u307e\u8d77\u52d5\u3059\u308b"
Merged

アプリ再起動後に前回のウィンドウサイズを維持したまま起動する#46
0suu merged 1 commit into
mainfrom
45-アプリ再起動後に前回のウィンドウサイズを維持したまま起動する

Conversation

@0suu

@0suu 0suu commented Apr 13, 2026

Copy link
Copy Markdown
Owner

fix #45

@0suu

0suu commented Apr 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements window state persistence by saving and restoring the window's dimensions and position. Feedback was provided to debounce the save operation to prevent excessive disk I/O during resizing or moving and to include a safety check ensuring the window is not destroyed before saving.

Comment thread src/main/main.ts
Comment on lines +108 to +112
const saveBounds = () => {
if (!mainWindow.isMinimized() && !mainWindow.isMaximized()) {
store.set("windowBounds", mainWindow.getBounds());
}
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

ウィンドウの resizemove イベントはドラッグやリサイズ中に頻繁に発生するため、そのたびに store.set(ディスク I/O)を呼び出すとパフォーマンスに悪影響を与える可能性があります。setTimeout を使用して処理をデバウンス(間引き)することをお勧めします。また、タイマー実行時にウィンドウが既に閉じられている場合の例外を防ぐため、!mainWindow.isDestroyed() のチェックを追加するのが安全です。

  let saveTimeout: ReturnType<typeof setTimeout>;
  const saveBounds = () => {
    clearTimeout(saveTimeout);
    saveTimeout = setTimeout(() => {
      if (!mainWindow.isDestroyed() && !mainWindow.isMinimized() && !mainWindow.isMaximized()) {
        store.set("windowBounds", mainWindow.getBounds());
      }
    }, 500);
  };

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 13, 2026

Copy link
Copy Markdown

Deploying switchbotcontroller with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5e69ea2
Status: ✅  Deploy successful!
Preview URL: https://e2450b8e.switchbotcontroller.pages.dev
Branch Preview URL: https://45.switchbotcontroller.pages.dev

View logs

@0suu

0suu commented Apr 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@0suu 0suu force-pushed the 45-アプリ再起動後に前回のウィンドウサイズを維持したまま起動する branch from b4eddee to 5e69ea2 Compare April 13, 2026 09:08
@0suu

0suu commented Apr 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e69ea28c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/main.ts
Comment on lines +97 to +98
x: savedBounds?.x,
y: savedBounds?.y,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate restored window position against active displays

Restoring x/y unconditionally can make the app reopen off-screen when the monitor layout changes (for example, a laptop was last used with an external display and then restarted without it). In that case Electron will honor the stale coordinates and users may see no window at startup, which is a functional regression from the previous centered default behavior.

Useful? React with 👍 / 👎.

@0suu 0suu merged commit 635dfc2 into main Apr 13, 2026
4 checks passed
@0suu 0suu deleted the 45-アプリ再起動後に前回のウィンドウサイズを維持したまま起動する branch April 13, 2026 09:16
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