Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
feat(onboarding): guide scheduling setup and Instagram tester access
spacesdrivef0bf04125859
diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.ymlindex 1f7c5e8..6d156d2 100644--- a/.github/workflows/deploy-frontend.yml+++ b/.github/workflows/deploy-frontend.yml@@ -32,6 +32,7 @@ jobs:VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}VITE_API_URL: ${{ secrets.VITE_API_URL }}+ VITE_ADMIN_EMAIL: ${{ secrets.VITE_ADMIN_EMAIL }}- name: Deploy to Cloudflare Pagesuses: cloudflare/wrangler-action@v4diff --git a/README.md b/README.mdindex 3e9f8f9..d7ccaf5 100644--- a/README.md+++ b/README.md@@ -117,7 +117,7 @@ You deploy one Cloudflare Worker and one Cloudflare Pages site using your own AP</td><td width="33%" align="center"><img src="frontend/public/screenshots/Setting%20Page.png" alt="Settings" width="100%" />- <br/><sub><strong>Settings</strong> - configure your GitHub PAT and repository for the scheduled post fallback publisher</sub>+ <br/><sub><strong>Settings</strong> - theme, server status, and setup guides for scheduled publishing and Instagram access</sub></td></tr></table>@@ -257,6 +257,8 @@ UPSTASH_REDIS_REST_TOKEN=...VITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...VITE_API_URL=http://localhost:8787+# Optional: who users contact for Instagram tester access and scheduling problems```### Production (Cloudflare Workers secrets)@@ -403,7 +405,7 @@ twiligent/│ │ ├── publishing.js # Instagram Graph API publish flow│ │ ├── scheduledPosts.js # CRUD for scheduled post queue│ │ ├── instagramAuth.js # Instagram OAuth flow-│ │ ├── settings.js # User settings (GitHub PAT)+│ │ ├── settings.js # User settings (GitHub repository for setup links)│ │ └── keys.js # API key presence check│ ├── services/│ │ ├── youtube.js # YouTube Data API v3 client@@ -423,7 +425,7 @@ twiligent/│ │ │ └── reels/ # Instagram content explorer│ │ ├── accounts/ # Account management UI│ │ ├── publishing/ # Single and bulk upload with scheduler-│ │ └── settings/ # GitHub PAT configuration+│ │ └── settings/ # Theme, server status, setup guides│ ├── context/│ │ └── AppContext.jsx # Global accounts and loading state│ ├── layout/diff --git a/docs/architecture/cloudflare/CI_CD.md b/docs/architecture/cloudflare/CI_CD.mdindex be2d04c..c77c64d 100644--- a/docs/architecture/cloudflare/CI_CD.md+++ b/docs/architecture/cloudflare/CI_CD.md@@ -34,6 +34,7 @@- `VITE_SUPABASE_URL` - injected at build time- `VITE_SUPABASE_ANON_KEY` - injected at build time- `VITE_API_URL` - injected at build time (the Worker URL)+- `VITE_ADMIN_EMAIL` - optional, injected at build time; the administrator contact shown in the app**Note:** `VITE_*` variables are baked into the built JS bundle at build time. They are not runtime environment variables.diff --git a/docs/architecture/cloudflare/PAGES.md b/docs/architecture/cloudflare/PAGES.mdindex b2841e5..5ae06c9 100644--- a/docs/architecture/cloudflare/PAGES.md+++ b/docs/architecture/cloudflare/PAGES.md@@ -39,6 +39,7 @@ The frontend accesses environment variables at **build time** via Vite's `VITE_`| `VITE_SUPABASE_URL` | Supabase project URL (public) | Cloudflare Pages -> Settings -> Environment Variables || `VITE_SUPABASE_ANON_KEY` | Supabase anon key (public) | Cloudflare Pages -> Settings -> Environment Variables || `VITE_API_URL` | Backend Worker URL | Cloudflare Pages -> Settings -> Environment Variables |+| `VITE_ADMIN_EMAIL` | Optional. Administrator address shown for Instagram tester requests and scheduling problems; defaults to [email protected] | Cloudflare Pages -> Settings -> Environment Variables, or the GitHub secret of the same name |**These are public values** - they are baked into the JavaScript bundle. Do not add the service role key here. Do not add any private API credentials here.diff --git a/docs/workflows/DEPLOYMENT.md b/docs/workflows/DEPLOYMENT.mdindex 48b024a..df3de43 100644--- a/docs/workflows/DEPLOYMENT.md+++ b/docs/workflows/DEPLOYMENT.md@@ -68,6 +68,7 @@ Required for `deploy-frontend.yml` and `publish-scheduled.yml`:- `VITE_SUPABASE_URL`- `VITE_SUPABASE_ANON_KEY`- `VITE_API_URL`+- `VITE_ADMIN_EMAIL` (optional; the administrator contact shown in the app)**For backend deploy:**- `CLOUDFLARE_API_TOKEN`diff --git a/frontend/.env.example b/frontend/.env.exampleindex 17321a4..d5b8413 100644--- a/frontend/.env.example+++ b/frontend/.env.example@@ -7,3 +7,8 @@ VITE_SUPABASE_ANON_KEY=your-anon-key# Local dev: leave blank (defaults to http://localhost:8787)# Production: set to your Cloudflare Worker URLVITE_API_URL=https://twiligent.your-subdomain.workers.dev/api++# ── Administrator contact (optional) ─────────────────────────────────────────+# Shown to people who need Instagram tester access or whose scheduled posts+# are not publishing. Defaults to [email protected] when unset.diff --git a/frontend/src/components/InstagramTesterNotice.jsx b/frontend/src/components/InstagramTesterNotice.jsxnew file mode 100644index 0000000..8d13269--- /dev/null+++ b/frontend/src/components/InstagramTesterNotice.jsx@@ -0,0 +1,85 @@+import React from 'react';+import { Mail, ExternalLink, UserCheck } from 'lucide-react';+import { Button } from '@/components/ui/button';+import { ADMIN_EMAIL, adminMailto, INSTAGRAM_TESTER_INVITES_URL } from '@/lib/contact';+import { cn } from '@/lib/utils';++const REQUEST_BODY = [+ 'Hi,',+ '',+ 'Please add my Instagram account as an Instagram tester for Twiligent.',+ '',+ 'Instagram username: @',+ 'Account type (Business or Creator): ',+ '',+ 'Thanks',+].join('\n');++// While the Meta app is in development mode, Instagram only lets accepted testers sign in.+export default function InstagramTesterNotice({ compact = false, className }) {+ const steps = [+ {+ title: 'Ask to be added as a tester',+ body: (+ <>+ Email the administrator at{' '}+ <a href={adminMailto('Instagram tester request for Twiligent', REQUEST_BODY)} className="font-medium text-brand-text underline-offset-4 hover:underline">+ {ADMIN_EMAIL}+ </a>{' '}+ with your Instagram username. Only Business and Creator accounts can be added.+ </>+ ),+ },+ {+ title: 'Accept the invite on Instagram',+ body: (+ <>+ Once you are added, sign in to Instagram on the web and open{' '}+ <a href={INSTAGRAM_TESTER_INVITES_URL} target="_blank" rel="noopener noreferrer" className="font-medium text-brand-text underline-offset-4 hover:underline">+ Apps and websites, Tester invites+ </a>+ , then accept the Twiligent invite. In the Instagram app it is under Settings and privacy, Website permissions, Apps and websites, Tester invites.+ </>+ ),+ },+ {+ title: 'Connect your account here',+ body: 'Come back, choose Continue to Instagram, and approve the requested permissions.',+ },+ ];++ return (+ <div className={cn('flex flex-col gap-3 rounded-field border border-info/30 bg-info-soft p-4', className)}>+ <div className="flex items-start gap-2.5">+ <UserCheck className="mt-0.5 size-4 shrink-0 stroke-[1.75] text-info" />+ <div className="flex flex-col gap-0.5">+ <p className="text-sm font-semibold text-ink">Your Instagram account needs tester access first</p>+ <p className="text-small text-ink-muted">+ The Twiligent Meta app is in development mode, so Instagram only lets accounts that are added as testers connect. Without it, Instagram shows an error or a blank page when you sign in.+ </p>+ </div>+ </div>+ {!compact && (+ <ol className="flex flex-col gap-2.5 pl-6.5">+ {steps.map((step, i) => (+ <li key={step.title} className="flex gap-2.5">+ <span className="flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-raised font-mono text-caption font-medium text-ink-muted">{i + 1}</span>+ <div className="flex flex-col gap-0.5">+ <p className="text-small font-medium text-ink">{step.title}</p>+ <p className="text-small text-ink-muted">{step.body}</p>+ </div>+ </li>+ ))}+ </ol>+ )}+ <div className="flex flex-wrap gap-2 pl-6.5">+ <Button size="sm" variant="outline" render={<a href={adminMailto('Instagram tester request for Twiligent', REQUEST_BODY)} />}>+ <Mail data-icon="inline-start" />Email the administrator+ </Button>+ <Button size="sm" variant="ghost" render={<a href={INSTAGRAM_TESTER_INVITES_URL} target="_blank" rel="noopener noreferrer" />}>+ <ExternalLink data-icon="inline-start" />Open tester invites+ </Button>+ </div>+ </div>+ );+}diff --git a/frontend/src/features/accounts/AccountManager.jsx b/frontend/src/features/accounts/AccountManager.jsxindex cba5f7f..790599d 100644--- a/frontend/src/features/accounts/AccountManager.jsx+++ b/frontend/src/features/accounts/AccountManager.jsx@@ -14,6 +14,8 @@ import PageHeader from '@/components/PageHeader';import SurfaceBox from '@/components/SurfaceBox';import SectionHeader from '@/components/SectionHeader';import ChoiceCard from '@/components/ChoiceCard';+import InstagramTesterNotice from '@/components/InstagramTesterNotice';+import { ADMIN_EMAIL } from '@/lib/contact';import ConfirmDialog from '@/components/ConfirmDialog';import { FieldRow } from '@/components/DetailPanel';import { EmptyState } from '@/components/StateViews';@@ -31,10 +33,12 @@ const PLATFORM_CHOICES = [{ value: 'reddit', title: 'Reddit account', description: 'Add a username and a session cookie from your browser.', icon: <RedditIcon /> },];+const TESTER_HINT = `If your account is not an Instagram tester yet, email ${ADMIN_EMAIL} to be added, then accept the invite in Instagram.`;+const IG_ERRORS = {already_added: 'This Instagram account is already connected.',cancelled: 'Instagram sign-in was cancelled. Try again when you are ready.',- access_denied: 'Instagram did not grant access. Approve every requested permission and try again.',+ access_denied: `Instagram did not grant access. Approve every requested permission and try again. ${TESTER_HINT}`,invalid_state: 'The Instagram sign-in link expired. Start the connection again.',};@@ -73,7 +77,7 @@ export default function AccountManager() {showToast('Instagram account connected');loadAccounts();} else if (igError) {- showToast(IG_ERRORS[igError] || `Instagram connection failed: ${igError}`, 'error');+ showToast(IG_ERRORS[igError] || `Instagram connection failed: ${igError}. ${TESTER_HINT}`, 'error');}if (add) setDialogOpen(true);setSearchParams({}, { replace: true });@@ -328,14 +332,9 @@ export default function AccountManager() {{platform === 'instagram' && (<div className="flex flex-col gap-4"><p className="text-sm text-ink-muted">- We open Instagram so you can sign in and approve access. When you finish, Instagram sends you back here and the account appears in the list.+ We open Instagram so you can sign in and approve access. When you finish, Instagram sends you back here and the account appears in the list. The account must be an Instagram Business or Creator account; personal accounts cannot be connected.</p>- <Alert variant="info">- <Info />- <AlertDescription>- The account must be an Instagram Business or Creator account. Personal accounts cannot be connected through the Instagram API.- </AlertDescription>- </Alert>+ <InstagramTesterNotice /></div>)}diff --git a/frontend/src/features/publishing/UploadContent.jsx b/frontend/src/features/publishing/UploadContent.jsxindex 31faea0..947c3bc 100644--- a/frontend/src/features/publishing/UploadContent.jsx+++ b/frontend/src/features/publishing/UploadContent.jsx@@ -24,6 +24,7 @@ import ConfirmDialog from '@/components/ConfirmDialog';import { EmptyState } from '@/components/StateViews';import { AccountAvatar } from '@/components/platform';import { InstagramIcon } from '@/components/brand/platform-icons';+import { ADMIN_EMAIL, adminMailto } from '@/lib/contact';import { useAppContext } from '../../context/AppContext';import { api } from '../../services/api';import { cn } from '@/lib/utils';@@ -63,6 +64,16 @@ const BULK_STATUS = {const ACTIVE_BULK = ['uploading', 'creating', 'processing', 'publishing', 'scheduling'];const CAPTION_LIMIT = 2200;+const OVERDUE_MS = 30 * 60 * 1000;++function ScheduleHint() {+ return (+ <p className="text-caption text-ink-faint">+ The server publishes the post within 15 minutes after this time, even with this page closed. Keep the account connected until then.{' '}+ <Link to="/settings#scheduling" className="font-medium text-brand-text underline-offset-4 hover:underline">How scheduling works</Link>+ </p>+ );+}function StatusBadge({ status, map }) {const s = map[status] || Object.values(map)[0];@@ -509,6 +520,8 @@ export default function UploadContent() {.filter(p => statusFilter === 'all' || p.status === statusFilter).sort((a, b) => new Date(b.scheduledAt) - new Date(a.scheduledAt));+ const overduePosts = scheduledPosts.filter(p => p.status === 'pending' && Date.now() - new Date(p.scheduledAt).getTime() > OVERDUE_MS);+const intervalText = bulkInterval >= 1440 ? `${bulkInterval / 1440} day${bulkInterval > 1440 ? 's' : ''}` : `${bulkInterval / 60} hours`;if (igAccounts.length === 0) {@@ -598,7 +611,7 @@ export default function UploadContent() {<span className="flex size-12 items-center justify-center rounded-full bg-warning-soft text-warning"><Calendar className="size-6" /></span><h2 className="font-heading text-page-title font-semibold text-ink">Post scheduled</h2><p className="text-sm text-ink-muted">{statusMessage}</p>- <p className="max-w-md text-small text-ink-faint">The server publishes it at that time, even when this browser is closed.</p>+ <p className="max-w-md text-small text-ink-faint">The server publishes it within 15 minutes after that time, even when this browser is closed. Track it under Scheduled posts below.</p><Button onClick={resetAll} className="mt-2"><Plus data-icon="inline-start" />Schedule another</Button></>)}@@ -745,10 +758,13 @@ export default function UploadContent() {<ScheduleToggle scheduled={scheduleMode} onChange={setScheduleMode} /></FieldRow>{scheduleMode && (- <div className="grid grid-cols-2 gap-2">- <Input type="date" value={scheduleDate} onChange={e => setScheduleDate(e.target.value)} min={today} aria-label="Schedule date" />- <Input type="time" value={scheduleTime} onChange={e => setScheduleTime(e.target.value)} aria-label="Schedule time" />- </div>+ <>+ <div className="grid grid-cols-2 gap-2">+ <Input type="date" value={scheduleDate} onChange={e => setScheduleDate(e.target.value)} min={today} aria-label="Schedule date" />+ <Input type="time" value={scheduleTime} onChange={e => setScheduleTime(e.target.value)} aria-label="Schedule time" />+ </div>+ <ScheduleHint />+ </>)}</div>@@ -907,6 +923,7 @@ export default function UploadContent() {<Input type="date" value={bulkStartDate} onChange={e => setBulkStartDate(e.target.value)} min={today} disabled={bulkProcessing} aria-label="Start date" /><Input type="time" value={bulkStartTime} onChange={e => setBulkStartTime(e.target.value)} disabled={bulkProcessing} aria-label="Start time" /></div>+ <ScheduleHint /><Select value={String(bulkInterval)} onValueChange={v => setBulkInterval(Number(v))} disabled={bulkProcessing} items={BULK_INTERVAL_OPTIONS.map(o => ({ value: String(o.value), label: o.label }))}><SelectTrigger className="w-full" aria-label="Interval"><SelectValue /></SelectTrigger><SelectContent>@@ -948,6 +965,16 @@ export default function UploadContent() {<Button size="sm" variant="outline" onClick={() => setConfirmDeleteAll(true)} className="hover:bg-danger-soft hover:text-danger"><Trash2 data-icon="inline-start" />Delete all</Button></div></div>+ {overduePosts.length > 0 && (+ <Alert variant="warning">+ <AlertCircle />+ <AlertDescription>+ {overduePosts.length === 1 ? '1 post is' : `${overduePosts.length} posts are`} more than 30 minutes past their time and still pending, so the scheduler on this server is not running. Email the administrator at{' '}+ <a href={adminMailto('Scheduled posts are not publishing on Twiligent')} className="font-semibold underline underline-offset-4">{ADMIN_EMAIL}</a>.+ If you run this instance, follow the checks in <Link to="/settings#scheduling" className="font-semibold underline underline-offset-4">Settings, Scheduled publishing</Link>.+ </AlertDescription>+ </Alert>+ )}<FilterChips label="Status" options={statusChips} value={statusFilter} onChange={setStatusFilter} /><SurfaceBox content={false} className="overflow-hidden"><Table>diff --git a/frontend/src/features/settings/Settings.jsx b/frontend/src/features/settings/Settings.jsxindex d6cc520..d7208fa 100644--- a/frontend/src/features/settings/Settings.jsx+++ b/frontend/src/features/settings/Settings.jsx@@ -1,7 +1,8 @@import React, { useEffect, useState } from 'react';-import { useTheme } from 'next-themes';+import { useSmoothTheme } from '@/hooks/use-smooth-theme';+import { useLocation } from 'react-router-dom';import {- RefreshCw, CheckCircle2, Info, AlertTriangle, ExternalLink, Copy, Check, Save, Sun, Moon, Monitor, Activity,+ RefreshCw, CheckCircle2, AlertTriangle, ExternalLink, Copy, Check, Save, Sun, Moon, Monitor, Activity, Clock,} from 'lucide-react';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';@@ -13,23 +14,30 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';import PageHeader from '@/components/PageHeader';import SurfaceBox from '@/components/SurfaceBox';import { FieldRow } from '@/components/DetailPanel';+import InstagramTesterNotice from '@/components/InstagramTesterNotice';+import { ADMIN_EMAIL, adminMailto } from '@/lib/contact';import { useAppContext } from '../../context/AppContext';import { api } from '../../services/api';import { cn } from '@/lib/utils';-const PAT_STEPS = [- { title: 'Open GitHub settings', body: <>On github.com, open your profile menu (top right) and choose <strong>Settings</strong>.</> },- { title: 'Open developer settings', body: <>At the bottom of the left sidebar, choose <strong>Developer settings</strong>.</> },- { title: 'Create a fine-grained token', body: <>Choose <strong>Personal access tokens</strong>, then <strong>Fine-grained tokens</strong>, then <strong>Generate new token</strong>. Fine-grained tokens let you pick exact permissions.</> },- { title: 'Name the token and pick the repository', body: <>Use a clear name such as <em>twiligent-actions</em>, an expiry of 90 days or less, and <em>Only select repositories</em> with this project selected.</> },- { title: 'Set permissions', body: <>Under Repository permissions, enable <Badge variant="secondary">Actions: read and write</Badge> <Badge variant="secondary">Secrets: read and write</Badge> <Badge variant="secondary">Contents: read-only</Badge></> },- { title: 'Copy the token now', body: <>Choose <strong>Generate token</strong>. GitHub shows it once, so copy it into a password manager straight away. A lost token has to be generated again.</> },- { title: 'Add it as an Actions secret', body: 'In the repository, open Settings, then Secrets and variables, then Actions, then New repository secret. Name it exactly:', code: 'GITHUB_PAT' },+const WORKFLOW_FILE = '.github/workflows/publish-scheduled.yml';+const SECRET_NAMES = [+ { name: 'SUPABASE_URL', hint: 'Your Supabase project URL. Supabase dashboard, Project Settings, API.' },+ { name: 'SUPABASE_SERVICE_KEY', hint: 'The service_role key from the same page. It can read and write every table, so it goes only into GitHub secrets, never into code or chat.' },];+function repoLinks(owner, repo) {+ if (!owner || !repo) return null;+ const base = `https://github.com/${owner.trim()}/${repo.trim()}`;+ return {+ newSecret: `${base}/settings/secrets/actions/new`,+ actions: `${base}/actions`,+ workflow: `${base}/actions/workflows/publish-scheduled.yml`,+ };+}+const LINKS = [- { label: 'GitHub settings', href: 'https://github.com/settings/profile' },- { label: 'GitHub fine-grained tokens', href: 'https://github.com/settings/tokens?type=beta' },+ { label: 'Supabase API settings', href: 'https://supabase.com/dashboard/project/_/settings/api' },{ label: 'Cloudinary console', href: 'https://cloudinary.com/console' },{ label: 'Google Cloud credentials', href: 'https://console.cloud.google.com/apis/credentials' },{ label: 'Meta app dashboard', href: 'https://developers.facebook.com/apps' },@@ -55,11 +63,28 @@ function CopyButton({ text }) {);}+function Steps({ steps }) {+ return (+ <ol className="flex flex-col gap-4">+ {steps.map((step, i) => (+ <li key={step.title} className="flex gap-3">+ <span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-surface-sunken font-mono text-caption font-medium text-ink-muted">{i + 1}</span>+ <div className="flex min-w-0 flex-1 flex-col gap-1 pt-0.5">+ <p className="text-sm font-medium text-ink">{step.title}</p>+ <div className="text-sm text-ink-muted [&_a]:font-medium [&_a]:text-brand-text [&_a]:underline-offset-4 [&_a:hover]:underline [&_strong]:font-semibold [&_strong]:text-ink">{step.body}</div>+ {step.extra}+ </div>+ </li>+ ))}+ </ol>+ );+}+function SettingsSection({ id, title, description, children }) {return (- <section aria-labelledby={id} className="grid grid-cols-1 gap-4 border-t border-line pt-8 first:border-t-0 first:pt-0 lg:grid-cols-[16rem_1fr] lg:gap-10">+ <section id={id} aria-labelledby={`${id}-title`} className="grid scroll-mt-20 grid-cols-1 gap-4 border-t border-line pt-8 first:border-t-0 first:pt-0 lg:grid-cols-[16rem_1fr] lg:gap-10"><div className="flex flex-col gap-1">- <h2 id={id} className="font-heading text-section font-semibold text-ink">{title}</h2>+ <h2 id={`${id}-title`} className="font-heading text-section font-semibold text-ink">{title}</h2>{description && <p className="text-small text-ink-muted">{description}</p>}</div><div className="flex min-w-0 flex-col gap-4">{children}</div>@@ -85,18 +110,16 @@ function StatusRow({ label, ok, hint }) {export default function Settings() {const { showToast, refreshAll, loading: refreshingAll } = useAppContext();- const { theme, setTheme } = useTheme();+ const { theme, setTheme } = useSmoothTheme();const [serverStatus, setServerStatus] = useState(null);const [testing, setTesting] = useState(false);const [testResult, setTestResult] = useState(null);const [loading, setLoading] = useState(true);- const [ghPat, setGhPat] = useState('');+ const location = useLocation();const [ghRepoOwner, setGhRepoOwner] = useState('');const [ghRepoName, setGhRepoName] = useState('');- const [ghBranch, setGhBranch] = useState('main');- const [ghPatSet, setGhPatSet] = useState(false);const [ghSaving, setGhSaving] = useState(false);useEffect(() => {@@ -108,8 +131,6 @@ export default function Settings() {setServerStatus(keys);setGhRepoOwner(gh.repoOwner || '');setGhRepoName(gh.repoName || '');- setGhBranch(gh.branch || 'main');- setGhPatSet(gh.patSet || false);} catch {try {const keys = await api.getKeys();@@ -122,21 +143,67 @@ export default function Settings() {return () => { cancelled = true; };}, []);+ // Links such as /settings#scheduling jump to their section once the page has loaded+ useEffect(() => {+ if (loading || !location.hash) return;+ document.getElementById(location.hash.slice(1))?.scrollIntoView({ block: 'start' });+ }, [loading, location.hash]);++ // Only the repository is kept: it fills in the direct links in the setup guide. No token is needed.const handleSaveGithub = async e => {e.preventDefault();setGhSaving(true);try {- await api.saveGithubSettings({ pat: ghPat || undefined, repoOwner: ghRepoOwner, repoName: ghRepoName, branch: ghBranch });- showToast('GitHub settings saved');- if (ghPat) setGhPatSet(true);- setGhPat('');+ await api.saveGithubSettings({ repoOwner: ghRepoOwner.trim(), repoName: ghRepoName.trim(), branch: 'main' });+ showToast('Repository saved. The links in the guide now point to it.');} catch (err) {- showToast(`Couldn't save GitHub settings. ${err.message}`, 'error');+ showToast(`Couldn't save the repository. ${err.message}`, 'error');} finally {setGhSaving(false);}};+ const links = repoLinks(ghRepoOwner, ghRepoName);+ const adminSteps = [+ {+ title: 'Check the server scheduler',+ body: <>The Cloudflare Worker publishes due posts every 15 minutes. It is set up by deploying the backend (the cron is in <code className="font-mono text-small">backend/wrangler.toml</code>). In the Cloudflare dashboard, open Workers and Pages, then the twiligent Worker, then Settings, and confirm the trigger <code className="font-mono text-small">*/15 * * * *</code> is listed. Nothing else is required for scheduling to work.</>,+ },+ {+ title: 'Optional: add the GitHub Actions backup',+ body: <>The repository includes <code className="font-mono text-small">{WORKFLOW_FILE}</code>, which publishes due posts if the Worker cron is paused or failing. It needs your own copy of the repository on GitHub (a fork or a clone you pushed). Enter it below to get direct links.</>,+ },+ {+ title: 'Add two repository secrets',+ body: <>In the repository on GitHub, open Settings, then Secrets and variables, then Actions, then New repository secret. {links && <a href={links.newSecret} target="_blank" rel="noopener noreferrer">Open the new secret page</a>}</>,+ extra: (+ <div className="mt-1.5 flex flex-col gap-2">+ {SECRET_NAMES.map(secret => (+ <div key={secret.name} className="flex flex-col gap-1 rounded-control border border-line bg-surface-sunken px-3 py-2">+ <div className="flex items-center gap-2">+ <code className="flex-1 font-mono text-small text-ink">{secret.name}</code>+ <CopyButton text={secret.name} />+ </div>+ <p className="text-caption text-ink-faint">{secret.hint}</p>+ </div>+ ))}+ </div>+ ),+ },+ {+ title: 'Turn on the workflow',+ body: <>Open the Actions tab. Forks start with workflows switched off: choose the button to enable them. Then open <strong>Instagram Scheduled Publisher</strong> and choose Enable workflow if GitHub shows it as disabled. {links && <a href={links.workflow} target="_blank" rel="noopener noreferrer">Open the workflow</a>}</>,+ },+ {+ title: 'Run it once to test',+ body: 'On the workflow page choose Run workflow. Open the run: the log ends with "No posts due for publishing" or lists the posts it published. A red run with "Missing SUPABASE_URL or SUPABASE_SERVICE_KEY" means a secret name is misspelled.',+ },+ {+ title: 'Mind the free minutes on private repositories',+ body: <>Public repositories run Actions for free. Private ones get 2,000 minutes a month, and a run every 15 minutes uses more than that. For a private repository, change the cron in <code className="font-mono text-small">{WORKFLOW_FILE}</code> to <code className="font-mono text-small">*/30 * * * *</code>. GitHub also pauses scheduled workflows in public repositories after 60 days without commits; re-enable it from the Actions tab if that happens.</>,+ },+ ];+const handleTest = async () => {setTesting(true);setTestResult(null);@@ -209,71 +276,51 @@ export default function Settings() {</SettingsSection><SettingsSection- id="github"- title="GitHub"- description="Used for scheduled publishing through GitHub Actions. The token lets the scheduler trigger workflows in your repository."+ id="scheduling"+ title="Scheduled publishing"+ description="How scheduled Instagram posts go out, and what the person who runs this instance sets up once.">- <SurfaceBox>- <form className="flex flex-col gap-5" onSubmit={handleSaveGithub}>- <div className="grid grid-cols-1 gap-5 sm:grid-cols-2">- <FieldRow label="Repository owner" htmlFor="gh-owner">- <Input id="gh-owner" placeholder="owner" value={ghRepoOwner} onChange={e => setGhRepoOwner(e.target.value)} autoComplete="off" />+ <SurfaceBox title="How it works for you">+ <Steps steps={[+ { title: 'Schedule a post', body: 'In Publish, choose an account, the content type and the file, write the caption, pick Schedule, then a date and time, and choose Schedule post. The file uploads straight away.' },+ { title: 'The server publishes it', body: 'Within 15 minutes after the time you picked, the server publishes the post. Your browser can be closed and your computer can be off.' },+ { title: 'Keep the account connected', body: 'The post uses the Instagram account you picked. If that account is removed or its access expires before the time, the post fails and shows the reason under Publish, Scheduled posts. Refresh the account in Accounts if Instagram asks you to reconnect.' },+ {+ title: 'If a post stays Pending',+ body: <>A post still Pending 30 minutes after its time means the scheduler on this server is not running. Email the administrator at <a href={adminMailto('Scheduled posts are not publishing on Twiligent')}>{ADMIN_EMAIL}</a> with the time of the post. You can edit or delete a Pending post at any time.</>,+ },+ ]} />+ <div className="mt-5 flex flex-wrap items-center gap-3 rounded-control bg-surface-sunken/60 px-3 py-2.5 text-small text-ink-muted">+ <Clock className="size-4 shrink-0 stroke-[1.75] text-ink-faint" />+ Instagram allows up to 100 posts per account in any 24 hours, including scheduled ones.+ </div>+ </SurfaceBox>++ <SurfaceBox title="Set up for administrators" subheader="Only the person who deploys this Twiligent instance does this, once.">+ <form className="mb-6 flex flex-col gap-4" onSubmit={handleSaveGithub}>+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <FieldRow label="GitHub repository owner" hint="Your GitHub username or organisation" htmlFor="gh-owner">+ <Input id="gh-owner" placeholder="your-username" value={ghRepoOwner} onChange={e => setGhRepoOwner(e.target.value)} autoComplete="off" /></FieldRow>- <FieldRow label="Repository name" htmlFor="gh-repo">+ <FieldRow label="Repository name" hint="Your copy of the Twiligent repository" htmlFor="gh-repo"><Input id="gh-repo" placeholder="twiligent" value={ghRepoName} onChange={e => setGhRepoName(e.target.value)} autoComplete="off" /></FieldRow></div>- <FieldRow label="Branch" htmlFor="gh-branch">- <Input id="gh-branch" placeholder="main" value={ghBranch} onChange={e => setGhBranch(e.target.value)} autoComplete="off" className="sm:max-w-xs" />- </FieldRow>- <FieldRow- label={<span className="flex items-center gap-2">Personal access token{ghPatSet && <Badge variant="success"><CheckCircle2 />Saved</Badge>}</span>}- hint="Leave blank to keep the saved token. The guide below explains how to create one."- htmlFor="gh-pat"- >- <Input- id="gh-pat"- type="password"- placeholder={ghPatSet ? 'Enter a new token to replace the saved one' : 'github_pat_...'}- value={ghPat}- onChange={e => setGhPat(e.target.value)}- autoComplete="off"- className="font-mono"- />- </FieldRow>- <div>- <Button type="submit" disabled={ghSaving}>+ <div className="flex flex-wrap items-center gap-2">+ <Button type="submit" variant="outline" disabled={ghSaving || !ghRepoOwner.trim() || !ghRepoName.trim()}>{ghSaving ? <Spinner className="size-4" /> : <Save data-icon="inline-start" />}- {ghSaving ? 'Saving' : 'Save GitHub settings'}+ {ghSaving ? 'Saving' : 'Save repository'}</Button>+ {links && (+ <Button variant="ghost" render={<a href={links.actions} target="_blank" rel="noopener noreferrer" />}>+ <ExternalLink data-icon="inline-start" />Open Actions+ </Button>+ )}</div>+ <p className="text-caption text-ink-faint">No personal access token is needed. Scheduling never writes to GitHub; the workflow only reads due posts from Supabase.</p></form>- </SurfaceBox>-- <SurfaceBox title="Create a GitHub personal access token" subheader="A token lets this app and its workflow act on your repository on your behalf.">- <ol className="flex flex-col gap-4">- {PAT_STEPS.map((step, i) => (- <li key={step.title} className="flex gap-3">- <span className="flex size-6 shrink-0 items-center justify-center rounded-full bg-surface-sunken font-mono text-caption font-medium text-ink-muted">{i + 1}</span>- <div className="flex min-w-0 flex-col gap-1 pt-0.5">- <p className="text-sm font-medium text-ink">{step.title}</p>- <div className="text-sm text-ink-muted [&_strong]:font-semibold [&_strong]:text-ink">{step.body}</div>- {step.code && (- <div className="mt-1.5 flex items-center gap-2 rounded-control border border-line bg-surface-sunken px-3 py-1.5">- <code className="flex-1 font-mono text-small text-ink">{step.code}</code>- <CopyButton text={step.code} />- </div>- )}- </div>- </li>- ))}- </ol>- <Alert variant="warning" className="mt-5">- <AlertTriangle />- <AlertDescription>- Never put a token in code, a commit or a public place. If one is exposed, delete it on GitHub straight away and generate a new one.- </AlertDescription>- </Alert>+ <Steps steps={adminSteps} />+ <p className="mt-5 text-caption text-ink-faint">The Worker and the workflow can run side by side. Each post is claimed by whichever runs first, so it is never published twice.</p></SurfaceBox></SettingsSection>@@ -287,16 +334,11 @@ export default function Settings() {<p className="text-sm font-medium text-ink">Instagram</p><ol className="flex list-decimal flex-col gap-1 pl-5 text-sm text-ink-muted marker:text-ink-faint"><li>The account must be an Instagram Business or Creator account.</li>- <li>In Accounts, choose Add account, then Instagram account.</li>- <li>Continue to Instagram and sign in there.</li>+ <li>Get tester access from the administrator and accept the invite (below).</li>+ <li>In Accounts, choose Add account, then Instagram account, then Continue to Instagram.</li><li>Approve the requested permissions. Instagram sends you back here automatically.</li></ol>- <Alert variant="info" className="mt-2">- <Info />- <AlertDescription>- While the Meta app is in development mode, only test users added in the Meta app dashboard can connect. Add your Instagram account as a tester first.- </AlertDescription>- </Alert>+ <InstagramTesterNotice className="mt-2" /></div><div className="flex flex-col gap-1 px-5 py-4"><p className="text-sm font-medium text-ink">Cloudinary</p>diff --git a/frontend/src/lib/contact.js b/frontend/src/lib/contact.jsnew file mode 100644index 0000000..a691c38--- /dev/null+++ b/frontend/src/lib/contact.js@@ -0,0 +1,12 @@+// Who people on this instance contact for access requests and scheduling problems.+// Self-hosters set VITE_ADMIN_EMAIL to their own address.+export const ADMIN_EMAIL = import.meta.env?.VITE_ADMIN_EMAIL || '[email protected]';++export function adminMailto(subject, body = '') {+ const params = new URLSearchParams({ subject });+ if (body) params.set('body', body);+ // URLSearchParams encodes spaces as "+", which mail clients show literally+ return `mailto:${ADMIN_EMAIL}?${params.toString().replace(/\+/g, '%20')}`;+}++export const INSTAGRAM_TESTER_INVITES_URL = 'https://www.instagram.com/accounts/manage_access/';