Skip to content

Commit dbed86b

Browse files
Remove backward-compat ai-chat redirect from blog 6.3 and Angular source
1 parent cffc0cb commit dbed86b

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

blogs/series-6-ai-app-features/6.3-angular-ai-chat-widget.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ This article is part of the **AngularNetTutorial** series. The full-stack tutori
1919
* **Angular nested child routes** — How to register a `{ path: 'ai', children: [...] }` block so four pages share the same `/ai/*` URL prefix
2020
* **Sidebar sub-menu in ng-matero** — Adding a `"type": "sub"` entry with children to `menu.json` and translation keys in `en-US.json`
2121
* **One component, one responsibility** — Why extracting each AI feature into its own standalone component is better than growing a single tabbed component
22-
* **Backward-compatibility redirect** — How `{ path: 'ai-chat', redirectTo: 'ai/assistant' }` keeps old bookmarks working after a route rename
2322
* **`AiService`** — A lightweight, focused service that calls the AI endpoints without inheriting the base CRUD service
2423

2524
---
@@ -317,7 +316,7 @@ See the repository for the full files in:
317316

318317
The key change from the old approach is **nesting** the four AI routes under a parent `ai` path.
319318

320-
**`src/app/app.routes.ts`**replace the old flat `ai-chat` route:
319+
**`src/app/app.routes.ts`**add the nested `ai` route group:
321320

322321
```typescript
323322
import { AiAssistantComponent } from './routes/ai/ai-assistant/ai-assistant.component';
@@ -336,22 +335,17 @@ import { AiVectorSearchComponent } from './routes/ai/ai-vector-search/ai-vector-
336335
{ path: '', redirectTo: 'assistant', pathMatch: 'full' },
337336
],
338337
},
339-
{ path: 'ai-chat', redirectTo: 'ai/assistant', pathMatch: 'full' },
340338
```
341339

342340
**Why a `children` block instead of flat routes?**
343341

344342
Flat routes like `{ path: 'ai/assistant', component: ... }` would work for navigation but the URL structure would not be understood by the ng-matero sidebar. The sidebar resolves `route: "assistant"` relative to the parent `route: "ai"` — the routes file must mirror this nesting for the active-route highlighting to work correctly.
345343

346-
**Why keep the backward-compat redirect?**
347-
348-
Any bookmarks, Playwright tests, or external links pointing to `/ai-chat` will silently redirect to `/ai/assistant` without a 404 or broken navigation.
349-
350344
---
351345

352346
### Step 5: Add the Sidebar Sub-Menu
353347

354-
**`public/data/menu.json`**replace the old `ai-chat` entry:
348+
**`public/data/menu.json`**add the AI sub-menu group:
355349

356350
```json
357351
{
@@ -425,9 +419,6 @@ Click a suggestion chip — *"Which department has the most employees?"* — and
425419

426420
![HR Insight page showing a data-grounded Ollama answer — references live department headcounts, execution time shown below reply](../../docs/screenshots/series-6-ai-app-features/ai-hr-insight-with-answer.png)
427421

428-
**Test the backward-compat redirect:**
429-
Navigate to `http://localhost:4200/ai-chat` — it should silently redirect to `/ai/assistant`.
430-
431422
**Test the disabled state:**
432423
Set `aiEnabled: false` → hot-reload → all four pages show the info banner.
433424

@@ -444,7 +435,7 @@ src/app/
444435
│ └── ai-vector-search/ ← semantic position search (Article 6.6)
445436
├── services/api/
446437
│ └── ai.service.ts ← AiService (4 methods)
447-
└── app.routes.ts ← nested ai children + backward-compat redirect
438+
└── app.routes.ts ← nested ai children
448439
449440
public/
450441
├── data/menu.json ← ai sub-menu entry with 4 children
@@ -466,7 +457,7 @@ public/
466457
* ✅ Four focused pages — each component is ~80 lines, easy to read and test independently
467458
* ✅ Clean URL structure — `/ai/assistant`, `/ai/hr-insight`, `/ai/nl-search`, `/ai/vector-search`
468459
* ✅ Sidebar group — users discover all four AI features naturally via the collapsible sub-menu
469-
* ✅ Backward-compat redirect — any old `/ai-chat` bookmarks silently redirect to `/ai/assistant`
460+
470461

471462
---
472463

0 commit comments

Comments
 (0)