-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Auto-generate and edit session display names #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
Claude Code ReviewSummaryThis PR adds auto-generated and manual display name editing for sessions. The implementation is mostly solid with good patterns, but contains several critical security and architecture issues that must be addressed before merge. Issues by Severity🚫 Blocker Issues1. Missing RBAC Permission Check in PUT Endpoint (handlers/sessions.go:1004-1086)
// After line 1013, add:
ssar := &authv1.SelfSubjectAccessReview{
Spec: authv1.SelfSubjectAccessReviewSpec{
ResourceAttributes: &authv1.ResourceAttributes{
Group: "vteam.ambient-code",
Resource: "agenticsessions",
Verb: "update",
Namespace: project,
},
},
}
res, err := reqK8s.AuthorizationV1().SelfSubjectAccessReviews().Create(ctx, ssar, v1.CreateOptions{})
if err \!= nil || \!res.Status.Allowed {
c.JSON(http.StatusForbidden, gin.H{"error": "Unauthorized to update session"})
return
}2. Goroutine Leak Risk (display_name.go:76-82)
🔴 Critical Issues3. Potential API Key Exposure in Logs (display_name.go:160)
4. Missing Error Context in Async Generation (display_name.go:78-79)
5. Type Safety Violation in SessionContext (display_name.go:331-350)
// Current (line 333):
if repos, ok := spec["repos"].([]interface{}); ok {
// Better:
repos, found, err := unstructured.NestedSlice(spec, "repos")
if err \!= nil || \!found {
// Handle error
}🟡 Major Issues6. Inconsistent Client Usage Pattern (display_name.go:166-168, 264)
7. No Rate Limiting on Display Name Generation (display_name.go:76)
8. WebSocket Integration Not Using User Token (websocket/handlers.go:86-124)
🔵 Minor Issues9. Frontend: Missing Error Toast on Mutation Failure
10. Frontend: Dialog Component Uses Props Correctly ✅
11. Validation Logic Duplication
12. Log Injection Sanitization ✅
Positive Highlights✅ Type-Safe Unstructured Access (display_name.go:282-288, handlers/sessions.go:1044-1052)
✅ User Token Authentication (handlers/sessions.go:1007-1013)
✅ Proper Error Handling (display_name.go:273-276, 307-310)
✅ Input Validation (display_name.go:59-71, handlers/sessions.go:1024-1027)
✅ React Query Best Practices (use-sessions.ts:349-375)
✅ Shadcn UI Components (edit-session-name-dialog.tsx)
✅ Context Timeout (display_name.go:86)
RecommendationsPrioritized Action ItemsMust Fix Before Merge:
Should Fix Before Merge: Nice to Have: Architecture Questions
Testing Recommendations
ConclusionThis is well-structured code that follows most project patterns. The display name generation feature is thoughtfully designed with proper async handling and input validation. However, the missing RBAC check is a security vulnerability that blocks merge. Fix issues #1 and #5, address the recommendations, and this will be ready to ship. Great work on:
🔒 Security Score: 7/10 (would be 9/10 with RBAC fix) 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
Claude Code ReviewSummaryPR #432 adds display name management for agentic sessions. The implementation demonstrates strong adherence to project standards after addressing code review feedback. Issues by SeverityBlocker IssuesNone. All blockers addressed in commits dfe6c3c and b989f5f. Critical Issues1. Missing RBAC Check in Internal Update Function (display_name.go:268)
2. Potential Token Leakage in Error Paths (display_name.go:157-159)
Major Issues3. Missing Structured Error Responses (Next.js API route)
4. Goroutine Documentation (display_name.go:82)
Minor Issues
Positive Highlights
RecommendationsHigh Priority (Before Merge)
Medium Priority (Post-Merge)
Architecture Compliance✅ Backend: User token auth, RBAC, type-safe access, no panics ConclusionStrong engineering practices and diligent attention to code review feedback. All blocker issues addressed. Remaining issues are documentation clarity and minor enhancements. Recommendation: APPROVE with minor post-merge improvements Review completed by Claude Code using project standards 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
- Add RBAC permission check (SelfSubjectAccessReview) in UpdateSessionDisplayName - Remove API key logging to minimize information disclosure - Fix ExtractSessionContext to use unstructured helpers for type safety - Document goroutine lifecycle and timeout bounds in GenerateDisplayNameAsync feat: Add session display name update functionality - Introduced a new endpoint to update the display name of sessions. - Implemented UI components for editing session names in both the session header and sessions section. - Added hooks and API calls to handle display name updates, including success and error notifications. - Enhanced WebSocket message handling to trigger display name generation based on user messages. This update improves user experience by allowing dynamic session name management. fix: Address code review issues for display name feature - Fix unsafe type assertion using unstructured.NestedMap helpers - Add nil check for user client in UpdateSessionDisplayName handler - Add input validation for display name (length, sanitization) - Add session existence check to prevent goroutine leak - Add race condition mitigation (skip if display name already set) - Remove API key metadata from logs - Fix unicode truncation using runes instead of bytes - Add proper error handling to Next.js API route
b989f5f to
a1419b7
Compare
Claude Code ReviewSummaryThis PR adds auto-generated session display names and manual editing capabilities. The feature triggers Claude Haiku to generate descriptive names on first user message and provides UI controls for manual editing. Implementation spans backend API, WebSocket handlers, and frontend UI components. Overall Assessment: Well-structured feature with good separation of concerns. Several critical security and architecture issues require immediate attention before merge. Issues by Severity🚫 Blocker Issues1. SECURITY: Missing User Token Authentication in Display Name Update (components/backend/handlers/sessions.go:1118-1148)
2. CRITICAL: Goroutine Leak Risk (components/backend/handlers/display_name.go:82-88)
🔴 Critical Issues3. Inconsistent K8s Client Usage (components/backend/handlers/display_name.go:172-187)
4. Missing Input Validation on HTTP Handler (components/backend/handlers/sessions.go:1156-1160)
var req struct {
DisplayName string `json:"displayName" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
return
}
// ADD THIS VALIDATION
if errMsg := ValidateDisplayName(req.DisplayName); errMsg != "" {
c.JSON(http.StatusBadRequest, gin.H{"error": errMsg})
return
}5. Race Condition in First Message Detection (components/backend/websocket/handlers.go:218-275)
🟡 Major Issues6. Error Handling: Silent Failures in Goroutine (components/backend/handlers/display_name.go:82-88)
7. Type Safety: Direct Type Assertions Without Checking (components/backend/websocket/handlers.go:252)
8. API Client Initialization: Context from Background (components/backend/handlers/display_name.go:92)
9. Frontend: Missing Error States in Dialog (components/frontend/src/components/edit-session-name-dialog.tsx)
🔵 Minor Issues10. Code Organization: Large Display Name File (components/backend/handlers/display_name.go:362 lines)
11. Logging: Inconsistent Prefixes
12. Hardcoded Values: Secret Name (components/backend/handlers/display_name.go:23)
Positive Highlights✅ Excellent Type Safety: Consistent use of ✅ Security Best Practices:
✅ Good Error Handling Patterns:
✅ Frontend Excellence:
✅ Documentation: Goroutine lifecycle clearly documented (display_name.go:77-81) ✅ Vertex AI Support: Thoughtful implementation of both Anthropic API and Vertex AI auth paths RecommendationsPriority 1 (Before Merge)
Priority 2 (Follow-up PR)
Priority 3 (Nice-to-Have)
Testing Recommendations
Commit Before MergePlease address Issues #4 and #9 before merging. The RBAC security issue (#1) has been properly resolved in the latest commit. Great work on implementing user token authentication! 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
## Summary The display name auto-generation feature (PR #432) requires backend access to Vertex AI when `CLAUDE_CODE_USE_VERTEX=1`. This PR adds the missing configuration: ### Changes 1. **Add Vertex AI env vars** to backend deployment: - `CLOUD_ML_REGION` - `ANTHROPIC_VERTEX_PROJECT_ID` - `GOOGLE_APPLICATION_CREDENTIALS` All sourced from `operator-config` ConfigMap (same as operator). 2. **Mount `ambient-vertex` secret** as volume at `/app/vertex/`: - Contains `ambient-code-key.json` (GCP service account key) - Marked as `optional: true` so deployments without Vertex still work ### Why This Is Needed When `CLAUDE_CODE_USE_VERTEX=1`, the backend must use Vertex AI for Claude API calls (display name generation). Previously, the env vars were set but the actual credentials file wasn't mounted, causing: ``` ANTHROPIC_VERTEX_PROJECT_ID is required when CLAUDE_CODE_USE_VERTEX=1 ``` ### Testing Tested on dev cluster with Vertex AI enabled - display names now generate correctly via Vertex.
Summary
Two-part feature for session display name management:
1. Auto-Generate Display Names
When users send their first message in a session, the backend automatically generates a descriptive display name using Claude Haiku.
displayNameis empty2. Manual Name Editing
Added UI controls to edit session names:
Backend Changes
handlers/display_name.gowith Claude Haiku integrationPUT /api/projects/:projectName/agentic-sessions/:sessionName/displaynameendpointPostSessionMessageWSto trigger auto-generationFrontend Changes
EditSessionNameDialogcomponentuseUpdateSessionDisplayNameReact Query mutationsession-header.tsxandsessions-section.tsxwith edit buttonsTesting