Skip to content

ai-assistant: Add route-aware and multi-resource contextual prompt suggestions - #1274

Open
Aamod007 wants to merge 2 commits into
headlamp-k8s:mainfrom
Aamod007:feat/ai-assistant-dynamic-prompts
Open

Aamod007 wants to merge 2 commits into
headlamp-k8s:mainfrom
Aamod007:feat/ai-assistant-dynamic-prompts

Conversation

@Aamod007

@Aamod007 Aamod007 commented Sep 4, 2026 •

Copy link
Copy Markdown

Description

This pull request implements route-aware and multi-resource contextual prompt suggestions in the ai-assistant plugin, resolving issue #1271.

Changes

  1. Multi-Resource Kind Support:

    • Expanded generatePrompts in src/prompts/promptGenerator.ts to support primary Kubernetes resource kinds:
      • StatefulSet: "Check stateful replica order and PVCs", "Is this StatefulSet rollout healthy?"
      • DaemonSet: "Check daemon rollout across nodes", "Why are daemon pods not scheduling?"
      • Job: "Why did the last job execution fail?", "How can I inspect active job pods?"
      • CronJob: "Check cron schedule and completion history", "Why is this CronJob not triggering?"
      • Ingress: "Explain backend routing rules and TLS certs", "Are ingress paths configured correctly?"
      • ConfigMap: "Show workloads consuming this ConfigMap", "How to mount this ConfigMap in a workload safely"
      • Secret: "Show workloads consuming this Secret", "How to mount this Secret safely without leaking data"
      • PersistentVolumeClaim: "Why is this PVC pending or failing to bind?", "Check storage class provisioner and capacity"
      • PersistentVolume: "Check persistent volume capacity and status", "Show claims bound to this volume"
      • Namespace: "Summarize resources and quotas in this namespace", "Check namespace resource limits"
      • NetworkPolicy: "Explain ingress and egress traffic rules", "Are pods blocked by this network policy?"
  2. Expanded List View Categories:

    • Added list-view suggestions for Deployment, StatefulSet, DaemonSet, Job, CronJob, Ingress, Service, ConfigMap, Secret, PersistentVolumeClaim, and Namespace.
  3. Route-Aware Fallback:

    • When no resource or project event is present, parse event.pathname (from useLocation().pathname) to offer category-specific suggestions matching the active view.
  4. Localization and Unit Testing:

    • Mapped all new prompt keys in translatePrompt using t(), and updated localization catalogs across all supported locales via npm run i18n.
    • Added 17 new Vitest test cases in promptGenerator.test.ts (34/34 passing).

Testing Done

  • Unit tests: npx vitest run src/prompts/promptGenerator.test.ts (34/34 passed).
  • Linting: ESLint passed with 0 errors and 0 warnings.
  • TypeScript: tsc --noEmit passed with 0 errors.
  • Prettier: prettier --check clean across all modified files.

Fixes #1271

…ggestions

Expand prompt suggestions to handle primary Kubernetes resource kinds including StatefulSet, DaemonSet, Job, CronJob, Ingress, ConfigMap, Secret, PersistentVolumeClaim, PersistentVolume, Namespace, and NetworkPolicy. Add route-aware suggestion fallbacks based on pathname when no resource event is present.

Fixes headlamp-k8s#1271

Signed-off-by: Aamod007 <aamodkumar2006@gmail.com>
@Aamod007

Aamod007 commented Sep 4, 2026

Copy link
Copy Markdown
Author

@ashu8912, whenever you’re free, could you please review this? I’d really appreciate your feedback.

@illume
illume requested a balanced review from Copilot September 29, 2026 06:34

@illume illume 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.

Thanks for working on this.

The commit messages could use some tidying up to match our contribution guidelines. We use Linux kernel style — the contributing guide has the details, and git log shows good examples.

Commits that need attention
  • ai-assistant: Add route-aware and multi-resource contextual prompt suggestions — Contains Fixes #NN; please remove the issue reference from the commit message.
