Skip to content

fix(mobile): resolve three TypeScript CI failures in @promptos/mobile type-check#2

Merged
SMSDAO merged 11 commits intomainfrom
copilot/fix-ci-failing-type-check
May 6, 2026
Merged

fix(mobile): resolve three TypeScript CI failures in @promptos/mobile type-check#2
SMSDAO merged 11 commits intomainfrom
copilot/fix-ci-failing-type-check

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

  • Merge PR [WIP] Add PromptOS Desktop AI Agent core functions #1 code into this branch
  • Update apps/mobile/tsconfig.json with "module": "esnext" to fix TS1323
  • Add @react-native-async-storage/async-storage to apps/mobile/package.json to fix TS2307
  • Add expo-constants to apps/mobile/package.json dependencies
  • Update apps/mobile/src/screens/OptimizerScreen.tsx to use expo-constants instead of process.env (fix TS2580) and static import instead of dynamic import
  • Simplify expo-constants type assertion
  • Regenerate pnpm-lock.yaml using pnpm v8.15.9 (matching CI's pnpm/action-setup@v3 version: 8) — fixes ERR_PNPM_LOCKFILE_CONFIG_MISMATCH that blocked pnpm install --frozen-lockfile
  • Verify pnpm install --frozen-lockfile succeeds (CI simulation)
  • Verify pnpm turbo run type-check passes (13/13 tasks successful)
Original prompt

Fix CI failing @promptos/mobile#type-check in PR #1.

CI (.github/workflows/ci.yml) runs pnpm turbo run type-check and currently fails with TypeScript errors in apps/mobile/src/screens/OptimizerScreen.tsx:

  • TS2580: Cannot find name process (use of process.env["EXPO_PUBLIC_API_URL"])
  • TS1323: Dynamic imports require a compatible tsconfig compilerOptions.module
  • TS2307: Cannot find module @react-native-async-storage/async-storage

Make changes that:

  1. Ensure TypeScript can compile with dynamic import usage (or remove dynamic import) by updating apps/mobile/tsconfig.json appropriately.
  2. Add missing dependency @react-native-async-storage/async-storage to apps/mobile/package.json (and update lockfile as needed).
  3. Remove reliance on Node global process in the mobile app type-check by switching to an Expo-compatible config approach (prefer expo-constants), or otherwise properly type it without polluting RN with Node globals.

Keep changes minimal and aligned with Expo/React Native conventions. Ensure pnpm turbo run type-check passes.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for failing job 74552942938. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failing job 74552942938 is failing in @promptos/mobilepnpm run type-check (tsc --noEmit) with three TypeScript errors in apps/mobile/src/screens/OptimizerScreen.tsx at commit a01d02257460ec96f8b56e09679983c833da2da3:

  • TS2580: Cannot find name 'process' (line 21)
  • TS1323: Dynamic imports are only supported when the '--module' flag is set to ... (line 36)
  • TS2307: Cannot find module '@react-native-async-storage/async-storage' or its corresponding type declarations. (line 36)

Below are focused fixes that address each error.


1) Fix process.env typing in Expo (TS2580)

Problem line: OptimizerScreen.tsx uses:

const API_URL = process.env["EXPO_PUBLIC_API_URL"] ?? "http://localhost:3000";

In an Expo/React Native TS project, process is not typed unless Node types are present (and you generally don’t want full Node globals in RN).

Recommended fix (Expo-native): use expo-constants

Use Constants.expoConfig?.extra or Constants.expoConfig?.hostUri patterns. Since you’re using an EXPO_PUBLIC_ env var, a common pattern is to read it via Constants.expoConfig?.extra (populated from app.config.js/ts or app.json).

Code change (apps/mobile/src/screens/OptimizerScreen.tsx):

import Constants from "expo-constants";

// Prefer configuring this in app config (extra) and read it here.
const API_URL =
  (Constants.expoConfig?.extra as { EXPO_PUBLIC_API_URL?: string } | undefined)
    ?.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";

