Skip to content

Pulled updates from Earthscape parent#3

Merged
ModelEarth merged 85 commits intoModelEarth:mainfrom
Earthscape:main
Nov 23, 2025
Merged

Pulled updates from Earthscape parent#3
ModelEarth merged 85 commits intoModelEarth:mainfrom
Earthscape:main

Conversation

@ModelEarth
Copy link
Copy Markdown
Owner

Pull Request

Description

Type of Change

  • 🚀 Feature - New functionality
  • 🐛 Bug fix - Fixes an issue
  • 🗃️ Database migration - Schema changes
  • 📝 Documentation - Updates to docs
  • ⚡ Performance improvement
  • 🎨 UI/UX - Visual or interaction changes
  • ♻️ Refactor - Code restructuring without functional changes
  • 🧪 Test - Adding or updating tests
  • 🔧 Chore - Maintenance tasks

Database Changes

  • ✅ No database changes
  • 📊 Schema changes - Migration file: lib/db/migrations/XXXX_migration_name.sql
  • 🔄 Data migration required
  • 🔒 RLS policy changes
  • 📈 Index additions/modifications

Migration Details (if applicable)

Tables affected:

Migration file:

  • lib/db/migrations/XXXX_migration_name.sql

Backward compatible:

  • Yes
  • No (breaking change - requires coordination)

Rollback script included:

  • Yes
  • No
  • N/A

Impact on existing data:

Verification queries:

Testing

  • ✅ Tested locally
  • ✅ All existing tests pass
  • ✅ New tests added
  • ✅ Manual testing performed
  • ✅ Tested with production-like data

Test Coverage

Screenshots/Videos (if UI changes)

Breaking Changes

  • ⚠️ This PR includes breaking changes

If yes, describe:

Performance Impact

  • No performance impact expected
  • Performance improvements expected
  • Potential performance impact (explain below)

Details:

Security Considerations

  • No security impact
  • Security improvement
  • Requires security review

Details:

Dependencies

New dependencies:

Updated dependencies:

Checklist

  • 📖 Code follows project style guidelines (run pnpm lint)
  • 🔍 Self-reviewed the code
  • 💬 Commented complex/unclear code
  • 📚 Updated relevant documentation (README, API docs, etc.)
  • 🧪 Added/updated tests for new functionality
  • 🔒 Verified RLS policies work correctly (if DB changes)
  • ⚡ Added indexes for new foreign keys (if DB changes)
  • 🏷️ Updated TypeScript types/interfaces
  • ♿ Considered accessibility (if UI changes)
  • 📱 Tested on mobile/responsive (if UI changes)
  • 🌐 No hardcoded strings (using i18n if applicable)

Related Issues

Closes #
Related to #

Additional Context

Deployment Notes

  • Requires environment variable changes
  • Requires manual migration by Super Admin
  • Requires coordination with other PRs
  • Should be deployed during low-traffic hours

Special instructions:


For Reviewers

Focus areas:
1.
2.

Testing instructions:
1.
2.


Super Admin Checklist (for DB migrations)

  • Reviewed migration script syntax
  • Verified backward compatibility
  • Tested on staging/local Supabase
  • Verified rollback script works
  • No data loss risk
  • Performance impact assessed (indexes added?)
  • RLS policies correct and secure
  • Ready to apply to production

claude and others added 30 commits November 16, 2025 20:34
The lockfile was out of sync with package.json, causing deployment failures.
Regenerated the lockfile to include all current dependencies:
- Added @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/openai
- Added @modelcontextprotocol/sdk and @monaco-editor/react
- Added Supabase packages (@supabase/ssr, @supabase/supabase-js)
- Added missing Radix UI components
- Updated drizzle-orm to v0.44.7 and drizzle-kit to v0.31.6
- Added mermaid for diagram rendering
- Removed deprecated packages (next-auth, redis, etc.)
…8BFZ4quJqBCz9ecrHRu

fix: update pnpm-lock.yaml to match package.json
- Add explicit boolean type annotations to Switch onCheckedChange handlers across agent config components
- Install missing @radix-ui packages (avatar, checkbox, collapsible, dropdown-menu, scroll-area, separator, switch)
- Install missing uuid package for activity logger

