All jobs

Add Page Titles per Route to an Angular App

Yes. An agent sets a title on every route, adds a TitleStrategy that appends the site name, titles article and profile pages after they load, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the router before it touches a title. In an app shaped like realworld-apps/angular-realworld-example-app, package.json pins @angular/core and @angular/router 21.2.12, runs vitest for test through @analogjs/vite-plugin-angular, ng build for build and Playwright for test:e2e, and installs with bun. src/index.html has one <title>Conduit</title> that every page shows. src/app/app.config.ts provides provideZonelessChangeDetection(), provideRouter(routes) and the api, token and error interceptors. src/app/app.routes.ts lazy-loads the empty path, tag/:tag, login, register, settings, profile, editor, editor/:slug and article/:slug, with a requireAuth guard on the editor and settings routes, and not one of them carries a title. src/app/features/profile/profile.routes.ts nests :username with an empty child and favorites. article.component.ts loads the article by route.snapshot.params['slug'] into an article signal, profile.component.ts does the same for a profile, and core/auth/auth.component.ts already works out Sign in or Sign up from the last URL segment.

It uses the router's own title support rather than calling document.title from components. Every static route gets a title: Home, Sign in, Sign up, Settings, New Article and Edit Article. The tag/:tag route gets a title function that reads the tag parameter from the ActivatedRouteSnapshot and returns it with a leading hash. src/app/core/title.strategy.ts extends TitleStrategy: updateTitle reads buildTitle(snapshot) and sets the page title followed by a separator and Conduit, or Conduit alone when a route has no title, and app.config.ts provides it with useClass. Article and profile pages cannot know their title until the API answers, so article/:slug and profile/:username get placeholder titles and the two components inject Title from @angular/platform-browser and set the article's title, or the username with a leading at sign, in the subscribe that already fills their signals; an error leaves the placeholder in place.

The existing specs, such as core/auth/services/jwt.service.spec.ts, import describe, it and expect from vitest, call getTestBed().initTestEnvironment once and configure TestBed per test. The agent adds core/title.strategy.spec.ts in that shape, using RouterTestingHarness from @angular/router/testing with the real routes: navigating to /login makes document.title read Sign in | Conduit, /tag/rust reads #rust | Conduit, and the root reads Home | Conduit. A second spec stubs ArticlesService.get with of(article) and asserts the title after ArticleComponent initialises. It runs bun run test, bun run build and bun run format:check, the check that .github/workflows/lint.yml and the lint-staged pre-commit hook both run, and fixes what fails before it pushes.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a page title to every route of this Angular app and open a pull request. Read package.json, src/index.html, src/app/app.config.ts, src/app/app.routes.ts, src/app/features/profile/profile.routes.ts, src/app/features/article/pages/article/article.component.ts, src/app/features/profile/pages/profile/profile.component.ts, src/app/core/auth/auth.component.ts, vitest.config.ts, src/test-setup.ts and one existing spec first. Set a static title on each route (Home, Sign in, Sign up, Settings, New Article, Edit Article), a title function on tag/:tag that returns the tag with a leading hash, and placeholders on article/:slug and profile/:username. Add src/app/core/title.strategy.ts extending TitleStrategy that sets '<page> | Conduit', or 'Conduit' when a route has no title, and provide it in app.config.ts. In ArticleComponent and ProfileComponent inject Title and set the article title or @username once the data arrives. Add vitest specs with RouterTestingHarness covering the static, tag and fallback titles, and one for the article title with a stubbed ArticlesService. Run bun run test, bun run build and bun run format:check and paste the output in the pull request. Do not change the guards, the interceptors or index.html.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that edits app.routes.ts, profile.routes.ts, app.config.ts, article.component.ts and profile.component.ts, adds core/title.strategy.ts and two spec files, and leaves index.html, the guards and the interceptors alone. The description lists each route and its title and pastes the vitest, ng build and prettier output.

On a repository with the Format Check and Playwright Tests workflows, the pull request runs bun run format:check and the end-to-end suite from the realworld submodule, so a title change that broke navigation would show there.

A reviewer checks that the separator and site name read well in a browser tab, that the tag title comes from the route parameter and not from HTML, that the article title is set after the data arrives and never before, and that the fallback never leaves the previous page's title behind on a route without one. Then they decide whether the editor should name the article being edited.

Run it on every Angular app without route titles

A team with several Angular front ends sends one POST /o/{org}/sessions per repository with this prompt and that repository in resources. Each run reads its own route table, so an app with NgModule routing gets the strategy provided in its module and an app with resolvers gets titles from them, and each run opens its own pull request.

Give the API key a webhook_url and Rush POSTs run.completed when each turn ends, with the session_url to read the pull request and the test output from.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A title is small, but it is on every route, and the router's TitleStrategy only shows its value when the whole table of routes is right. In a Rush sandbox the agent runs the real router under RouterTestingHarness, reads document.title after each navigation and keeps the output in the run's record, so the pull request shows each title rather than listing them.

The change uses what Angular ships, the title route property, TitleStrategy and the Title service, so there is no dependency and nothing to configure. The same request works on any standalone Angular app that calls provideRouter.

Frequently asked questions

Why not set document.title in each component?

Because the router already knows the title for every navigation, including back and forward, and a TitleStrategy applies the site name in one place. Components only step in for the two pages whose title depends on data the API returns.

What does the tab show while an article loads?

The placeholder from the route, Article | Conduit, until the component's subscription sets the real title. If the request fails, the placeholder stays and the page shows its error list as it does today.

Does the tag title put user input into the page?

It reads the tag route parameter and passes it to the Title service, which sets document.title as text. Nothing is interpolated into HTML, so a tag with angle brackets shows as text in the tab.

Will the Playwright suite still pass?

The end-to-end specs come from the realworld submodule and drive the pages by their content, not their titles. The agent runs the vitest specs and the build; the Playwright workflow runs on the pull request as it does for every push.

More Angular jobs

The same job on other stacks

More jobs like this: Hand off a long task

Keep reading