If you do want to keep process.env in this file, then add Node types:

Add dev dependency (apps/mobile/package.json):

"devDependencies": {
  "@types/node": "^20.0.0",
  "@babel/core": "^7.24.0",
  "@types/react": "~18.2.79",
  "typescript": "^5.4.5"
}

…but for Expo/RN, expo-constants (or a typed env approach) is typically cleaner than enabling Node globals.


2) Fix dynamic import() module setting (TS1323)

You have a dynamic import here:

const { getItem } = await import("@react-native-async-storage/async-storage").then(
  (m) => m.default
);

Your apps/mobile/tsconfig.json extends expo/tsconfig.base and does not explicitly set compilerOptions.module. The current module target is not compatible with dynamic import during type-check.

Fix: set module to a supported value (ESNext is typical for Expo)

Update apps/mobile/tsconfig.json:

{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "strict": true,
    "module": "esnext",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.d.ts", "expo-env.d.ts"],
  "exclude": ["node_modules"]
}

This directly resolves the TS1323 error.

(Alternative: remove the dynamic import and use a normal static import; see next section.)


3) Install missing dependency (TS2307)

TypeScript can’t resolve @react-native-async-storage/async-storage because it is not listed in apps/mobile/package.json dependencies. The file imports it dynamically, but TypeScript still needs to resolve the module.

Fix: add AsyncStorage to mobile dependencies

Add to apps/mobile/package.json dependencies:

"dependencies": {
  "@react-native-async-storage/async-storage": "^1.23.1",
  "...": "..."
}

Then run install (repo root):

  • pnpm install

Optional simplification: switch to static import