Fixed type errors in:
- components/admin/agents/chat-model/chat-model-agent-config.tsx
- components/admin/agents/document/document-agent-config.tsx
- components/admin/agents/git-mcp/git-mcp-agent-config.tsx
- components/admin/agents/mermaid/mermaid-agent-config.tsx
- components/admin/agents/provider-tools/provider-tools-agent-config.tsx
- components/admin/agents/python/python-agent-config.tsx
- components/admin/logging-dashboard.tsx

Build now passes successfully.
Removed unnecessary files and dependencies that were not being used:

Files removed:
- playwright.config.ts - No tests exist in the project
- test-tool-config.js - Empty/unused configuration file
- instrumentation.ts - OpenTelemetry not enabled in Next.js config
- package-lock.json - Project uses pnpm, not npm
- tsconfig.tsbuildinfo - Build artifact, should not be committed

Dependencies removed:
- @playwright/test - No tests to run
- @vercel/otel - Only used in removed instrumentation.ts
- @opentelemetry/api - Only needed for instrumentation
- @opentelemetry/api-logs - Only needed for instrumentation

Scripts removed:
- "test" script - No test files exist

Files kept (they ARE being used):
- drizzle.config.ts - Database migrations actively used in build
- biome.jsonc - Linting configuration (used by ultracite)
- middleware.ts - Next.js middleware
- next.config.ts, tsconfig.json, postcss.config.mjs - Core configs

Build verified successful after cleanup.
The Vercel deployment is failing due to stale build cache from recently
removed dependencies (@playwright/test, @vercel/otel, etc.).

Changes:
- Add VERCEL_BUILD_FIX.md with instructions to clear Vercel build cache
- Update .gitignore to include tsconfig.tsbuildinfo (prevent future commits)
- Remove Playwright references from .gitignore (no longer used)

Local builds pass successfully - this is purely a Vercel cache issue.

To fix on Vercel:
1. Go to project Settings → General
2. Clear Build Cache
3. Redeploy

The file can be deleted after the Vercel issue is resolved.
…GvGAhqsPuhs4FStXrPJt

Claude/fix all the things 016m gv g ahqs puhs4 f st xr p jt
Database connections are not available during Vercel's build phase,
only at runtime. This change detects CI/build environments (VERCEL
or CI env vars) and skips migrations during build.

Migrations should be run manually using 'npm run db:migrate' after
deployment or during local development.

Fixes ENETUNREACH error during Vercel build.
…n-01TaboDjzfzdm6PapcEZWcSC

fix: skip database migrations during Vercel build
- Remove conflicting (chat) route group layout and root page
- Move chat/[id] page to app/chat/[id] structure
- Update chat layout with proper sidebar state handling

This fixes the "ENOENT client-reference-manifest.js" error by
eliminating duplicate route definitions that confused Next.js build.
…n-0132WZC1UHDaubYhVhrT7iMg

fix: consolidate route structure to resolve build error
This fixes the database connection pool exhaustion errors in production
(Vercel serverless functions) that were causing 400 errors on /api/history.

Changes:
- Add serverless-compatible postgres client configuration
- Limit max connections to 1 per function instance (instead of default 10)
- Disable prepared statements (incompatible with serverless)
- Add connection timeouts for better error handling

Issue: Each serverless function instance was creating a postgres client
with 10 connections, quickly exhausting the database connection pool
under concurrent load. This didn't occur locally because local dev runs
a persistent Node.js process that reuses a single client.

Fixes production errors:
- Error: An error occurred while executing a database query
- Failed to get chats by user id (400 status code)
…14ypNGdDdYGhZM2iqJNECfj

fix: configure postgres client for serverless environment
The Drizzle schema had type mismatches with the actual database schema:
- Chat.totalCost was text instead of decimal(10,6)
- Message_v2.cost was text instead of decimal(10,6)
- usage_logs cost fields were text instead of decimal(10,6)

This mismatch was causing query failures in /api/history endpoint.
Also added proper default values to match database constraints.
…SwixwJpCANXccBE5V1NRf

fix: correct decimal type definitions in drizzle schema
- Replace createBrowserClient with createAdminClient in logging system
- Update SSL mode to "require" for Supabase connections
- Fix database connection issues in production (Vercel)

The logging system was incorrectly using createBrowserClient (meant for
client-side) in server-side code, causing database query failures in
production. Now using createAdminClient which properly handles
server-side authentication with service role key.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…or logger

- Update error logger to detect browser vs server context
- Use createAdminClient for server-side error logging
- Use createBrowserClient only for client-side error logging
- Fixes remaining database connection issues in production

