Commit Graph

29 Commits

Author SHA1 Message Date
Loma Bot Ops 0ba3a5486c Improve automation worker error messages and inbox AI multi-bubble replies
- automation.ts: distinguish network/timeout errors from generic failures
- aiAutoReply.ts: upgrade to multi-bubble reply system with female particle enforcement
- codex-runtime.mjs: revert default model to gpt-4.1-mini

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-11-26 09:26:54 +07:00
Loma Bot Ops 89d46ab141 Add AI auto sales replies for inbox 2026-11-25 21:31:32 +07:00
chaloemphong dd42b81639 Add scheduled automatic content drafts with Codex and image automation 2026-11-25 21:13:36 +07:00
Loma Bot Ops 55235718c3 Add self-service teams and assigned post approvals 2026-11-24 11:13:20 +07:00
Loma Bot Ops b14a9286cd Allow members to connect and manage their Facebook pages 2026-11-24 09:43:34 +07:00
Loma Bot Ops 7f1a9face1 Add image art direction, Thai date picker on week board, sturdier image download
- Share IMAGE_ART_DIRECTION between editable image prompts and queued post drafts
- Use ThaiDateTimePicker for week board planning; a11y, clear action, mobile layout
- Show planned day in Thai format in the generation queue
- Wait longer for ChatGPT image download and handle the download menu item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 23:14:13 +07:00
Loma Bot Ops 7d6f42b964 Use dedicated Chrome profile for image automation 2026-11-23 22:51:57 +07:00
Loma Bot Ops ac4d3bf7a5 Prepare dedicated Playwright image browser and login checks 2026-11-23 22:36:22 +07:00
Loma Bot Ops df20406cf5 Diagnose image worker failures and normalize Facebook uploads 2026-11-23 22:27:53 +07:00
Loma Bot Ops 4429e6541b Surface content research at top of post editor 2026-11-23 22:08:00 +07:00
Loma Bot Ops 6ef01cb4b6 Add news research assistant to post editor 2026-11-23 21:59:02 +07:00
Loma Bot Ops 5f8f0c9159 Add website link to page profile so the AI can read the shop site
Adds PageProfile.website (with migration). Codex runs without network, so
the profile draft route fetches the site server-side (public hosts only,
redirect-checked, size-capped, cached) and passes its text as
<shop_website>. Other prompts receive the URL via the shop profile.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 21:20:35 +07:00
Loma Bot Ops b592cd43f4 Pick brand colours, not background tints, from page logos
Rank by vivid/dark pixels, average within coarse bins, and drop same-hue
anti-aliasing blends. On the 4Tech logo this yields red + charcoal instead
of white/pink fringe colours.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 21:11:04 +07:00
Loma Bot Ops 4c93bf0a11 Add brand visual style to page profile and logo palette to image prompts
Adds PageProfile.visualStyle (with migration), feeds it into every AI
prompt route, and samples a logo palette for image generation. Also
hardens Chrome focus handling and image copy in the ChatGPT driver.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 20:58:06 +07:00
Loma Bot Ops dc6ee09a55 Use HTML meta-refresh for external OAuth redirects behind IIS ARR
ARR's machine-level reverseRewriteHostInResponseHeaders rewrote the host of
Location headers, sending Facebook/Google login dialogs to loma.chat/v21.0/...
Serve a 200 HTML hop to the provider URL instead of a 3xx Location.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 16:44:26 +07:00
Loma Bot Ops fd282c8ce4 Add editor settings and SSL certificate document 2026-11-23 16:28:44 +07:00
Loma Bot Ops 4c691b5dde Show milestone progress bar for post generation queue jobs
Add percentage-by-stage progress in the queue UI, a progress rendering
test script, and clearer Chrome focus error details in the ChatGPT worker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 15:36:52 +07:00
chaloemphong 53d39ae4cd Merge branch 'deploy/coolify' of https://git.4tech-innovation.cloud/Chaloemphong/PAGIVA into deploy/coolify
# Conflicts:
#	src/app/globals.css
2026-11-23 15:25:52 +07:00
chaloemphong 9d97ef3afc Style date/datetime/time input picker icon to match design system
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-23 15:25:22 +07:00
Loma Bot Ops 5625c9a0e2 Restyle date inputs and checkboxes to match the blue UI
- date / datetime-local: themed calendar button, blue segment highlight,
  disabled state for all text controls