Once the dependency is present, you can avoid the dynamic import entirely (and this also makes TS con...

This pull request was created from Copilot chat.

Copilot AI and others added 7 commits May 5, 2026 13:02
- Root: pnpm workspaces, Turborepo, tsconfig.base, .gitignore, .env.example
- packages/contracts: billing, access, usage, ai, plugin, sync, web3 contracts (Zod-validated)
- packages/services: Stripe, Firebase, AI router (OpenAI/Claude/Gemini), plugin engine
- packages/middleware: JWT auth, billing tier, RBAC, usage/rate-limit middleware
- packages/ui: GlassCard, NeonButton, AICommandBar, PromptCard, BillingDashboard, PluginTile (NEON GLASS OS theme)
- packages/config: Zod-validated env config
- apps/web: Next.js 14 App Router, API routes (billing, ai, plugins, usage, stripe webhook), dashboard + optimizer pages
- apps/desktop: Electron 28 main process + preload, electron-builder config
- apps/mobile: React Native Expo 50, bottom tab nav, optimizer + dashboard screens
- Docker: Dockerfile.web, docker-compose.yml
- CI/CD: GitHub Actions ci.yml (lint + type-check + build), deploy-web.yml (Vercel)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
- Add explicit permissions: read to all GitHub Actions jobs
- Add /api/health route to fix docker-compose health check
- Implement Redis singleton to avoid repeated connection creation
- Use lazy initialization for Stripe client with fail-fast env validation
- Validate STRIPE_WEBHOOK_SECRET before use in webhook handler

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
- tailwind: move custom colors to theme.extend.colors to preserve Tailwind defaults (text-red-*, text-yellow-*, etc.)
- usage/summary: fix Firestore path to use flat 'usage/{userId}_{period}' (odd segments)
- stripe: use invoice.subscription_details.metadata.userId instead of customer_email in payment_failed handler
- auth: fail fast with clear error when JWT_SECRET is not set
- ai router: honor targetModel in optimizePrompt() instead of always using GPT_4O_MINI
- AICommandBar: sync internal model state via useEffect when selectedModel prop changes
- plugin engine: add registerPluginModule() API; getOrCreateSandbox throws clear error when module not loaded instead of silent no-op
- billing/checkout: remove successUrl/cancelUrl from client schema; URLs always server-generated
- ai/optimize route: switch to withOptionalAuth to allow unauthenticated access; pass targetModel through
- mobile OptimizerScreen: attach Bearer token from AsyncStorage when available
- security: upgrade next 14.2.4 -> 14.2.35, electron ^28.3.3 -> ^39.8.1
- fix: update @promptos/middleware next peer dep to ^14.2.35 to resolve NextRequest type mismatch"

Agent-Logs-Url: https://github.com/Algodons/PromptOS/sessions/95f215e6-a99f-4e13-80e8-6a4f3a9314dc

Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
Copilot AI and others added 3 commits May 6, 2026 05:25
Co-authored-by: SMSDAO <144380926+SMSDAO@users.noreply.github.com>
@SMSDAO SMSDAO requested a review from Copilot May 6, 2026 05:32
Copilot AI changed the title [WIP] Fix CI failing @promptos/mobile type-check fix(mobile): resolve three TypeScript CI failures in @promptos/mobile type-check May 6, 2026
Copilot AI requested a review from SMSDAO May 6, 2026 05:34
Copilot finished work on behalf of SMSDAO May 6, 2026 05:34
Copy link
Copy Markdown
Contributor

@SMSDAO SMSDAO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot merge passable only after repair don't no drift ! Strictly fix CI Builds all tests must pass before we merge

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to resolve CI TypeScript failures in @promptos/mobile (Expo/React Native) by adjusting the mobile TypeScript config and dependencies, and it also brings in a large set of monorepo scaffolding and shared packages (contracts/services/middleware/ui/config) plus web/desktop app foundations and CI/deploy tooling.

Changes:

  • Fix @promptos/mobile type-check by setting tsconfig module target, adding missing dependencies, and switching runtime config access to expo-constants.
  • Introduce shared workspace packages (@promptos/contracts, @promptos/services, @promptos/middleware, @promptos/ui, @promptos/config) and wire them into the web app.
  • Add/standardize Turborepo + pnpm workspace setup, CI workflows, and Docker/Vercel deployment configuration.

Reviewed changes

Copilot reviewed 79 out of 82 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
turbo.json Adds Turborepo pipeline configuration for build/lint/type-check/test/clean.
tsconfig.base.json Introduces a strict base TypeScript configuration for workspace packages/apps.
pnpm-workspace.yaml Defines workspace package globs for pnpm.
package.json Root workspace scripts (turbo) and devDependencies.
Dockerfile.web Container build for the Next.js web app using pnpm + turbo.
docker-compose.yml Compose setup for web + redis.
.gitignore Standard ignores for node/turbo/next/expo/electron artifacts and env files.
.env.example Root env template covering auth/stripe/ai/firebase/walletconnect/ratelimit.
.github/workflows/ci.yml CI workflow running pnpm turbo run type-check and lint, plus package builds.
.github/workflows/deploy-web.yml Vercel deployment workflow for main.
apps/web/package.json Web app dependencies/scripts (Next.js 14) and workspace package usage.
apps/web/tsconfig.json Web TS config aligned to Next + bundler resolution and path aliases.
apps/web/next.config.js Next config enabling transpilePackages and server external packages.
apps/web/next-env.d.ts Next-generated TS ambient references.
apps/web/postcss.config.js PostCSS config enabling Tailwind + autoprefixer.
apps/web/tailwind.config.ts Tailwind config extending the shared UI config and setting content globs.
apps/web/.env.example Web-scoped env template referencing the root env example.
apps/web/src/app/layout.tsx App Router root layout and global font/style setup.
apps/web/src/app/globals.css Global Tailwind layers and shared “glass/neon” component styles.
apps/web/src/app/page.tsx Marketing/home landing page.
apps/web/src/app/dashboard/page.tsx Dashboard placeholder UI.
apps/web/src/app/optimizer/page.tsx Client-side optimizer UI calling /api/ai/optimize.
apps/web/src/app/api/health/route.ts Health endpoint with timestamp/version response.
apps/web/src/app/api/ai/optimize/route.ts Optional-auth optimize endpoint delegating to aiRouterService.optimizePrompt.
apps/web/src/app/api/ai/complete/route.ts Auth + rate-limited AI completion endpoint validating request schema.
apps/web/src/app/api/usage/summary/route.ts Usage summary endpoint reading subscription tier and usage docs from Firestore.
apps/web/src/app/api/billing/checkout/route.ts Checkout session creation using Stripe service and server-generated URLs.
apps/web/src/app/api/billing/portal/route.ts Billing portal session creation for existing Stripe customers.
apps/web/src/app/api/billing/cancel/route.ts Subscription cancellation endpoint.
apps/web/src/app/api/webhooks/stripe/route.ts Stripe webhook handler mapping Stripe events to Firestore + custom claims updates.
apps/web/src/app/api/plugins/install/route.ts Plugin install endpoint validating manifest and calling pluginEngine.installPlugin.
apps/web/src/app/api/plugins/uninstall/route.ts Plugin uninstall endpoint calling pluginEngine.uninstallPlugin.
apps/mobile/package.json Adds missing mobile deps (AsyncStorage, expo-constants) and type-check script.
apps/mobile/tsconfig.json Sets module: esnext to support dynamic imports / ESM semantics in TS.
apps/mobile/app.json Expo app config (name/slug/platform IDs/plugins/extra).
apps/mobile/src/screens/DashboardScreen.tsx Mobile dashboard placeholder UI.
apps/mobile/src/screens/OptimizerScreen.tsx Mobile optimizer screen using AsyncStorage token + expo-constants config for API URL.
apps/mobile/src/screens/PluginsScreen.tsx Mobile plugins placeholder UI.
apps/mobile/src/screens/SettingsScreen.tsx Mobile settings placeholder UI.
apps/mobile/src/navigation/TabNavigator.tsx Mobile bottom tab navigation wiring the screens.
apps/desktop/package.json Electron desktop app setup (electron-builder, updater, dev scripts).
apps/desktop/tsconfig.json Desktop TS config targeting CommonJS/node resolution for Electron main/preload.
apps/desktop/src/main.ts Electron main process creating window, menu, and auto-update wiring.
apps/desktop/src/preload.ts Electron preload exposing limited IPC APIs via contextBridge.
packages/contracts/package.json Contracts package build/type-check scripts and zod dependency.
packages/contracts/tsconfig.json Contracts TS config for dist output using bundler resolution.
packages/contracts/src/index.ts Barrel export for all contract modules.
packages/contracts/src/billing.contract.ts Subscription tiers/limits/feature flags and Stripe checkout schema.
packages/contracts/src/access.contract.ts Roles/permissions/JWT payload schema and helpers.
packages/contracts/src/ai.contract.ts AI provider/model contracts and request/response schemas.
packages/contracts/src/plugin.contract.ts Plugin manifest/install/execution contracts and schemas.
packages/contracts/src/usage.contract.ts Usage metrics contracts and token-cost calculator.
packages/contracts/src/sync.contract.ts Sync contracts for offline/queue/conflict resolution models.
packages/contracts/src/web3.contract.ts Web3 auth/session/NFT gating request contracts.
packages/services/package.json Services package deps (Stripe, Firebase, AI SDKs) and build/type-check scripts.
packages/services/tsconfig.json Services TS config for dist output using bundler resolution.
packages/services/src/index.ts Barrel export for services modules.
packages/services/src/stripe.service.ts Stripe client + checkout/portal/webhook handling helpers.
packages/services/src/firebase.service.ts Firebase Admin initialization and Firestore/RTDB/Auth helper methods.
packages/services/src/ai.router.service.ts AI router service for OpenAI/Anthropic/Gemini + optimization routine.
packages/services/src/plugin.engine.ts In-memory plugin registry/installation and hook execution engine.
packages/middleware/package.json Next middleware utilities package deps and scripts.
packages/middleware/tsconfig.json Middleware TS config for dist output using bundler resolution.
packages/middleware/src/index.ts Barrel export for middleware functions.
packages/middleware/src/auth.middleware.ts JWT sign/verify and auth/optional-auth request wrappers.
packages/middleware/src/billing.middleware.ts Tier/feature gating wrappers and tier limit accessor.
packages/middleware/src/rbac.middleware.ts Permission-based request wrappers.
packages/middleware/src/usage.middleware.ts Upstash rate limiting and usage tracking helpers.
packages/ui/package.json UI component package with tsup build and peer deps for React.
packages/ui/tsconfig.json UI TS config with JSX + DOM libs.
packages/ui/tailwind.config.ts Shared Tailwind theme/config exported for apps to extend.
packages/ui/src/index.ts UI barrel exporting shared components.
packages/ui/src/components/GlassCard.tsx Shared “glass” card component.
packages/ui/src/components/NeonButton.tsx Shared neon-styled button component.
packages/ui/src/components/AICommandBar.tsx Shared AI command bar component with model selector + submit UX.
packages/ui/src/components/PromptCard.tsx Shared prompt card component.
packages/ui/src/components/BillingDashboard.tsx Shared billing/usage UI component.
packages/ui/src/components/PluginTile.tsx Shared plugin tile UI component.
packages/config/package.json Config/env package with zod schema parsing.
packages/config/tsconfig.json Config package TS config with node types.
packages/config/src/index.ts Environment variable schema validation and public env accessor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +132 to +137
const result = await Promise.race([
sandbox.execute(context),
new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error("Plugin execution timeout")), context.timeoutMs)
),
]);
Comment on lines +90 to +92
if (manifest.hooks.onInstall) {
await this.executeHook(installation, "onInstall", {});
}
Comment on lines +115 to +118
const messages: Anthropic.Messages.MessageParam[] = request.messages.map((m) => ({
role: m.role === "assistant" ? "assistant" as const : "user" as const,
content: m.content,
}));
Comment on lines +16 to +19
onSubmit,
placeholder = "Enter a prompt or command... (⌘K to focus)",
models = ["gpt-4o-mini", "gpt-4o", "claude-3-5-sonnet", "gemini-1.5-flash"],
selectedModel,
Comment on lines +26 to +35
// Anonymous users are allowed with a lower quota; authenticated users get tier limits
const userId = user?.sub ?? "anonymous";