The error logging system was using createBrowserClient with service
role key on the server-side, which causes issues in production.
Now properly detects the runtime context and uses the appropriate
Supabase client.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Created comprehensive test suite for GoogleChatAgent with 39 tests
- Tests cover agent initialization, configuration, and core functionality
- All tests passing: agent init, API key management, GitHub PAT, model selection,
  thinking mode detection, tool building delegation, file input support, error handling
- Updated docs/testing.md to mark Chat Agent Tests as complete

Coverage areas:
- Agent initialization with valid/invalid configs
- API key setting and propagation to config loader
- GitHub PAT management
- Model selection and retrieval
- Thinking mode support detection
- Model configuration methods for all agent types
- Agent configuration loading
- File input support and allowed file types
- Comprehensive error handling

All 39 tests passing successfully.
Implemented 22 unit tests covering:
- Tool creation for all agent types (Provider, Document, Mermaid, Python, Git MCP)
- Tool enablement validation based on config
- Parameter validation with error handling
- Tool execution delegation to specialized agents
- Error handling in tool execution

All tests passing (26/26 total including existing tests).
Updated docs/testing.md to mark Tool Builder Tests as complete.
Implemented 30 comprehensive unit tests for the AgentConfigLoader class covering:

✅ Agent config loading from database (all 5 agent types)
✅ Config caching and instance reuse
✅ API key propagation to all agents (Google API key & GitHub PAT)
✅ Agent initialization on demand
✅ Config validation (enabled/disabled, missing configs, errors)
✅ Model configuration for all agents
✅ Complex integration scenarios

All tests pass successfully (34/34 tests passing).

Updated docs/testing.md to mark Phase 2 Config Loader Tests as complete.
Implement Phase 2 of the testing plan with complete coverage for chat database queries:

- Created tests/unit/lib/db/queries/chat.test.ts with 21 test cases
- Test chat creation (saveChat) with success and error scenarios
- Test chat retrieval by ID (getChatById) including not found cases
- Test chat list for user (getChatsByUserId) with pagination support
- Test chat deletion (deleteChatById) including cascading deletes
- Test chat updates (updateChatVisiblityById, updateChatLastContextById)
- Test comprehensive error handling for all operations
- All 25 tests passing (including example tests)

Updated docs/testing.md to mark chat query tests as complete.

Test coverage includes:
- Successful operations
- Error handling and exceptions
- Edge cases (null values, not found scenarios)
- Database error scenarios
- Pagination logic
- ChatSDKError validation
- Created comprehensive test suite for document query functions
- Tests cover all 7 required scenarios:
  * Document creation (version 1) - 3 tests
  * Document update (new version) - 3 tests
  * Version retrieval - 3 tests
  * Version list for document - 3 tests
  * Latest version retrieval - 3 tests
  * Document deletion - 4 tests
  * Version comparison query - 4 tests
- All 23 tests passing successfully
- Updated docs/testing.md with completed checkboxes
- Mocked database and server-only module for unit testing

Tests validate:
- Document versioning system
- Error handling with ChatSDKError
- Metadata support
- Parent version tracking
- Suggestion cascade deletion
- Version comparison capabilities
Added comprehensive unit tests for message database operations:
- Message creation (saveMessages)
- Message retrieval for chat (getMessagesByChatId)
- Message deletion (deleteMessagesByChatIdAfterTimestamp)
- Message pagination (large message sets, ordering)
- Single message retrieval (getMessageById)

Total: 15 passing tests covering all message query functions
Updated docs/testing.md to mark Message Query Tests as complete
Implemented 43 comprehensive unit tests for file processing functionality:

Validation Tests:
- Image file validation (PNG, JPG, WebP, GIF)
- PDF file validation
- Code file validation (Python, JavaScript, TypeScript, JSON, text)
- File size validation (reject >10MB, boundary cases)
- File type rejection (video, audio, archive, executable, binary)
- Required properties validation

Content Extraction Tests:
- Image content extraction with size calculation
- PDF file handling
- Code file content extraction with syntax highlighting markers
- Text and JSON file extraction
- Malformed JSON graceful handling
- Base64 encoding support for binary data

Error Handling Tests:
- Fetch failures
- Network errors
- Timeout handling

Edge Cases:
- Empty files
- Large files
- Special characters in filenames
- Uppercase extensions
- Files without extensions

All 43 tests passing successfully.
Updated docs/testing.md to mark File Processing Tests as complete.
Completed Phase 2: Storage Manager Tests with comprehensive coverage

