feat(ui): add Lighthouse contextual transport core#12068
feat(ui): add Lighthouse contextual transport core#12068alejandrobailo wants to merge 4 commits into
Conversation
|
✅ No Conflicts No conflict markers, and the branch merges cleanly into its base. |
📝 WalkthroughWalkthroughAdds typed Lighthouse UI context contracts, bounded compilation and transport, context-aware chat submission and retry snapshots, and v2 adapter support for contextual or legacy text-only messages. ChangesLighthouse context messaging
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ChatStore
participant ContextCompiler
participant LighthouseAdapter
participant LighthouseAPI
User->>ChatStore: submitMessage(displayText, context)
ChatStore->>ContextCompiler: prepareLighthouseContext(context)
ContextCompiler-->>ChatStore: compiled context snapshot
ChatStore->>LighthouseAdapter: send displayText and context
LighthouseAdapter->>LighthouseAPI: send contextual message payload
LighthouseAPI-->>LighthouseAdapter: response
LighthouseAdapter-->>ChatStore: message result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔒 Container Security ScanImage: ✅ No Vulnerabilities DetectedThe container image passed all security checks. No known CVEs were found.📋 Resources:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui/app/`(prowler)/lighthouse/_actions/lighthouse-v2.adapter.ts:
- Around line 264-274: Update buildAgentText in the lighthouse context transport
module to accept and reuse the already-validated apiContext, then pass that
value from the adapter’s contextual message branch instead of having
buildAgentText revalidate input.context. Preserve the existing text output and
non-context path while ensuring each context envelope is parsed only once per
send.
In `@ui/app/`(prowler)/lighthouse/_lib/chat-store.ts:
- Around line 131-134: The retry context bypass currently relies on mutable
closure state and call ordering. Remove retryContextOverride and update
submitMessage to accept an explicit internal option indicating whether to bypass
the context gate; have retryLastMessage pass that option while normal callers
retain the default behavior, preserving reuse of the original validated
snapshot.
In `@ui/lib/lighthouse/context/compiler.ts`:
- Around line 29-65: Update the candidate loop in compileLighthouseContext to
ignore schema-parse failures rather than returning undefined, while continuing
to collect valid same-scope items. Preserve the existing scope filtering,
deduplication, ordering, and size-based fallback behavior for the successfully
parsed candidates.
In `@ui/lib/lighthouse/context/transport.ts`:
- Around line 69-146: Update toApiContextItem with an explicit return type and
an exhaustive default branch that assigns the unhandled item to never and
returns or throws through the established guard pattern. Ensure any future
LIGHTHOUSE_CONTEXT_KIND addition causes a compile-time failure instead of
silently returning undefined, while preserving all existing serialization cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d97d4258-b973-4193-aa2f-549724356012
📒 Files selected for processing (13)
ui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.test.tsui/app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.tsui/app/(prowler)/lighthouse/_lib/chat-store.test.tsui/app/(prowler)/lighthouse/_lib/chat-store.tsui/app/(prowler)/lighthouse/_lib/messages.test.tsui/app/(prowler)/lighthouse/_lib/messages.tsui/app/(prowler)/lighthouse/_types/sessions.tsui/lib/lighthouse/context/compiler.tsui/lib/lighthouse/context/context.test.tsui/lib/lighthouse/context/schema.tsui/lib/lighthouse/context/transport.test.tsui/lib/lighthouse/context/transport.tsui/types/lighthouse-context.ts
Context
Lighthouse needs a bounded UI-only context contract that preserves the text shown to the user while prioritizing the page and active side-panel detail. This is PR 1 of 2 and is the base for #12069.
Description
text,display_text, andui_context, while preserving non-contextual payloads, legacy{ text }history, and the Lighthouse v1 flow.No API, MCP Server, dependency, or visual changes are included. The approved user-visible changelog fragment ships in #12069; this foundation PR uses the
no-changeloglabel.Steps to review
cd ui.pnpm test --run lib/lighthouse/context/context.test.ts lib/lighthouse/context/transport.test.ts 'app/(prowler)/lighthouse/_actions/lighthouse-v2.adapter.test.ts' 'app/(prowler)/lighthouse/_lib/messages.test.ts' 'app/(prowler)/lighthouse/_lib/chat-store.test.ts'.pnpm run healthcheck.Validation performed locally:
pnpm run healthcheckpassed TypeScript, ESLint, and Prettier.Checklist
Community Checklist
no-changelog.SDK/CLI
UI
API
MCP Server
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.