diff --git a/astro.config.ts b/astro.config.ts index 0c5d1e6a..79c849ce 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -127,6 +127,16 @@ export default defineConfig({ access: "public", optional: true, }), + PUBLIC_SYNTWIN_ENABLED: envField.boolean({ + context: "client", + access: "public", + default: true, + }), + PUBLIC_SYNTWIN_ROOM_ID: envField.string({ + context: "client", + access: "public", + default: "j97dc3ekdfj0hffadfwwqb19w98h3q3m", + }), }, }, }) diff --git a/docs/ai-tools.md b/docs/ai-tools.md index 6eac476d..066fdea9 100644 --- a/docs/ai-tools.md +++ b/docs/ai-tools.md @@ -3,3 +3,11 @@ - Tool functions in `tools.ts` use operations internally - Return sanitized data (exclude `_ref` properties) - No file upload support in AI tools + +## Person summaries + +The shared field guidance lives in `src/shared/tools/person-summary-guidance.ts`. The in-app system prompt and create/update person tools use it directly. + +A summary is a compact bio: "How would you introduce them to your friends?" Temporary events belong in notes. Leave summary empty when there is no known biographical context. The in-app assistant can update an outdated bio from journal evidence. + +written with gpt-6.1-sol in Codex diff --git a/docs/syntwin.md b/docs/syntwin.md new file mode 100644 index 00000000..612ae7e3 --- /dev/null +++ b/docs/syntwin.md @@ -0,0 +1,29 @@ +# Syntwin integration + +The website loads Carl's Syntwin through `src/shared/ui/syntwin-embed.astro`. The app loads it through `src/app/components/syntwin-guide.tsx` once the account locale is known. The script stays outside the React router. Syntwin restores the conversation across full page loads on the same origin. + +Both scripts set `data-context` to identify website exploration or in-app help. The attribute contains no account or journal data. Syntwin manages the greeting and conversation behavior. + +The website has a CTA below the hero and a floating launcher. Fresh app visits open the guide through Settings → Help → Talk to Carl's AI twin. The app uses `data-launcher="none"`; Syntwin keeps a launcher for an ongoing conversation carried from the website. The Settings button uses `data-syntwin-open`. + +## Configuration + +- Public room: https://my.syntwin.ai/app/d/j97dc3ekdfj0hffadfwwqb19w98h3q3m +- Room settings: https://my.syntwin.ai/app/deploy/j97dc3ekdfj0hffadfwwqb19w98h3q3m?settings=room +- Embed script: https://my.syntwin.ai/omny.js + +Room instructions, knowledge sources, source access, notifications and test mode are managed in Syntwin. Edit them there. This repository documents the integration and Tilly's product behavior. + +`PUBLIC_SYNTWIN_ROOM_ID` defaults to Carl's Tilly room. Set it to another room for your own deployment. Set `PUBLIC_SYNTWIN_ENABLED=false` to disable the script, website CTA and Settings Help section. An empty room ID is not an off switch: Astro treats empty environment variables as unset and restores the default. No Syntwin secret belongs in Tilly. + +Launcher appearance, interaction modes and page permissions come from the room's Omny settings. The embed starts in the page's language and retains the conversation language across navigation. The room's operator privacy notice points to https://tilly.social/en/privacy. + +Account controls are hidden with `data-syntwin-hidden`. Sign-in and bulk data controls use `data-syntwin-readonly`. `data-syntwin-avoid="0px"` on the hero actions folds the launcher while those actions are visible on phones. Its value is an IntersectionObserver margin. + +## Local verification + +In a fresh worktree, run `work setup` before `work up`. Use `work urls` to find the local website. The embed connects to production Syntwin. Use a separate test room and fictional journal details for automated or exploratory conversations. + +Check a fresh website conversation and a fresh app conversation from Settings Help. Verify that website-to-app navigation keeps the session and sends the app context. Check an ongoing minimized call, English and German, declined and revoked page access, and phone layouts. Do not clear site data to restart a conversation, because that can erase anonymous journal entries. + +written with gpt-6.1-sol in Codex diff --git a/src/app/components/splash-screen.tsx b/src/app/components/splash-screen.tsx index a0da4c7d..598b428c 100644 --- a/src/app/components/splash-screen.tsx +++ b/src/app/components/splash-screen.tsx @@ -63,7 +63,10 @@ function SplashScreenStatic() { }, []) return ( -
+
Tilly
@@ -75,6 +78,7 @@ function SplashScreen({ show }: { show?: boolean }) { {show !== false && ( { + document.documentElement.lang = locale + if ( + !PUBLIC_SYNTWIN_ENABLED || + !PUBLIC_SYNTWIN_ROOM_ID || + document.getElementById("tilly-syntwin") + ) { + return + } + + // Syntwin reads the page language once, so wait for the account locale. + let script = document.createElement("script") + script.id = "tilly-syntwin" + script.src = "https://my.syntwin.ai/omny.js" + script.async = true + script.dataset.room = PUBLIC_SYNTWIN_ROOM_ID + script.dataset.launcher = "none" + script.dataset.context = + "The visitor is inside the Tilly app, where they can manage people, notes and reminders. This is in-app help, possibly continuing a walkthrough from the website." + document.body.append(script) + }, [locale]) + + return null +} diff --git a/src/app/features/settings/screens/settings-screen.tsx b/src/app/features/settings/screens/settings-screen.tsx index 5a5c4f47..1dd20e6a 100644 --- a/src/app/features/settings/screens/settings-screen.tsx +++ b/src/app/features/settings/screens/settings-screen.tsx @@ -13,6 +13,7 @@ import { PWASection } from "../widgets/pwa-section" import { AppSection } from "../widgets/app-section" import { DataSection } from "../widgets/data-section" import { AboutSection } from "../widgets/about-section" +import { HelpSection } from "../widgets/help-section" export { SettingsScreen } @@ -38,6 +39,7 @@ function SettingsScreen({ fallback }: SettingsScreenProps) { {!isPWAInstalled && } +
diff --git a/src/app/features/settings/widgets/account-section.tsx b/src/app/features/settings/widgets/account-section.tsx index a6edc8a1..065291de 100644 --- a/src/app/features/settings/widgets/account-section.tsx +++ b/src/app/features/settings/widgets/account-section.tsx @@ -43,7 +43,7 @@ function AccountSection() { : t("settings.account.description.signedOut.offline") } > -
+
{isAuthenticated ? ( <>
diff --git a/src/app/features/settings/widgets/data-section.tsx b/src/app/features/settings/widgets/data-section.tsx index f69d9d06..81fa9661 100644 --- a/src/app/features/settings/widgets/data-section.tsx +++ b/src/app/features/settings/widgets/data-section.tsx @@ -18,7 +18,7 @@ function DataSection({ me }: { me: SettingsAccount }) { title={t("settings.data.title")} description={t("settings.data.description")} > -
+

diff --git a/src/app/features/settings/widgets/help-section.tsx b/src/app/features/settings/widgets/help-section.tsx new file mode 100644 index 00000000..bda7c8cc --- /dev/null +++ b/src/app/features/settings/widgets/help-section.tsx @@ -0,0 +1,44 @@ +import { + PUBLIC_SYNTWIN_ENABLED, + PUBLIC_SYNTWIN_ROOM_ID, +} from "astro:env/client" +import { Button, buttonVariants } from "#shared/ui/button" +import { T, useIntl } from "#shared/intl/setup" +import { SettingsSection } from "#app/features/settings/parts/settings-section" +import { useOnlineStatus } from "#app/hooks/use-online-status" + +export { HelpSection } + +function HelpSection() { + let t = useIntl() + let isOnline = useOnlineStatus() + + if (!PUBLIC_SYNTWIN_ENABLED || !PUBLIC_SYNTWIN_ROOM_ID) return null + + return ( + +

+ + + + + + + +
+ + ) +} diff --git a/src/app/main.tsx b/src/app/main.tsx index 46f2bd24..9afaf6f7 100644 --- a/src/app/main.tsx +++ b/src/app/main.tsx @@ -21,6 +21,7 @@ import { import { PWAInstallHint } from "#app/components/pwa-install-hint" import { Toaster } from "#shared/ui/sonner" import { MainErrorBoundary } from "#app/components/main-error-boundary" +import { SyntwinGuide } from "#app/components/syntwin-guide" export function PWA() { return ( @@ -74,6 +75,7 @@ function RouterWithJazz() { return ( + {contextMe && } {locale === "de" ? ( diff --git a/src/app/routes/index.tsx b/src/app/routes/index.tsx index cb6ae1d9..5fe984c7 100644 --- a/src/app/routes/index.tsx +++ b/src/app/routes/index.tsx @@ -110,6 +110,7 @@ function WelcomeIndex() {