Added tests for:
- API key storage (setAPIKey)
- API key retrieval (getAPIKey)
- API key deletion (removeAPIKey)
- Settings persistence (GitHub PAT, integrations)
- Settings retrieval (getGitHubPAT, getGitHubIntegration)
- Event listeners and storage events
- Edge cases (special characters, long keys, unicode)
- Error handling (corrupted data, quota exceeded)

Test Results:
- 43 comprehensive test cases
- All tests passing (100%)
- Full coverage of core storage functionality

Updated docs/testing.md to mark Storage Manager tests as complete.
- Implemented 34 unit tests for admin configuration database queries
- Test coverage for all CRUD operations (Create, Read, Update, Delete)
- Added config summary generation tests
- Validation helper function tests (isValidAgentConfigKey, validateAgentConfigData)
- All tests passing (38/38)

Tests include:
- Config retrieval (getAdminConfig, getAllAdminConfigs)
- Config creation with validation
- Config update with validation
- Config deletion with proper error handling
- Config summary generation with model integration
- Edge cases and error scenarios

Updated:
- tests/setup.ts: Added server-only module mock for server component testing
- docs/testing.md: Marked Admin Query Tests as complete
…s-0142hd4RzEj6CJHPfgZQAkh3

feat: implement Phase 2 Chat Agent unit tests
…-0159bWeNJoXeFcNiEpzmZfED

feat: add comprehensive unit tests for AgentToolBuilder
ananthpai1998 and others added 28 commits November 17, 2025 20:32
…ests-01D5yexmFDP4zXcSrJR6XFxo

Add Phase 3: Admin API Integration Tests
Add comprehensive E2E test suite for document creation workflow covering:
- Requesting document creation
- Watching real-time streaming
- Document appearing in artifact panel
- Editing document
- Saving new version
- Viewing version history
- Comparing versions
- Reverting to previous version

Additional coverage:
- Error handling
- Multiple documents in same chat
- Rapid edits handling
- Document persistence across page refresh

Update testing documentation to mark Document Creation Journey as complete.
Implement Phase 4: E2E Tests - Python Code Journey

This commit adds comprehensive end-to-end tests for the Python code
execution feature, covering the complete user journey from requesting
Python code to executing and modifying it.

Tests implemented:
- Request Python code from chat interface
- Verify code appears in Monaco editor with syntax highlighting
- Switch between editor and console tabs
- Execute Python code and verify output
- Modify code and re-run successfully
- Handle Python execution errors gracefully
- Display loading states during execution
- Toggle console visibility

The test suite includes 9 comprehensive test cases that validate:
1. Python code generation and display
2. Syntax highlighting in Monaco editor
3. Console tab switching functionality
4. Code execution and output display
5. Output viewing in console
6. Code modification and re-execution
7. Error handling for invalid Python code
8. Loading state indicators
9. Console toggle button functionality

Files changed:
- tests/e2e/python-execution.spec.ts (new): Complete test suite
- docs/testing.md: Updated to mark Python Code Journey tests as complete

All tests follow Playwright best practices and include proper waiting
strategies, error handling, and assertions.
…s-019QaN6pJXQqrJPTP3VsYxTy

Add Phase 3 Document Lifecycle integration tests
…01QHD6bqzyaVgkC9AyYL7uEn

Add Phase 3: Authentication Integration Tests
…ts-01ABBRt4BvCx6kgXnZoY8sxU

Add Phase 3 Multi-Agent Orchestration Integration Tests
Add comprehensive E2E test suite for complete chat session user journeys:
- Test 1: Complete first-time user flow (navigation, registration, login)
- Test 2: API key entry and validation in localStorage
- Test 3: Model selection from dropdown
- Test 4: Sending first message
- Test 5: Receiving AI response
- Test 6: Multi-turn conversation with message persistence
- Test 7: Chat persistence after page refresh

The test suite includes helper functions for common operations:
- loginUser: Handles user authentication flow
- setApiKey/getApiKey: Manages API key in localStorage
- sendMessage: Sends chat messages and waits for display
- waitForAIResponse: Waits for streaming completion
- selectModel: Handles model dropdown selection

All 7 tests are properly structured using Playwright best practices
with appropriate wait conditions, selectors, and assertions.

Updated docs/testing.md to mark all New User Chat Session E2E tests
as completed [x].

