Reopen closed tab (⌘⇧T) - #482
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c5919dbcf
ℹ️ 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".
| const record = closedStack.pop(); | ||
| if (!record) return { ok: false }; | ||
| const { tabId } = await newTab({ url: record.url, activate: true }); |
There was a problem hiding this comment.
Keep the closed-tab entry when reopen cannot create a tab
When the browser is already back at MAX_TABS while closedCount > 0 (for example, close a tab, open replacement tabs up to the 50-tab cap, then choose Reopen), this pops the record before newTab() can throw tab limit reached. The renderer calls this without catching the rejection, and the closed tab is lost from the stack instead of remaining available after the user frees a slot, so the reopen history is corrupted in this edge case.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed — reopen peeks and only pops after newTab succeeds, so the record survives the MAX_TABS edge; test included (4430c09).
A small closed-tab stack (last 10, session-only) recorded on every real close. ⌘⇧T or the ⋮ menu pops the most recent record into a fresh activated tab; the menu item disables itself when the stack is empty (closedCount rides the state push, additive for older renderers). Blank tabs are never recorded; pinned tabs can't be closed so they never enter the stack.
Codex on #482: at MAX_TABS the closed-tab record was popped before newTab() could throw 'tab limit reached', so the tab was lost from reopen history. Peek instead and pop only after the tab exists; covers the edge with a test (reopen at the cap, free a slot, reopen succeeds).
ad2ec92 to
5097695
Compare
5c5919d to
4430c09
Compare
What
⌘⇧T reopens the most recently closed tab, like Chrome.
The main process keeps a session-only stack of the last 10 closed tabs (URL, title, favicon, pinned). Reopening loads the URL fresh and restores the pin if the tab had one. Blank/start-page tabs are never remembered, and the stack doesn't survive an app restart by design —
tabs.jsonalready handles deliberate session restore.Stacked on
pr/omnibox-suggestions. Includes main-process tests for the stack behaviour.For QA