Skip to content

feat(web): title the browser tab with the page being shown - #5

Merged
greymag merged 1 commit into
masterfrom
feature/48.page-title
Sep 9, 2026
Merged

feat(web): title the browser tab with the page being shown#5
greymag merged 1 commit into
masterfrom
feature/48.page-title

Conversation

@sonny-ns5

Copy link
Copy Markdown

Every page of the web UI was served with the same fixed <title>in_pub</title>, so a row of open tabs was indistinguishable and a bookmark carried no hint of what it pointed at.

Each screen now names itself as it activates:

Route Title
/ in_pub
/packages Packages | in_pub
/packages?q=foo Search: foo | in_pub
/packages/foo foo | in_pub
/packages/foo/versions/1.2.3 foo 1.2.3 | in_pub
/account Account | in_pub
/admin Administration | in_pub

Written pub.dev's way round — the specific part first, because the first few characters are all a tab strip has room for.

How it fits together

unpub_api/page_title.dart holds the repository's name and the composition rule; it is the one package both the server and the web UI already depend on, and both write a title:

  • the server stamps appTitle into the shell's <title> through the existing build-time template mechanism ({{$APP_TITLE}}), which is what a tab says until the bundle has loaded;
  • the web UI replaces it on every navigation, through AppService.setPageTitle.

Written twice, the two would drift the first time the repository was renamed, and a tab would flip from one name to another on load.

Titles are set from the url rather than from fetched data, so the package screen is named while its request is still in flight — and stays named when the answer is that there is no such package.

Not included

The server still renders one cached shell for every route, so the initial HTML carries the bare repository name; the tab is corrected as soon as the application starts. Serving a per-route title would mean caching the shell and its ETag per url, which is a larger change than this is worth. Worth revisiting if link previews (Slack, crawlers) ever matter.

Verification

  • make build — green; the regenerated unpub/lib/src/static/*.dart are committed as the project requires.
  • dart analyzeunpub clean; unpub_web reports only the four pre-existing dart:html deprecation infos.
  • dart test in unpub — 497 passed. The two failures are test/auth/mongo_auth_store_test.dart (setUpAll)/(tearDownAll), which need a local MongoDB that was not running; unrelated to this change.
  • New unpub/test/page_title_test.dart covers the composition rules and checks that the served shell really is titled through the template.

🤖 Generated with Claude Code

Every tab of the repository said `in_pub`, so a row of them could not be
told apart. Each screen now names itself as it activates, through
`AppService.setPageTitle`, and the composition lives in
`unpub_api/page_title.dart` — which the server reads too, stamping the same
constant into the shell's `<title>` through the build-time template
mechanism, so the name a tab shows before the bundle loads and the one it
shows after cannot drift apart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Copilot AI 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.

🔵 Needs a closer look

The hand-written changes are clean and correct, but the PR commits a large regenerated minified main.dart.js.dart bundle whose internal consistency cannot be fully verified by automated review.

Pull request overview

This PR makes the browser tab title reflect the page currently shown in the in_pub web UI, instead of a fixed in_pub on every route. The repository name and the title-composition rule are centralized in a new page_title.dart inside the unpub_api package (depended on by both server and web UI). The server stamps appTitle into the served shell's <title> via the existing build-time template mechanism ({{$APP_TITLE}}), and the AngularDart web UI overwrites the title on each navigation through AppService.setPageTitle.

Changes:

  • Add shared appTitle constant and pageTitle([page]) helper, and a server-side test covering the composition rule and the served shell template.
  • Replace the hardcoded <title>in_pub</title> with the APP_TITLE template variable (source template, generated index.html.dart, and app.dart wiring), regenerating the committed static bundle.
  • Call setPageTitle(...) from all five routed components (home, list, detail, admin, account) with page-appropriate names.
File summaries
File Description
unpub/lib/unpub_api/lib/page_title.dart New shared appTitle + pageTitle composition rule.
unpub/test/page_title_test.dart Tests composition rule and that the served shell renders appTitle.
unpub/lib/src/static/index.html.dart Generated shell now uses ${vars['APP_TITLE'] ?? ''}.
unpub/lib/src/static/main.dart.js.dart Regenerated minified bundle (title-setting + minifier renames).
unpub/lib/src/app.dart Passes APP_TITLE: appTitle into the shell template.
unpub/CHANGELOG.md Documents the tab-title change under 3.6.0.
unpub_web/web/index.html Source template uses {{$APP_TITLE}}.
unpub_web/lib/app_service.dart Adds setPageTitle writing document.title.
unpub_web/lib/src/{home,list,detail,admin,account}_component.dart Each sets its page title on activation.

I verified the dual import paths resolve (package:in_pub/unpub_api/lib/... for the server, package:unpub_api/... for the web UI via the path dependency), that all five routed components set a title, the q?.isEmpty ?? true ? ... : ... precedence in list_component.dart is correct, and that the single index_html.content(...) caller passes APP_TITLE. No objective issues were found in the hand-written code; unpub_web has no automated test suite, so no test-coverage feedback applies there.

Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@greymag
greymag merged commit 6576685 into master Sep 9, 2026
4 checks passed
@greymag
greymag deleted the feature/48.page-title branch September 9, 2026 07:17
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.

3 participants