Tests verified with: npx playwright test --list
Result: 7 tests successfully recognized in 1 file
Implemented comprehensive streaming integration tests covering:
- Document streaming (create, update, revert)
- Python code streaming (create, update, fix, revert)
- Mermaid diagram streaming (create, update, fix, revert)
- Stream interruption handling for all artifact types
- Stream resumption after interruption
- Data integrity verification after resume

All 19 tests passing successfully.
Implemented comprehensive E2E tests for GitHub MCP integration journey:
- Test entering GitHub PAT
- Test connecting to GitHub
- Test selecting repository
- Test browsing files
- Test loading file content
- Test asking questions about code
- Test AI using GitHub context
- Test error handling and validation
- Test multi-file selection
- Test repository metadata display

Updated docs/testing.md to mark Phase 4 GitHub MCP Journey tests as complete.
Implemented complete E2E test suite for Mermaid diagram functionality:
- Test diagram creation and streaming
- Test live preview rendering
- Test code editing functionality
- Test preview updates after edits
- Test syntax error handling and display
- Test diagram export capabilities
- Test version control for diagrams
- Test different diagram types (flowchart, sequence, class, state)
- Test zoom and pan controls
- Test edge cases (empty diagrams, large diagrams)

Updated docs/testing.md to mark Phase 4 Mermaid Diagram Journey tasks as complete.

All tests follow Playwright best practices with proper selectors, timeouts,
and graceful error handling.
Implemented Phase 4 E2E tests for admin configuration workflow:

✅ Admin Access Tests
- Admin user can access admin panel
- Non-admin user redirected to home
- Unauthenticated user redirected to login

✅ Provider Selection Tests
- Navigate to Google AI configuration
- Navigate to OpenAI configuration
- Navigate to Anthropic configuration
- Back to dashboard navigation

✅ Agent Configuration Tests
- Display Chat Model Agent configuration form
- Switch between agent configuration tabs
- Update and save Chat Model Agent configuration
- Persist configuration changes after reload
- Enable/disable agent tools
- Update rate limit settings

✅ Configuration Effect Verification Tests
- Verify configuration loaded on admin dashboard
- Show configuration summary

✅ Error Handling Tests
- Handle save errors gracefully
- Handle network errors during config load

✅ Navigation and Breadcrumbs Tests
- Display correct breadcrumbs
- Navigate using breadcrumb links
- Navigate back to chat from admin panel

✅ Multi-Provider Configuration Tests
- Maintain separate configurations for different providers

Test Infrastructure:
- Created auth-helpers.ts for E2E authentication utilities
- Setup functions for creating admin/regular users
- Login/logout helpers for Playwright tests
- Session management for authenticated E2E tests

Files:
- tests/e2e/admin/admin-config.spec.ts (438 lines, 17+ test scenarios)
- tests/helpers/auth-helpers.ts (authentication utilities)
- docs/testing.md (updated with completed checkboxes)

All 7 test scenarios from Phase 4 Admin Configuration Journey are now implemented and marked complete.
…s-01Gf3n1FKbD5jGBZnBbtd9B4

Add comprehensive Model Selector component tests
…ests-012B9v4itLMYTQkpxnog5iBC

Implement E2E tests for document creation journey (Phase 4)
…sts-01S8t52yxVrkiGxDLSn6mZws

Add comprehensive E2E tests for Python code execution journey
…017hGGhmy953tYFez37AU1gf

Implement Phase 4 E2E tests: New User Chat Session
…ests-017LBfMhkAVBr5QgAXfmsBSp

Add Phase 3 streaming integration tests
…Tq13pvXQbWSv7uGyk5rLLC

Add GitHub MCP E2E integration tests
…ts-014vxmmCpS3FQX6tgVdS5cxc

Add comprehensive E2E tests for Mermaid diagram journey
…01QF8LwX9ewGp3d2m9Cjv94W

Add comprehensive E2E tests for Admin Configuration Journey
Updated vitest configuration to be compatible with latest vitest v8 coverage provider:
- Removed deprecated 'all' property from coverage options
- Moved coverage threshold properties (lines, functions, branches, statements) under 'thresholds' object
- Removed deprecated 'poolOptions' configuration

These changes resolve TypeScript errors that were preventing the build from succeeding.
…crU7GPeBbgXJrh56Ui

Fix build errors in vitest.config.ts
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 23, 2025

@ananthpai1998 is attempting to deploy a commit to the modelearth's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ModelEarth ModelEarth merged commit 4af10d3 into ModelEarth:main Nov 23, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants