Skip to content

chore: improve ai agent#418

Merged
zxh326 merged 7 commits intomainfrom
improve-ai-agent
Mar 10, 2026
Merged

chore: improve ai agent#418
zxh326 merged 7 commits intomainfrom
improve-ai-agent

Conversation

@zxh326
Copy link
Collaborator

@zxh326 zxh326 commented Mar 9, 2026

No description provided.

zxh326 added 4 commits March 9, 2026 13:35
Signed-off-by: Zzde <zhangxh1997@gmail.com>
Signed-off-by: Zzde <zhangxh1997@gmail.com>
Signed-off-by: Zzde <zhangxh1997@gmail.com>
Signed-off-by: Zzde <zhangxh1997@gmail.com>
@zxh326 zxh326 requested a review from Copilot March 9, 2026 16:28
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the AI assistant UX and safety by adding client-side chat session history, enhancing tool-call confirmation flow with server-side pending sessions, and simplifying the chatbox open/close behavior.

Changes:

  • Add per-user chat session history (localStorage-backed) and history UI panel with load/delete/new chat actions.
  • Replace stateless mutation execution with server-side pending sessions + SSE continuation endpoint (/ai/execute/continue) using session_id.
  • Refine system prompt language guidance to prefer the user’s latest message language.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ui/src/hooks/use-ai-chat.ts Adds session/history state, localStorage persistence, and new execute/continue streaming flow.
ui/src/contexts/auth-context.tsx Adds Key() helper on user object for per-user history keying.
ui/src/contexts/ai-chat-context.tsx Removes minimized state; simplifies toggle to open/close only.
ui/src/components/selector/namespace-selector.tsx Minor formatting/quote normalization.
ui/src/components/ai-chat/ai-chatbox.tsx Adds history overlay UI and YAML preview for tool calls; adjusts header actions.
pkg/ai/pending_session.go Introduces in-memory pending session store for confirmed mutation continuation.
pkg/ai/openai.go Saves pending sessions on mutation tools and adds continuation path to resume conversation.
pkg/ai/anthropic.go Same as OpenAI path: pending sessions + continuation execution and resume.
pkg/ai/handler.go Replaces /ai/execute with SSE /ai/execute/continue handler.
pkg/ai/agent.go Adds ContinuePendingAction and updates language prompt behavior.
main.go Wires new /ai/execute/continue route.
Comments suppressed due to low confidence (1)

ui/src/components/ai-chat/ai-chatbox.tsx:284

  • wrap-break-word is not a standard Tailwind utility class, and there are no other occurrences in the repo. This likely results in missing word-wrapping for chat bubbles. Consider using Tailwind's break-words (or break-all / whitespace-pre-wrap as appropriate) instead.
      <div
        className={`max-w-[85%] rounded-lg px-3 py-2 text-sm wrap-break-word ${
          isUser
            ? 'bg-primary text-primary-foreground whitespace-pre-wrap'
            : 'bg-muted text-foreground'
        }`}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Zzde <zhangxh1997@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Zzde <zhangxh1997@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

ui/src/components/ai-chat/ai-chatbox.tsx:284

  • wrap-break-word isn’t a standard Tailwind utility and doesn’t appear elsewhere in the UI, so this likely has no effect and messages may not wrap as intended. Use Tailwind’s break-words/break-all (or define a custom utility) instead.
        className={`max-w-[85%] rounded-lg px-3 py-2 text-sm wrap-break-word ${
          isUser
            ? 'bg-primary text-primary-foreground whitespace-pre-wrap'
            : 'bg-muted text-foreground'
        }`}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +72
// Cleanup expired sessions asynchronously
go func() {
if err := model.CleanupExpiredPendingSessions(); err != nil {
klog.V(4).Infof("Failed to cleanup expired pending sessions: %v", err)
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Spawning a goroutine to clean up expired sessions on every save can create many goroutines and repeated DELETE queries under load. Prefer a periodic cleanup job (ticker/background worker) or otherwise rate-limit cleanup.

Copilot uses AI. Check for mistakes.
Signed-off-by: Zzde <zhangxh1997@gmail.com>
@zxh326 zxh326 merged commit acb07de into main Mar 10, 2026
3 checks passed
@zxh326 zxh326 deleted the improve-ai-agent branch March 10, 2026 14:36
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.

2 participants