Skip to content

feat: app-wide, page-context-aware chatbot#173

Merged
BhuvanArn merged 4 commits into
stagingfrom
fu-197-context-chatbot
Jul 15, 2026
Merged

feat: app-wide, page-context-aware chatbot#173
BhuvanArn merged 4 commits into
stagingfrom
fu-197-context-chatbot

Conversation

@BhuvanArn

Copy link
Copy Markdown
Owner

What type of PR is this? (check all applicable)

  • ✨ Feature
  • 🛑 Bug
  • ⚠️ Anomaly
  • 📝 Doc
  • 🎨 Style
  • 🧑‍💻 Refactor
  • 🛠️ Setup
  • 🏗️ Build
  • 🔥 Perfs
  • ✅ Test
  • 🔁 CI
  • ⏩ Revert

Description

Makes the chatbot app-wide and aware of the page it's on (#197). The floating assistant now appears on every authenticated page and grounds its answers in the current surface's real data — e.g. on a roadmap it can explain a topic or suggest talking points; on the agenda it can tell the user their next scheduled event.

Security (reuses the #154 pattern)

The client sends identifiers only ({ surface, applicationId?, interviewId? }), never a data blob. The server resolves the actual data from those ids through owner-guarded loaders, so a caller can only ground on their own data — no prompt-injection surface. A resolution failure (foreign/missing id, no data) degrades to an ungrounded reply rather than failing the chat.

Server

  • POST /ai/chat now takes @UserId() and is rate-limited: added @UseGuards(ThrottlerGuard) + @Throttle (20/min per user) — the class-level AccessTokenGuard runs first so req.userId is set (it was previously an unthrottled, user-less route).
  • ChatDto gains an optional context (a ChatSurface enum + optional owned ids).
  • resolveChatContext(context, userId) dispatches per surface to existing owner-guarded services — applicationsService.getRoadmap/ensureCvSnapshot, getInterviewById + verbal analysis (latest interview for the application when no interview id), agendaService.listForRange (next 30 days), notesService.findAll (scoped by application when given) — and the resolved block is appended to the system prompt.
  • New chat-context.ts compactors turn owned rows into short, plain-text, char-capped blocks (never raw JSON). AiModule now imports AgendaModule + NotesModule. Bruno post chat.bru shows the context field.

Web

  • ChatWidget mounts once app-wide from __root.tsx (authenticated shell only) and derives its context from the current route via a new useChatContext hook (roadmap / simulation / agenda / notes+scope / cv). It forwards that context to /ai/chat.
  • Added a sidebar Assistant entry (F8 was previously unreachable from nav). /ai-chat becomes the assistant's landing page; the widget itself is global, so the page no longer mounts its own copy.

Verification

Browser-verified (Playwright, auth+data mocked): the FAB floats on the roadmap page, opening it and sending a message posts context: { surface: 'roadmap', applicationId } to /ai/chat; the Assistant nav entry is visible. Server 900 tests (format/lint/build clean); web 1224 tests (tsc -b / lint / vite build clean). New unit coverage: per-surface context resolution + degrade-on-failure (service), the chat-context formatters, the useChatContext route mapping, the widget forwarding context, and the throttle-guard metadata.

Deliberately out of scope (follow-up)

A persistent chat "bank" (saved conversations + history/continue UI) is a separate, larger feature — the chat is stateless today. Filed as a follow-up issue so this PR stays focused on context-awareness, per the issue's own scope note.

Linked GitHub Ticket

Closes EpitechPromo2027/G-EIP-600-NAN-6-1-eip-tugdual.de-reviers#197

Workspace

  • 🖥️ Web
  • 🛠️ Server
  • 🔁 CI
  • 🤖 Ai
  • 📱 App

Screenshots

Roadmap page with the assistant open (sidebar shows the new Assistant entry). Sending a message grounds on the roadmap: match score, summary, topics, talking points.

Copilot AI review requested due to automatic review settings July 14, 2026 23:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
talk-up-ai-dev Ready Ready Preview, Comment Jul 15, 2026 1:59am

@railway-app
railway-app Bot temporarily deployed to talk-up-ai / TalkUp.AI-pr-173 July 14, 2026 23:31 Destroyed
@railway-app

railway-app Bot commented Jul 14, 2026

Copy link
Copy Markdown

🚅 Deployed to the TalkUp.AI-pr-173 environment in talk-up-ai

Service Status Web Updated (UTC)
Backend ✅ Success (View Logs) Jul 15, 2026 at 2:00 am

@BhuvanArn BhuvanArn self-assigned this Jul 15, 2026
@railway-app
railway-app Bot temporarily deployed to talk-up-ai / TalkUp.AI-pr-173 July 15, 2026 01:59 Destroyed
@BhuvanArn
BhuvanArn merged commit e2f9ca3 into staging Jul 15, 2026
14 checks passed
@BhuvanArn
BhuvanArn deleted the fu-197-context-chatbot branch July 15, 2026 22:31
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