Skip to content

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

Merged
SMSDAO merged 11 commits into
mainfrom
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 into
mainfrom
copilot/fix-ci-failing-type-check

Conversation

CopilotAI commented May 6, 2026

Copy link
Copy Markdown
Contributor
  • 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 tsconfigcompilerOptions.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:

constAPI_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):

importConstantsfrom"expo-constants";// Prefer configuring this in app config (extra) and read it here.constAPI_URL=(Constants.expoConfig?.extraas{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 }=awaitimport("@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.

CopilotAIand 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>
CopilotAIand 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 CopilotMay 6, 2026 05:32
CopilotAI changed the title [WIP] Fix CI failing @promptos/mobile type-checkfix(mobile): resolve three TypeScript CI failures in @promptos/mobile type-checkMay 6, 2026
CopilotAI requested a review from SMSDAOMay 6, 2026 05:34

@SMSDAOSMSDAO left a comment

Copy link
Copy Markdown
Contributor

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

CopilotAI left a comment

Copy link
Copy Markdown

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
FileDescription
turbo.jsonAdds Turborepo pipeline configuration for build/lint/type-check/test/clean.
tsconfig.base.jsonIntroduces a strict base TypeScript configuration for workspace packages/apps.
pnpm-workspace.yamlDefines workspace package globs for pnpm.
package.jsonRoot workspace scripts (turbo) and devDependencies.
Dockerfile.webContainer build for the Next.js web app using pnpm + turbo.
docker-compose.ymlCompose setup for web + redis.
.gitignoreStandard ignores for node/turbo/next/expo/electron artifacts and env files.
.env.exampleRoot env template covering auth/stripe/ai/firebase/walletconnect/ratelimit.
.github/workflows/ci.ymlCI workflow running pnpm turbo run type-check and lint, plus package builds.
.github/workflows/deploy-web.ymlVercel deployment workflow for main.
apps/web/package.jsonWeb app dependencies/scripts (Next.js 14) and workspace package usage.
apps/web/tsconfig.jsonWeb TS config aligned to Next + bundler resolution and path aliases.
apps/web/next.config.jsNext config enabling transpilePackages and server external packages.
apps/web/next-env.d.tsNext-generated TS ambient references.
apps/web/postcss.config.jsPostCSS config enabling Tailwind + autoprefixer.
apps/web/tailwind.config.tsTailwind config extending the shared UI config and setting content globs.
apps/web/.env.exampleWeb-scoped env template referencing the root env example.
apps/web/src/app/layout.tsxApp Router root layout and global font/style setup.
apps/web/src/app/globals.cssGlobal Tailwind layers and shared “glass/neon” component styles.
apps/web/src/app/page.tsxMarketing/home landing page.
apps/web/src/app/dashboard/page.tsxDashboard placeholder UI.
apps/web/src/app/optimizer/page.tsxClient-side optimizer UI calling /api/ai/optimize.
apps/web/src/app/api/health/route.tsHealth endpoint with timestamp/version response.
apps/web/src/app/api/ai/optimize/route.tsOptional-auth optimize endpoint delegating to aiRouterService.optimizePrompt.
apps/web/src/app/api/ai/complete/route.tsAuth + rate-limited AI completion endpoint validating request schema.
apps/web/src/app/api/usage/summary/route.tsUsage summary endpoint reading subscription tier and usage docs from Firestore.
apps/web/src/app/api/billing/checkout/route.tsCheckout session creation using Stripe service and server-generated URLs.
apps/web/src/app/api/billing/portal/route.tsBilling portal session creation for existing Stripe customers.
apps/web/src/app/api/billing/cancel/route.tsSubscription cancellation endpoint.
apps/web/src/app/api/webhooks/stripe/route.tsStripe webhook handler mapping Stripe events to Firestore + custom claims updates.
apps/web/src/app/api/plugins/install/route.tsPlugin install endpoint validating manifest and calling pluginEngine.installPlugin.
apps/web/src/app/api/plugins/uninstall/route.tsPlugin uninstall endpoint calling pluginEngine.uninstallPlugin.
apps/mobile/package.jsonAdds missing mobile deps (AsyncStorage, expo-constants) and type-check script.
apps/mobile/tsconfig.jsonSets module: esnext to support dynamic imports / ESM semantics in TS.
apps/mobile/app.jsonExpo app config (name/slug/platform IDs/plugins/extra).
apps/mobile/src/screens/DashboardScreen.tsxMobile dashboard placeholder UI.
apps/mobile/src/screens/OptimizerScreen.tsxMobile optimizer screen using AsyncStorage token + expo-constants config for API URL.
apps/mobile/src/screens/PluginsScreen.tsxMobile plugins placeholder UI.
apps/mobile/src/screens/SettingsScreen.tsxMobile settings placeholder UI.
apps/mobile/src/navigation/TabNavigator.tsxMobile bottom tab navigation wiring the screens.
apps/desktop/package.jsonElectron desktop app setup (electron-builder, updater, dev scripts).
apps/desktop/tsconfig.jsonDesktop TS config targeting CommonJS/node resolution for Electron main/preload.
apps/desktop/src/main.tsElectron main process creating window, menu, and auto-update wiring.
apps/desktop/src/preload.tsElectron preload exposing limited IPC APIs via contextBridge.
packages/contracts/package.jsonContracts package build/type-check scripts and zod dependency.
packages/contracts/tsconfig.jsonContracts TS config for dist output using bundler resolution.
packages/contracts/src/index.tsBarrel export for all contract modules.
packages/contracts/src/billing.contract.tsSubscription tiers/limits/feature flags and Stripe checkout schema.
packages/contracts/src/access.contract.tsRoles/permissions/JWT payload schema and helpers.
packages/contracts/src/ai.contract.tsAI provider/model contracts and request/response schemas.
packages/contracts/src/plugin.contract.tsPlugin manifest/install/execution contracts and schemas.
packages/contracts/src/usage.contract.tsUsage metrics contracts and token-cost calculator.
packages/contracts/src/sync.contract.tsSync contracts for offline/queue/conflict resolution models.
packages/contracts/src/web3.contract.tsWeb3 auth/session/NFT gating request contracts.
packages/services/package.jsonServices package deps (Stripe, Firebase, AI SDKs) and build/type-check scripts.
packages/services/tsconfig.jsonServices TS config for dist output using bundler resolution.
packages/services/src/index.tsBarrel export for services modules.
packages/services/src/stripe.service.tsStripe client + checkout/portal/webhook handling helpers.
packages/services/src/firebase.service.tsFirebase Admin initialization and Firestore/RTDB/Auth helper methods.
packages/services/src/ai.router.service.tsAI router service for OpenAI/Anthropic/Gemini + optimization routine.
packages/services/src/plugin.engine.tsIn-memory plugin registry/installation and hook execution engine.
packages/middleware/package.jsonNext middleware utilities package deps and scripts.
packages/middleware/tsconfig.jsonMiddleware TS config for dist output using bundler resolution.
packages/middleware/src/index.tsBarrel export for middleware functions.
packages/middleware/src/auth.middleware.tsJWT sign/verify and auth/optional-auth request wrappers.
packages/middleware/src/billing.middleware.tsTier/feature gating wrappers and tier limit accessor.
packages/middleware/src/rbac.middleware.tsPermission-based request wrappers.
packages/middleware/src/usage.middleware.tsUpstash rate limiting and usage tracking helpers.
packages/ui/package.jsonUI component package with tsup build and peer deps for React.
packages/ui/tsconfig.jsonUI TS config with JSX + DOM libs.
packages/ui/tailwind.config.tsShared Tailwind theme/config exported for apps to extend.
packages/ui/src/index.tsUI barrel exporting shared components.
packages/ui/src/components/GlassCard.tsxShared “glass” card component.
packages/ui/src/components/NeonButton.tsxShared neon-styled button component.
packages/ui/src/components/AICommandBar.tsxShared AI command bar component with model selector + submit UX.
packages/ui/src/components/PromptCard.tsxShared prompt card component.
packages/ui/src/components/BillingDashboard.tsxShared billing/usage UI component.
packages/ui/src/components/PluginTile.tsxShared plugin tile UI component.
packages/config/package.jsonConfig/env package with zod schema parsing.
packages/config/tsconfig.jsonConfig package TS config with node types.
packages/config/src/index.tsEnvironment 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";

CopilotAI commented May 6, 2026

Copy link
Copy Markdown
ContributorAuthor

@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.

CopilotAI requested a review from SMSDAOMay 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 mainMay 6, 2026
1 of 2 checks passed
Sign up for freeto 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

@SMSDAO