// Enforce prompt limit for free/anonymous tier
if (!user) {
const ip = req.headers.get("x-forwarded-for") ?? "unknown";
const tierLimit = TierLimits[SubscriptionTier.FREE].monthlyPrompts;
// IP-based limiting is handled by upstream infrastructure; log for monitoring
console.info(`[optimize] anonymous request from ${ip}, userId=anonymous, limit=${tierLimit}`);
}
Comment on lines +23 to +26
const API_URL =
(Constants.expoConfig?.extra as { EXPO_PUBLIC_API_URL?: string })
?.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 6, 2026

@copilot merge passable only after repair don't no drift ! Strictly fix CI Builds all tests must pass before we merge

Fixed in commit a9ed798. The CI was failing at pnpm install --frozen-lockfile with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH because the lockfile had been generated with pnpm v9 (format 9.0) while the CI workflow uses pnpm/action-setup@v3 version: 8. Regenerated pnpm-lock.yaml using pnpm v8.15.9 (format 6.0) to match the CI environment. pnpm install --frozen-lockfile and pnpm turbo run type-check (13/13 tasks) both pass cleanly now.

Copilot finished work on behalf of SMSDAO May 6, 2026 05:39
Copilot AI requested a review from SMSDAO May 6, 2026 05:39
@SMSDAO SMSDAO marked this pull request as ready for review May 6, 2026 08:06
@SMSDAO SMSDAO merged commit 689d8ec into main May 6, 2026
1 of 2 checks passed
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