Skip to content

Reopen closed tab (⌘⇧T) - #482

Open
ianu82 wants to merge 2 commits into
pr/omnibox-suggestionsfrom
pr/reopen-closed-tab
Open

Reopen closed tab (⌘⇧T)#482
ianu82 wants to merge 2 commits into
pr/omnibox-suggestionsfrom
pr/reopen-closed-tab

Conversation

@ianu82

@ianu82 ianu82 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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.json already handles deliberate session restore.

Stacked on pr/omnibox-suggestions. Includes main-process tests for the stack behaviour.

For QA

  1. Open a few tabs, close one, press ⌘⇧T: it comes back on the same URL and becomes active.
  2. Close a pinned tab, ⌘⇧T: it returns pinned.
  3. Close several tabs and reopen repeatedly: they come back newest-first, up to 10 deep; older ones are forgotten.
  4. Close a start-page / blank tab: it's not remembered (⌘⇧T skips it).
  5. Restart the app: ⌘⇧T does nothing — the stack is intentionally session-only.

@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: 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".

Comment thread src/main/browser/browser-manager.ts Outdated
Comment on lines +577 to +579
const record = closedStack.pop();
if (!record) return { ok: false };
const { tabId } = await newTab({ url: record.url, activate: true });

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 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — reopen peeks and only pops after newTab succeeds, so the record survives the MAX_TABS edge; test included (4430c09).

ianu82 added 2 commits July 23, 2026 10:21
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).
@ianu82
ianu82 force-pushed the pr/omnibox-suggestions branch from ad2ec92 to 5097695 Compare July 23, 2026 17:44
@ianu82
ianu82 force-pushed the pr/reopen-closed-tab branch from 5c5919d to 4430c09 Compare July 23, 2026 17:44
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