- checkbox: custom 18px box (22px on touch widths) with checked,
  indeterminate, hover, disabled and forced-colors fallbacks
- WeekPlanAssistant: drop fixed checkbox size so it matches the rest

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 21:52:10 +07:00
Loma Bot Ops 6994ba1a4e Move AI to Codex CLI + ChatGPT browser workers with a durable post queue
Text generation now runs through a PM2 automation worker (codex exec) and
images through the ChatGPT Chrome extension, replacing the Anthropic API.
generateStructured keeps its signature; results are Zod-validated on the web
side and the worker is reached with a bearer secret.

- AI image assistant in the post editor: editable prompt step, then image
  (square or 3:2 only, since Instagram rejects 2:3), stored via putBlob
- Full-post queue (PostGenerationJob + migration): enqueue returns 202, FIFO
  claim under an advisory lock, heartbeat, stale-job failure, per-user
  request key, cancel while QUEUED; output is always a DRAFT with audit rows
- Separate 10 images/page/day quota; text quota excludes images
- Worker reports Codex usage-limit as 429 with a clear Thai message
- Docs: AI-AUTOMATION.md, ARCHITECTURE/README/.env.example updated

Known gap: the live FIFO queue check (scripts/check-post-queue.mjs) has not
passed yet; the last run hit the Codex account usage limit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 21:52:09 +07:00
Loma Bot Ops 4a673ebb28 Support sub-path deploy via NEXT_PUBLIC_BASE_PATH (loma.chat/pagiva)
Adds basePath config, withBase/appUrl helpers, base-path-aware cookies,
OAuth redirects, manifest, service worker and cron runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:48:42 +07:00
chaloemphong 9d5a029fa5 Disable Facebook social login permanently
Facebook Login for Business (the only Login product a Business-type
app gets, needed here for Page/Messenger/Instagram) has no
email/public_profile permission to request, only business asset
permissions - there is no config_id that can resolve a user's
identity. credentials() now always returns null for facebook so the
button stays hidden; Google login is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 16:17:36 +07:00
chaloemphong 025ed6cc57 Add Vercel deploy support alongside Coolify
Storage now picks Vercel Blob when a store is connected (BLOB_STORE_ID
or BLOB_READ_WRITE_TOKEN), falling back to local disk for self-hosted
runs. Adds vercel.json cron schedule for the existing cron routes
(ig-publisher capped to once/day on Hobby plan).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 15:16:08 +07:00
chaloemphong 32c121a85a Copy the full scripts/ directory into the runtime image
Only cron-runner.mjs was copied, so scripts/create-user.mjs (needed to
bootstrap the first login account on a fresh deploy) was missing from
the container entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 14:45:43 +07:00
chaloemphong fd33d5c987 Copy prisma.config.ts into the runtime image
Prisma 7 reads datasource.url from prisma.config.ts, not schema.prisma.
The final Docker stage copied prisma/ but not the root config file, so
`prisma migrate deploy` always failed with "datasource.url property is
required" regardless of DATABASE_URL being set correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 14:29:57 +07:00
chaloemphong 53b8c3cbf7 Add docker-compose deploy path with Coolify-managed secrets
Adds docker-compose.yml so Coolify can provision Postgres and generate
DATABASE_URL/SESSION_SECRET/TOKEN_ENCRYPTION_KEY/CRON_SECRET itself via
its SERVICE_PASSWORD_* magic variables, instead of an operator typing
them into the dashboard by hand.

TOKEN_ENCRYPTION_KEY now derives its AES-256 key via SHA-256 instead of
requiring exactly 32 raw bytes in base64, so a generated magic variable
works regardless of its format.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 12:45:57 +07:00
chaloemphong 1cb75a163f Self-host Anuphan font instead of next/font/google
The Coolify build server has no outbound access to fonts.googleapis.com,
which crashed `npm run build` inside the Docker build with a next/font
google-loader TypeError. Switch to next/font/local with the variable TTF
fetched from the Google Fonts GitHub repo (same OFL-licensed font, no
build-time network dependency).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 12:31:13 +07:00
chaloemphong 9d32552457 Initial commit: page-manager Next.js app with Coolify deploy support
Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents
for deployment to Coolify: in-container cron scheduler
(scripts/cron-runner.mjs) and disk-based upload storage served via
/api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health
for container health checks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-22 11:52:17 +07:00