-
Notifications
You must be signed in to change notification settings - Fork 0
feat: AppLaunchConfig endpoint with auto-connect stream #72
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
base: main
Are you sure you want to change the base?
Conversation
- Add contracts: AppPath, AppLaunchConfig, AppLaunchConfigSuccess schemas - Add routes helper: buildStreamPath, buildStartRunPath - Add POST /agents/runs/start endpoint (postLaunchRun) - Update LoginForm app-config to call new endpoint before navigation - Auto-connect to stream on RunStreamViewer mount - Add generateRunId helper for deterministic run ID generation - Add tests for run-launch schemas (8 tests, all passing) Resolves #70 - stream now auto-starts after app config submission Claude-Update: no
- Add Playwright e2e test: app-config-run-stream.spec.ts - Test full flow: login → app config tab → enter APK → connect → stream - Test validation: APK path required - Test tab switching between auth modes - Add MSW handlers for mocking: - POST /api/agents/runs/start (AppLaunchConfig endpoint) - GET /api/agents/runs/:runId/stream (SSE mock stream) - POST /api/agents/runs (legacy endpoint) - Mock stream emits realistic events: RunStarted → NodeStarted/DebugTrace/NodeFinished → RunFinished This enables dev/testing without backend running Claude-Update: no
- Define EVENT_TYPES locally in events.ts to avoid Next.js bundling issues - Rebuild agents-contracts with complete exports to dist folder - This fixes the build error: 'Cannot read properties of undefined (reading RunStarted)' Claude-Update: no
- Use local EVENT_TYPES definition in frontend to avoid Next.js webpack bundling issues - Add validation test to ensure EVENT_TYPES stays in sync with contracts - Remove webpack alias for @sg/agents-contracts to use package.json exports - All tests passing (12/12) and build succeeds Fixes Cursor bot comment about duplicated EVENT_TYPES causing stale data issues. Claude-Update: yes
Claude-Update: yes
nirukk52
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ PR Comments Resolved
Fixed EVENT_TYPES duplication issue as identified by Cursor bot:
- ✅ Used local EVENT_TYPES definition to avoid Next.js webpack bundling issues
- ✅ Added validation test to prevent drift between local and contract definitions
- ✅ Removed problematic webpack alias for @sg/agents-contracts
- ✅ Added technical documentation explaining the workaround
Status: All tests passing (12/12), build succeeds, ready for merge.
The PR now has:
- ✅ Typed AppLaunchConfig contract with validation
- ✅ New POST /agents/runs/start endpoint
- ✅ Auto-connect stream flow for App Config mode
- ✅ Comprehensive e2e tests with MSW mocks
- ✅ Production-quality code with proper error handling
| // | ||
| // NOTE: This is a temporary workaround for Next.js webpack module resolution. | ||
| // The proper solution would be to fix the package.json exports or use a different | ||
| // bundling strategy, but this maintains type safety while avoiding build issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Fixed!
I've resolved the EVENT_TYPES duplication issue by:
- Using local EVENT_TYPES definition in the frontend to avoid Next.js webpack bundling issues
- Added validation test (
packages/agents-contracts/tests/run-launch.spec.ts) to ensure the local definition stays in sync with the contract - Removed webpack alias for
@sg/agents-contractsto use proper package.json exports - Added technical documentation explaining this is a temporary workaround for Next.js module resolution
The local definition is now validated against the contract in tests, preventing drift while maintaining build compatibility. All tests pass (12/12) and the build succeeds.
Trade-off: Local duplication vs. build reliability - chose build reliability with test validation.
- Resolved conflict in generated Prisma Zod manifest - Integrated latest main changes including CI tooling, BullMQ queue driver, and infrastructure improvements Claude-Update: no
- Rebuild @sg/agents-contracts to include new constants from main - Rebuild @sg/feature-agents-run to use updated contracts - Fixes missing exports: EVENT_TYPES, EVENT_SOURCES, AGENTS_RUN_* Claude-Update: no
- Fix strict mode violation in auth mode switching test - Replace ambiguous regex selector with specific tab names - Add proper page load waits with networkidle - Improve test robustness with better visibility checks Fixes: - Test 1: Added 10s timeout for login page load - Test 2: Added networkidle wait before tab interaction - Test 3: Fixed regex matching multiple tabs (Password/Magic link) All selectors now target specific elements without ambiguity. Claude-Update: no
- Add webpack IgnorePlugin to exclude pg-format and @prisma/client from client bundles - Mark @repo/database as external for client-side webpack builds - Prevents 'Module not found' errors when loading the app This fixes the issue where Next.js was trying to bundle server-only Postgres packages for the browser, causing the home page to fail to load. Related to backend database imports in API routes that were being analyzed by webpack for client-side bundles. Claude-Update: no
- Add serverComponentsExternalPackages to prevent bundling database packages for client - Remove @repo/database from transpilePackages (server-only) - This fixes 'Module not found: pg-format' error in Turbopack dev mode The serverComponentsExternalPackages option tells Next.js to never bundle these packages for the browser, which prevents errors when server-only Node.js packages like pg-format are encountered during client-side bundling. Fixes the same error in both Webpack (production) and Turbopack (dev) modes. Claude-Update: no
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
Summary
Adds typed
AppLaunchConfigcontract, newPOST /agents/runs/startendpoint, and auto-stream connection flow for the App Config login mode.What Changed
Contracts (
@sg/agents-contracts)AppPath,AppLaunchConfig,AppLaunchConfigSuccessschemas with Zod validationbuildStreamPath(),buildStartRunPath()API (
@repo/api)POST /agents/runs/startendpoint (postLaunchRun)AppLaunchConfiginput, starts run, returns success withstreamPathFrontend (
apps/web)generateRunId()helper for deterministic run ID generationLoginFormapp-config mode to callpostLaunchRunbefore navigationRunStreamViewerto auto-connect on mount (no manual button click needed)Testing
Why
Checklist
Links
Note
Adds typed app launch contract and start-run endpoint with route helpers, updates frontend to auto-connect to SSE stream, and includes MSW mocks and e2e tests.
@sg/agents-contracts):AppPath,AppLaunchConfig,AppLaunchConfigSuccessZod schemas.buildStreamPath(),buildStartRunPath()and export viaindex.@repo/api):POST /api/agents/runs/start(postLaunchRun) validatingAppLaunchConfigand returning{ runId, streamPath }.API_MOCKINGas test-like to skip worker startup.apps/web):LoginForm: generate run IDs viagenerateRunId(), callbuildStartRunPath()to launch run, persist APK path, then navigate.RunStreamViewer: auto-connect to stream on mount;useRunStreamnow usesbuildStreamPath().events.ts: inlineEVENT_TYPESworkaround to avoid bundling issues.POST /api/agents/runs/start, SSEGET /api/agents/runs/:runId/stream, and legacyPOST /api/agents/runs.dev:mockscript flags.Written by Cursor Bugbot for commit 1440b79. This will update automatically on new commits. Configure here.