Add support for tab groups - #16
Conversation
- urlintitle: guard unknown message names and catch handler rejections in the service worker onMessage listener, preventing unhandled promise rejections in the content script when a handler rejects or is unknown. - urlintitle: fix a race where concurrent in-flight title updates could apply stale/out-of-order results. Capture the original title locally, ignore superseded responses via a monotonic id, clear the pending marker only after the latest response (or on send failure), and memoize get_constants. - newtab: use chrome.tabs.getCurrent() instead of querying the active tab of the last-focused window, so the extension's own new-tab page is redirected rather than an unrelated tab; await and catch chrome.tabs.update. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a {group} format tag that inserts the name of the tab's tab group into
the reformatted title. Opt-in is format-string driven (add {group} to the
format); no new setting, default format unchanged.
- manifest.json: adds the "tabGroups" permission ("tabs" is not needed, as
groupId is not a sensitive tab property) and declares
"minimum_chrome_version": "99" — the floor for promise-form
chrome.runtime/tabs.sendMessage per the Chrome docs (Object.hasOwn needs 93,
the tabGroups API 89).
- title_lib.js: adds the {group} tag (which auto-appears in the options tag
reference table and live preview) and a formatUsesGroup() helper. When the
tab has no group name, formatPageTitle removes the tag together with its
surrounding separators instead of leaving a dangling or doubled separator:
brackets wrapping the tag are dropped as a pair ('{title} ({group}) -
{host}' -> '{title} - {host}'), a trailing separator is kept when real
content flanks both sides, and at an edge the tag and its separators are
dropped entirely.
- options_lib.js: adds an example group to EXAMPLE_ENV for the options preview.
- background.js: resolves the group name in the service worker from
sender.tab.id (reading a fresh groupId via chrome.tabs.get rather than
trusting the possibly-stale sender snapshot), guarded by a formatUsesGroup()
short-circuit and try/catch. Titles refresh live via two listeners:
chrome.tabGroups.onUpdated for renames (skipped when the last-known group
title is unchanged, e.g. color or collapse updates) and chrome.tabs.onUpdated
changeInfo.groupId for a tab joining or leaving a group.
formatPageTitleUpdate also returns the suffix-stripped core_title.
- page_hook.js: a refresh_title listener re-formats from the stored raw source
title (the background's core_title) rather than the already-formatted
document.title, so repeated refreshes cannot accumulate a stale suffix. It
prefers the title of an in-flight page-driven update, so a refresh cannot
resurrect a superseded title, and is registered before the first awaited
update so a rename during the initial format is not dropped. The update
try/catch also covers the get_constants fetch, so a failed first message
cannot leave the title deduped forever.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a DEBUG constant (false by default) and a debug() helper to both the service worker and the content script, logging title and tab-group activity. Flip DEBUG to true and reload to trace; the service worker logs to its own console (chrome://extensions) and the content script to the page's DevTools console. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The default format is now '{title} @ {group} - {protocol}://{hostname}{port}/',
so a named tab group shows as 'Title @ Group - https://host/'. Ungrouped tabs
collapse cleanly to 'Title - https://host/'.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This PR does a lot more than just adding support for tab groups to urlintitle. It needs reorganizing/splitting before a review can take place. The newtab extension changes should be separate and increment the version number. Separately, most of the changes are complex and/or subtle and will require careful review & testing. I don't know when I will have time to do this difficult work, if at all. Regarding the feature itself (tab groups), I'm on the fence. I don't know how many users would use the feature, and it's not obvious that its benefits are worth requiring another permission and a large amount of new, complex code. It looks like we're approaching/reaching the point where the code is complex enough -- especially the separators removal logic -- to deserve unit tests, which I'd like to avoid. |
Adds support for using a tab's current tab group name in the custom page title.
E.g. I want to name my tabs "{title} @ {group} - {url}"
Should automatically update whenever a tab is added to or removed from a group.