-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: web proactive-notifications (PR #4435 v2) #4845
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
Open
neooriginal
wants to merge
12
commits into
main
Choose a base branch
from
feature/web-proactive-notifications-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d8520a8
feat: web proactive-notifications (PR #4435 v2)
neooriginal d9bf2c8
fix: TypeScript errors and add missing functions
neooriginal 12f1b50
chore: add tsconfig.tsbuildinfo to gitignore
neooriginal fcbc05a
fix: address code review issues
neooriginal 675c6d1
Update web/app/src/lib/screenCapture.ts
neooriginal c8dcc7e
fix: correct API response validation in proactiveAnalysis
neooriginal 3f01425
fix: move ProactiveMonitoringWidget outside recording dropdown
neooriginal 0fa14c4
Revert "fix: move ProactiveMonitoringWidget outside recording dropdown"
neooriginal 8c50a5b
Update HeaderRecordingIndicator.tsx
neooriginal 390408c
finalize
neooriginal f1a5d74
memory proactiveness
neooriginal 00f3747
Merge branch 'main' into feature/web-proactive-notifications-v2
neooriginal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # Claude Code local files | ||
| .claude/ | ||
| web/app/tsconfig.tsbuildinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # --- Firebase (Public Web Config ONLY) --- | ||
|
|
||
| NEXT_PUBLIC_FIREBASE_API_KEY= | ||
| NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN= | ||
| NEXT_PUBLIC_FIREBASE_PROJECT_ID= | ||
| NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET= | ||
|
|
||
| # You MUST fetch these from Firebase Console -> Project Settings | ||
| NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID= | ||
| NEXT_PUBLIC_FIREBASE_APP_ID= | ||
| NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID= | ||
|
|
||
| GEMINI_API_KEY= | ||
|
|
||
| # --- Push Notifications (Web Push / VAPID) --- | ||
| # Firebase Console -> Cloud Messaging -> Web Push certificates | ||
| NEXT_PUBLIC_FIREBASE_VAPID_KEY= | ||
|
|
||
| # --- Backend API Connection --- | ||
| # Map from API_BASE_URL / BASE_API_URL | ||
| NEXT_PUBLIC_API_BASE_URL= | ||
|
|
||
| NEXT_PUBLIC_WS_BASE_URL= | ||
|
|
||
| # --- Analytics (Optional) --- | ||
| NEXT_PUBLIC_MIXPANEL_TOKEN= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /// <reference types="next" /> | ||
| /// <reference types="next/image-types/global" /> | ||
| import "./.next/dev/types/routes.d.ts"; | ||
| import "./.next/types/routes.d.ts"; | ||
|
|
||
| // NOTE: This file should not be edited | ||
| // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| 'use server'; | ||
|
|
||
| import { GeminiResponseSchema } from '@/lib/geminiClient'; | ||
|
|
||
| interface AnalyzeScreenParams { | ||
| imageBase64: string; | ||
| imageMimeType?: string; | ||
| prompt: string; | ||
| systemPrompt: string; | ||
| responseSchema?: GeminiResponseSchema; | ||
| model?: string; | ||
| } | ||
|
|
||
| const DEFAULT_MODEL = 'gemini-2.0-flash'; | ||
| const ALLOWED_MODELS = ['gemini-2.0-flash', 'gemini-1.5-flash', 'gemini-1.5-pro']; | ||
|
|
||
| export async function analyzeScreenAction(params: AnalyzeScreenParams): Promise<string> { | ||
| const apiKey = process.env.GEMINI_API_KEY; | ||
|
|
||
| if (!apiKey) { | ||
| throw new Error('Gemini API key not configured on server'); | ||
| } | ||
|
|
||
| const { | ||
| imageBase64, | ||
| imageMimeType = 'image/jpeg', | ||
| prompt, | ||
| systemPrompt, | ||
| responseSchema, | ||
| model = DEFAULT_MODEL | ||
| } = params; | ||
|
|
||
| // Validate model | ||
| if (!ALLOWED_MODELS.includes(model)) { | ||
| throw new Error(`Invalid model specified. Allowed: ${ALLOWED_MODELS.join(', ')}`); | ||
| } | ||
|
|
||
| // Construct request payload | ||
| const requestBody: any = { | ||
| contents: [ | ||
| { | ||
| parts: [ | ||
| { text: prompt }, | ||
| { | ||
| inline_data: { | ||
| mime_type: imageMimeType, | ||
| data: imageBase64, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| system_instruction: { | ||
| parts: [{ text: systemPrompt }], | ||
| }, | ||
| }; | ||
|
|
||
| if (responseSchema) { | ||
| requestBody.generation_config = { | ||
| response_mime_type: 'application/json', | ||
| response_schema: responseSchema, | ||
| }; | ||
| } | ||
|
|
||
| const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${apiKey}`; | ||
|
neooriginal marked this conversation as resolved.
|
||
|
|
||
| try { | ||
| const response = await fetch(url, { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(requestBody), | ||
| }); | ||
|
neooriginal marked this conversation as resolved.
|
||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text(); | ||
| throw new Error(`Gemini API error: ${response.status} ${response.statusText} - ${errorText}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
|
|
||
| if (data.error) { | ||
| throw new Error(data.error.message); | ||
| } | ||
|
|
||
| const text = data.candidates?.[0]?.content?.parts?.[0]?.text; | ||
| if (!text) { | ||
| throw new Error('No text in response from Gemini API'); | ||
| } | ||
|
|
||
| return text; | ||
| } catch (error: any) { | ||
| console.error('Server Action Analysis Failed:', error); | ||
| throw new Error(error.message || 'Analysis failed'); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.