Skip to content

feat(ai): add PageSpace model aliases (standard/pro) for AI agents - #207

Merged
2witstudios merged 1 commit into
masterfrom
claude/default-ai-chat-model-kX3RG
Jan 14, 2026
Merged

2witstudios merged 1 commit into
masterfrom
claude/default-ai-chat-model-kX3RG

Conversation

@2witstudios

@2witstudios 2witstudios commented Jan 14, 2026 •

Copy link
Copy Markdown
Owner
  • Add PAGESPACE_MODEL_ALIASES mapping 'standard' -> 'glm-4.5-air' and 'pro' -> 'glm-4.7'
  • Add resolvePageSpaceModel() to convert aliases to actual model IDs
  • New AI agents now default to provider='pagespace' and model='standard'
  • Provider factory resolves aliases before passing to backend
  • Agents can now use 'standard' or 'pro' without knowing underlying model names

Summary by CodeRabbit

Release Notes

  • New Features
    • Agents now created with default AI provider and model settings automatically applied
    • AI model selection now supports user-friendly aliases (standard, pro) for easier configuration

✏️ Tip: You can customize this high-level summary in your review settings.

- Add PAGESPACE_MODEL_ALIASES mapping 'standard' -> 'glm-4.5-air' and 'pro' -> 'glm-4.7'
- Add resolvePageSpaceModel() to convert aliases to actual model IDs
- New AI agents now default to provider='pagespace' and model='standard'
- Provider factory resolves aliases before passing to backend
- Agents can now use 'standard' or 'pro' without knowing underlying model names
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes introduce PageSpace model aliasing (standard, pro) with resolver functions, add default AI provider and model values during agent creation, and integrate alias resolution into the provider factory to map user-friendly aliases to actual model IDs.

Changes

Cohort / File(s) Summary
AI Provider Configuration
apps/web/src/lib/ai/core/ai-providers-config.ts
Added PAGESPACE_MODEL_ALIASES mapping friendly names to model IDs, introduced resolvePageSpaceModel() and isPageSpaceModelAlias() utility functions, extended AI_PROVIDERS.pagespace.models to accept aliases, updated getUserFacingModelName() to resolve aliases before comparison.
Agent Creation & Defaults
apps/web/src/app/api/ai/page-agents/create/route.ts
Added default AI provider ('pagespace') and model ('standard') initialization in agentData, removed separate conditional assignments, updated response payload to return provider/model from agentData, extended AgentData interface with aiProvider and aiModel fields.
Provider Factory Integration
apps/web/src/lib/ai/core/provider-factory.ts
Imported resolvePageSpaceModel, changed currentModel from const to let for reassignment, added conditional alias resolution when provider is 'pagespace'.

Possibly related PRs

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Model aliases spring to life,
With "standard" and "pro" set just right,
Default companions by agent's side,
Resolution flows like rabbit's stride,
Clean configs hopping forward bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main change: adding PageSpace model aliases (standard/pro) for AI agents, which is the core feature across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
apps/web/src/lib/ai/core/ai-providers-config.ts (2)

11-14: Type annotation conflicts with as const assertion.

The explicit Record<string, string> type widens the type, negating the benefit of as const. Either remove the type annotation to let TypeScript infer the literal types, or remove as const if you don't need literal type inference.

🔧 Suggested fix (option 1: rely on inference)
-export const PAGESPACE_MODEL_ALIASES: Record<string, string> = {
+export const PAGESPACE_MODEL_ALIASES = {
   standard: 'glm-4.5-air',
   pro: 'glm-4.7',
 } as const;

29-31: Remove unused isPageSpaceModelAlias or add clarifying comment.

This exported function is unused throughout the codebase. Either remove it if it's no longer needed, or add a brief comment explaining its intended purpose (e.g., if it's meant for external consumers or future use).


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73a25a5 and d7a0cf7.

📒 Files selected for processing (3)
  • apps/web/src/app/api/ai/page-agents/create/route.ts
  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/lib/ai/core/provider-factory.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Never use any types - always use proper TypeScript types
Use camelCase for variable and function names
Use UPPER_SNAKE_CASE for constants
Use PascalCase for type and enum names
Use kebab-case for filenames, except React hooks (camelCase with use prefix), Zustand stores (camelCase with use prefix), and React components (PascalCase)
Lint with Next/ESLint as configured in apps/web/eslint.config.mjs
Message content should always use the message parts structure with { parts: [{ type: 'text', text: '...' }] }
Use centralized permission functions from @pagespace/lib/permissions (e.g., getUserAccessLevel, canUserEditPage) instead of implementing permission logic locally
Always use Drizzle client from @pagespace/db package for database access
Use ESM modules throughout the codebase