Commit guidelines
  • Use atomic commits focused on a single change.
  • Use the title format <area>: <Description of changes> — description must start with a capital letter.
  • Keep the title under 72 characters (soft requirement).
  • Explain the intention and why the change is needed.
  • Make commit titles meaningful and describe what changed.
  • Do not add code that a later commit rewrites; squash or reorder commits instead.
  • Do not include Fixes #NN in commit messages.

Good examples:

  • frontend: HomeButton: Fix so it navigates to home
  • backend: config: Add enable-dynamic-clusters flag

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 review overview

🟡 Changes recommended

Specialized prompts are truncated or misclassified, and required resource-name interpolation is missing.

Review effort: Balanced
Findings: 5 Medium severity

Open (5)
What changed in this PR

Extends AI Assistant prompt suggestions for additional Kubernetes resources and route-based contexts.

Changes:

  • Adds detail, list, and pathname-aware prompts.
  • Adds localization keys across supported locales.
  • Expands prompt generator unit tests.
File Description
ai-assistant/​src/​prompts/​promptGenerator.ts Adds resource and route-aware prompt generation.
ai-assistant/​src/​prompts/​promptGenerator.test.ts Tests new prompt categories and routes.
ai-assistant/​locales/​en/​translation.json Adds English prompt translations.
ai-assistant/​locales/​cs/​translation.json Adds Czech prompt keys.
ai-assistant/​locales/​de/​translation.json Adds German prompt keys.
ai-assistant/​locales/​es/​translation.json Adds Spanish prompt keys.
ai-assistant/​locales/​fr/​translation.json Adds French prompt keys.
ai-assistant/​locales/​hu/​translation.json Adds Hungarian prompt keys.
ai-assistant/​locales/​id/​translation.json Adds Indonesian prompt keys.
ai-assistant/​locales/​it/​translation.json Adds Italian prompt keys.
ai-assistant/​locales/​ja/​translation.json Adds Japanese prompt keys.
ai-assistant/​locales/​ko/​translation.json Adds Korean prompt keys.
ai-assistant/​locales/​nl/​translation.json Adds Dutch prompt keys.
ai-assistant/​locales/​pl/​translation.json Adds Polish prompt keys.
ai-assistant/​locales/​pt-BR/​translation.json Adds Brazilian Portuguese prompt keys.
ai-assistant/​locales/​pt-PT/​translation.json Adds Portuguese prompt keys.
ai-assistant/​locales/​ru/​translation.json Adds Russian prompt keys.
ai-assistant/​locales/​sv/​translation.json Adds Swedish prompt keys.
ai-assistant/​locales/​tr/​translation.json Adds Turkish prompt keys.
ai-assistant/​locales/​zh-Hans/​translation.json Adds Simplified Chinese prompt keys.
ai-assistant/​locales/​zh-Hant/​translation.json Adds Traditional Chinese prompt keys.

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

Comment thread ai-assistant/src/prompts/promptGenerator.ts Outdated
Comment thread ai-assistant/src/prompts/promptGenerator.ts Outdated
Comment thread ai-assistant/src/prompts/promptGenerator.ts Outdated
Comment thread ai-assistant/src/prompts/promptGenerator.ts Outdated
Comment thread ai-assistant/src/prompts/promptGenerator.ts Outdated
Prioritize kind-specific prompts ahead of generic resource fallbacks so both specialized suggestions are retained within the top-3 limit. Interpolate resource name and namespace into canonical detail prompts while preserving localized display labels. Reorder list-kind prompts before generic list fallbacks, split Job and CronJob suggestions, and restrict route matching to PersistentVolumeClaims.

Signed-off-by: Aamod007 <aamodkumar2006@gmail.com>
@Aamod007

Copy link
Copy Markdown
Author

@illume I've updated the prompt suggestions based on the review feedback (prompt prioritization, interpolation, and route filtering) and added a follow-up commit matching the commit guidelines. When you get a chance, could you please take another look?

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.

ai-assistant: Add route-aware and multi-resource contextual prompt suggestions

3 participants