Repository navigation
feat(popup): migrate popup service to Connect-RPC with server-streaming WatchPopup and polymorphic UI registry - #897
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces parallel chunk parsing, direct YAML serialization, trigram indexing with Roaring Bitmaps, and a sparse bitset representation for filter results to optimize performance, alongside migrating the popup system to Connect-RPC. The reviewer identified several critical improvement opportunities: making DirectYAMLSerializer thread-safe by allocating the buffer locally, serializing ShowPopup calls in PopupManager to prevent concurrent state corruption, refining the chunk partitioning logic in filter_log_cel.go and parallel.go to avoid empty chunks and potential nil pointer dereferences, and removing CPU profiling code from the production path of BuildTrigramIndexWithProgress.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the popup management system in KHI, migrating the backend popup system from REST endpoints to a Connect-RPC service (PopupService) and updating the frontend to dynamically render popup content components (such as text input and OAuth login) based on the protobuf payload, replacing HTTP polling with a Connect-RPC stream. The code review identified several critical issues, including concurrency bugs in PopupManager.ShowPopup that could leak goroutines, a potential server panic from a non-idempotent unsubscribe function in the subscription logic, a race condition in TextPopupContentComponent where out-of-order validation responses could overwrite newer results, and a UI bug in main.component.ts that prevents a new popup dialog from opening when transitioning directly between popups.
…and UI transitions
Summary
This PR migrates the interactive user popup system in KHI from legacy polling-based REST endpoints to a Connect-RPC service featuring server-streaming
WatchPopupand an Open-Closed Principle (OCP) compliant polymorphic UI component registry.Background & Motivation
WatchPopupendpoint with a resilient 30-second server cycle. If an intermediary proxy terminates long-lived streaming connections, the frontend automatically reconnects immediately without stalling or requiring timer polling loops.popup.PopupForminterface, handling its own proto construction, input validation, and answer completion.PopupRegistryservice maps oneof proto payloads to dynamic UI content components instantiated via*ngComponentOutlet.WatchPopup, automatically closing the dialog without client-side periodic polling.API Endpoint Path Changes
GET/api/v1/popupPOST/api/v1/popupvalidate_only).POST/api.v1.PopupService/WatchPopupPOST/api.v1.PopupService/ValidatePopupAnswerPOST/api.v1.PopupService/SubmitPopupAnswerGET/api/v1/oauthKey Changes
1. Protobuf (
proto/api/v1/popup.proto)PopupServicewithWatchPopup(server streaming),ValidatePopupAnswer(unary), andSubmitPopupAnswer(unary).PopupForm.payloadoneof:TextPopupPayload(text inputs with placeholder and validation).OAuthLoginPopupPayload(OAuth authorization flows withauth_url).2. Go Backend
pkg/server/popup:PopupForminterface (BuildProtoForm,Validate,Answer).TextPopupFormimplementation.PopupManagerto manage active forms, stream notifications via channels, and delegate validation/submission to the active form.pkg/api/googlecloud/oauth:popup.PopupFormforoauthTokenPopup, replacing legacy metadata mappings and serving the OAuth authorization URL.pkg/server/api/v1/popup.go:PopupServerdelegating directly toPopupManager./api/v1/popuphandlers and centralizedswitchstatements.3. Angular Frontend
PopupRegistry(popup-registry.service.ts):'text','oauthLogin') to child content components.TextPopupContentComponent: Handles text input forms with real-time validation and submission.OAuthLoginPopupContentComponent: Handles opening the OAuth login window, waiting for server completion, and allowing re-opening.RequestUserActionPopupComponent):*ngComponentOutlet="component; inputs: contentInputs()".PopupManagerImpl(popup-manager-impl.ts):WatchPopupConnect-RPC stream, with automatic reconnect handling.Verification
go test -v ./pkg/server/... ./pkg/api/googlecloud/oauth/...passed.npx ng test --watch=false --browsers=ChromeHeadlesspassed (741/741 tests).TextPopupContentComponentandOAuthLoginPopupContentComponentstories build cleanly (npm run build-storybook).make lint-go,make lint-web,make format-go,make format-web, andmake pre-commitpassed with 0 issues.