**/*.{ts,tsx}: Never use any types - always use proper TypeScript types
Write code that is explicit over implicit and self-documenting

Files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/lib/ai/core/provider-factory.ts
  • apps/web/src/app/api/ai/page-agents/create/route.ts
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: React hook files should use camelCase matching the exported hook name (e.g., useAuth.ts)
Zustand store files should use camelCase with use prefix (e.g., useAuthStore.ts)

Files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/lib/ai/core/provider-factory.ts
  • apps/web/src/app/api/ai/page-agents/create/route.ts
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Format code with Prettier

Files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/lib/ai/core/provider-factory.ts
  • apps/web/src/app/api/ai/page-agents/create/route.ts
**/*ai*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Vercel AI SDK for AI integrations

Files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
apps/web/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/web/src/**/*.{ts,tsx}: Use message parts structure for message content: { parts: [{ type: 'text', text: '...' }] }
For database access, always use Drizzle client from @pagespace/db: import { db, pages } from '@pagespace/db';
Use centralized Drizzle ORM with PostgreSQL for all database operations - no direct SQL or other ORMs
Use Socket.IO for real-time collaboration features - imported from the realtime service at port 3001
Use Vercel AI SDK with async/await for all AI operations and streaming
Use Next.js 15 App Router and TypeScript for all routes and components

Files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/lib/ai/core/provider-factory.ts
  • apps/web/src/app/api/ai/page-agents/create/route.ts
apps/web/src/app/**/route.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/src/app/**/route.{ts,tsx}: In Next.js 15 route handlers, params in dynamic routes are Promise objects and MUST be awaited before destructuring
Use Response.json() or NextResponse.json() for returning JSON from route handlers
Get request body using const body = await request.json();
Get search parameters using const { searchParams } = new URL(request.url);

apps/web/src/app/**/route.{ts,tsx}: In Next.js 15 dynamic routes, params are Promise objects and MUST be awaited before destructuring: const { id } = await context.params;
In Route Handlers, get request body with const body = await request.json();
In Route Handlers, get search parameters with const { searchParams } = new URL(request.url);
In Route Handlers, return JSON using Response.json(data) or NextResponse.json(data)
For permission logic, use centralized functions from @pagespace/lib/permissions: getUserAccessLevel(), canUserEditPage()

Files:

  • apps/web/src/app/api/ai/page-agents/create/route.ts
🧠 Learnings (2)
📚 Learning: 2025-12-22T20:04:40.910Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T20:04:40.910Z
Learning: Applies to **/*ai*.{ts,tsx} : Use Vercel AI SDK for AI integrations

Applied to files:

  • apps/web/src/lib/ai/core/ai-providers-config.ts
  • apps/web/src/app/api/ai/page-agents/create/route.ts
📚 Learning: 2025-12-14T14:54:45.713Z
Learnt from: CR
Repo: 2witstudios/PageSpace PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-14T14:54:45.713Z
Learning: When adding AI providers, follow the integration pattern documented in `docs/3.0-guides-and-tools/adding-ai-provider.md`

Applied to files:

  • apps/web/src/app/api/ai/page-agents/create/route.ts
🧬 Code graph analysis (1)
apps/web/src/lib/ai/core/provider-factory.ts (1)
apps/web/src/lib/ai/core/ai-providers-config.ts (1)
  • resolvePageSpaceModel (21-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint & TypeScript Check
🔇 Additional comments (7)
apps/web/src/app/api/ai/page-agents/create/route.ts (2)

88-102: LGTM! Default provider/model initialization is well-structured.

The default values (pagespace provider with standard model alias) align with the PR objectives. The inline comments clearly document that agents can use friendly aliases. The implementation correctly applies defaults only when values aren't provided in the request body.


144-145: LGTM! Response payload correctly reflects stored values.

Returning agentData.aiProvider and agentData.aiModel ensures the response is consistent with what was persisted, rather than echoing potentially different local variables.

apps/web/src/lib/ai/core/provider-factory.ts (2)

38-38: LGTM! Import aligns with the new aliasing utilities.


90-95: LGTM! Alias resolution is correctly scoped and placed.

The resolution happens early, ensuring that downstream provider initialization (e.g., GLM backend at line 138) receives the actual model ID rather than the alias. The conditional check for pagespace provider prevents unintended transformations for other providers.

apps/web/src/lib/ai/core/ai-providers-config.ts (3)

21-24: LGTM! Clean alias resolution with case-insensitive matching.

The case-insensitive lookup provides good UX, and returning the original input when no alias matches allows actual model IDs to pass through unchanged.


39-41: LGTM! Aliases added to models list for UI selection support.

Adding aliases as valid model keys enables UI components to present them as selectable options. The duplicate display names ("Standard", "Pro") are intentional since both the alias and the actual model ID should show the same user-friendly name.


409-419: LGTM! Alias resolution ensures correct display names.

Resolving the alias before comparison ensures both 'pro' and 'glm-4.7' correctly return 'PageSpace Pro', and similarly for standard. This maintains consistency regardless of whether the caller uses aliases or actual model IDs.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@2witstudios
2witstudios merged commit 571ff43 into master Jan 14, 2026
3 checks passed
@2witstudios
2witstudios deleted the claude/default-ai-chat-model-kX3RG branch January 29, 2026 02:29
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.

2 participants