Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open-ended work. The default provider and model come from Settings → Providers
| Away spans | `away/`, `web/src/away.ts`, `web/src/components/AwayEditor.tsx`, `mobile/src/features/overview/AwaySheet.tsx` | Trips and days off in `data/away.json` (`AWAY_FILE`): inclusive local day keys, edited by the owner from the Overview's schedule card (`/api/away`). Every prompt's date block marks away days in its 14-day table and names the current and coming spans, capped at five, and always says to propose a trip found in email (`away/grounding.mjs`); the calendar draws them as a band; a queued notification whose category's `away` column is `'hold'` waits one night at a time (`heldBy: 'away'`) and goes out the first morning the owner is back, older digest copies dropped and nothing distinct lost (`away/hold.mjs` through `gate.addHold`, `notify/categories.mjs`). Agents get `totem_away_list` and `totem_away_propose` (`away__*` in the gateway): propose stages an `away` inbox item once per set of dates, only the dashboard accepts it, and there is no write tool. Agents never edit `data/away.json`; the store re-reads it when it changes on disk and drops rows that fail validation. `docs/away.md`. |
| Voice journal | `journal/`, `web/src/journal/` | Record in the browser, transcribe on the box with whisper.cpp, digest into the notes repo after a grace period. `docs/journal.md`. |
| Notifications | `notify/`, `web/public/sw.js` | Web Push (RFC 8291/8292 on `node:crypto`) and APNs for the native iPhone app (`notify/apns.mjs`, `APNS_*`; a chat's notification is taken back off the phone by a silent push once the chat is read anywhere, `notifier.dismiss`), a due-queue drained on the job tick, digests, feed scan, quota nudges. On an away day a queued notification whose category's `away` column is `'hold'` waits until the owner is back (`createAwayHold` in `away/hold.mjs`, registered through `gate.addHold`; a hold's `tag` stays on the entry as `heldBy`, which skips the missed-delivery cutoff and is claimed after everything never held; a repeat is suppressed when first held, by `admit(item, { reserve: false })`, not after the earlier copy's window runs out). Every push passes the dedupe gate in `notifier.deliver` (`notify/dedupe.mjs`): a key already sent inside its window (a quota fact's key is its reset window, persisted across restarts; keyless repeats only in categories with `textDedupe`) or a story already told (only items carrying `story`: canonical link, or headlines with the same lead model and version, no event kind the earlier lacks, shared details and real word overlap, within 48 h; an optional background model check for close calls, Claude or Codex only, that fails open) is counted on the first notification instead of pushed, and logged. Sends are reserved, then committed only if they reached the bell or a phone. Settings → Notifications › Duplicates; `gate.addHold(fn)` keeps a queued one waiting. Habits get no completion nudges (no "streak ends tonight"): they can be logged for past days, so the notifier drops any still queued (`isRetiredNudge`). `docs/notifications.md`. |
| Totems | `totems/`, the "Totems" block in `bridge.mjs`, `web/src/components/TotemsView.tsx`, `web/src/totems/` | On the rail after Chat since 1.1 (`TOTEMS_TAB_DEF` in `App.tsx`; its badge counts totem chats with an unread report), and from a totem chat's gear. Laid out like a project's page: a composer that hands a description to the builder, then flush rows (drafts, group chats, totems, and a folded shelf of the built-ins that are off): a row opens the totem's chat (its runs are posted there), the gear its page, whose settings are drawn with the Settings dialog's sections and rows (`web/src/totems/fields.tsx`, shared with the builder's draft); the totem's chat header has a play button that runs it now. Neither the web's chats panel nor the iPhone drawer lists totem chats; the drawer has a Totems row under Overview with the same dot. Any chat can bring totems in: `totems__list`/`totems__ask`/`totems__wait`/`totems__invite` run a totem on its own model with its memory and tools, and its answer shows under its name (`web/src/chat/totemReply.ts`); a chat with `members` is a group chat its agent hosts. On by default (`totemsInChat`, Settings → Chat). Standing agents over the job store: every job is a totem (no second scheduler). A totem's runs keep the standard job limits unless its Full access switch is on (`access: 'full'`: bypassPermissions / danger-full-access, since nothing can approve a command mid-run), and write their memory and their chat's outputs folder. Agent totems keep `data/totems/<id>/memory.md` (pasted into each run and ask, a fresh session that needs its state; only named in the totem's chat, which reads it on demand), end runs with `NOTIFY:`/`QUIET`, post runs to their chat `totem-<id>`, and get cheapest-first model recommendations from the builder or any model from the chat picker (`modelsOnly`). The builder asks scoping questions in a chat beside the draft and revises it on each reply; an unfinished design is a draft (`totems/drafts.mjs`, `data/totem-drafts/`). A totem can wake on a watch (git branch or web page) instead of a schedule; the built-in "Deploy Totem" pulls, rebuilds and restarts the bridge when main moves. Any chat can propose a change (Accept card). Replaced Studio. `docs/totems.md`. |
| Totems | `totems/`, the "Totems" block in `bridge.mjs`, `web/src/components/TotemsView.tsx`, `web/src/totems/` | On the rail after Chat since 1.1 (`TOTEMS_TAB_DEF` in `App.tsx`; its badge counts totem chats with an unread report), and from a totem chat's gear. Laid out like a project's page: a composer that hands a description to the builder, then flush rows (drafts, group chats, totems, and a folded shelf of the built-ins that are off): a row opens the totem's chat (its runs are posted there), the gear its page, whose settings are drawn with the Settings dialog's sections and rows (`web/src/totems/fields.tsx`, shared with the builder's draft); the totem's chat header has a play button that runs it now. Neither the web's chats panel nor the iPhone drawer lists totem chats; on the iPhone the Totems page opens from the Overview's app row, not the drawer. Any chat can bring totems in: `totems__list`/`totems__ask`/`totems__wait`/`totems__invite` run a totem on its own model with its memory and tools, and its answer shows under its name (`web/src/chat/totemReply.ts`); a chat with `members` is a group chat its agent hosts. On by default (`totemsInChat`, Settings → Chat). Standing agents over the job store: every job is a totem (no second scheduler). A totem's runs keep the standard job limits unless its Full access switch is on (`access: 'full'`: bypassPermissions / danger-full-access, since nothing can approve a command mid-run), and write their memory and their chat's outputs folder. Agent totems keep `data/totems/<id>/memory.md` (pasted into each run and ask, a fresh session that needs its state; only named in the totem's chat, which reads it on demand), end runs with `NOTIFY:`/`QUIET`, post runs to their chat `totem-<id>`, and get cheapest-first model recommendations from the builder or any model from the chat picker (`modelsOnly`). The builder asks scoping questions in a chat beside the draft and revises it on each reply; an unfinished design is a draft (`totems/drafts.mjs`, `data/totem-drafts/`). A totem can wake on a watch (git branch or web page) instead of a schedule; the built-in "Deploy Totem" pulls, rebuilds and restarts the bridge when main moves. Any chat can propose a change (Accept card). Replaced Studio. `docs/totems.md`. |
| Jobs | `jobs/` | Timezone-aware schedules (`daily`, `weekly`, `interval`, `window`), watch triggers over one or more git branches or pages, checked without AI (`jobs/triggers.mjs`), and `data/jobs.json`. One 30-second tick in `bridge.mjs` runs jobs, checks watches and drains notifications. A job id Totem stopped shipping goes in the store's `retiredIds` and is dropped on read. `docs/jobs.md`. |
| Skills | `skills/` | Every prompt as an editable `SKILL.md` with `{{variables}}`. Generic seeds in `skills/seeds/` are copied into `data/skills/` once. Chat cites a skill with `/name` anywhere in a message; the owner's Claude Code/Codex/Cursor skills are found read-only by `skills/agent-skills.mjs` and cited the same way. `docs/skills.md`. The `change-totem` seed is the steps for changing Totem itself from a chat; the guardrails are in code (next row), not in the skill. |
| Changing Totem from a chat | `dev/change.mjs`, `change_start`/`change_finish` on each chat run's `/agent-mcp` (`changeTools` in `bridge.mjs`), `web/src/chat/ChangeCard.tsx` | "Build me a page for X" ends as a pull request card, never as edits to the checkout Totem runs from. Offered only to Full-access chat runs. `change_start` fetches `origin/main` into `refs/totem-change/base` (never moving the live `origin/main`) and makes a worktree under `CHANGE_WORKTREES_DIR` (default `~/.totem-changes`; the path is checked before anything is created, and refused inside or around the live checkout or over `AGENT_CWD`/cwd), linking `node_modules`. `change_finish` first checks every field of its record (`data/changes.json`, denied to Claude's file tools) against git and GitHub, then stages the worktree into a tree and checks it as one diff against the base, reading git's output in full (anything that would not fit is refused; at most 500 files, 5 MB of diff; diffs with `--no-ext-diff --no-textconv` and fixed prefixes): paths are case-folded and must be ASCII (macOS deploys), and it refuses data/env/secrets/`.git`/`node_modules`, package-manager and git config files, symlinks and submodules, case collisions, protected files (`auth/`, `logs/approval*`, `.github/`, the rule-enforcing files in `PROTECTED_FILES`, the flow itself), `bridge.mjs` lines in `GUARDED_LINE`, changed package `scripts`, `.gitignore` lines about `node_modules`, and any secret from Totem's credential files (`data/*-tokens.json`, `auth.json`, `ai-settings.json`, `integrations.json`, the MCP manifest's env, `BRIDGE_SECRET`) or a known token shape anywhere in a changed file's whole content (a tripwire for accidents, not a boundary). It then makes one fresh commit of that tree on the last push, runs `npm test` (retried once) and the web build with a throwaway `HOME` and no git config or tokens, refuses if they moved HEAD or wrote tracked files or the live checkout got dirty (by content hash), and pushes exactly that SHA to `totem-change/*`. Stop or a timeout kills the checks' whole process tree. It opens the PR with `gh`, saves it at once, and posts a `change-pr` card whose CI state is a snapshot at push. A merged or closed PR starts a fresh worktree, and so does a record that no longer checks out (the remote branch moved); every git call has filters and attribute files switched off, and `.git/info/attributes` is refused; `cleanup()` (boot, then every 6 h) removes those and ones abandoned 14 days. No merge path anywhere. Off unless the owner sets `CHANGE_FLOW_ENABLED=true` (`changeFlowEnabled`), and only when Totem runs from a git checkout. `docs/change-totem.md`. |
Expand Down
4 changes: 2 additions & 2 deletions docs/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -1649,8 +1649,8 @@ search box of their own: the Search tab finds any chat, parked or not.

The iPhone app draws no Snoozed or Settled shelf in its drawer, which has one scroll: they
are a button each with a count (a dot when the open chat is on it) in the drawer's foot
beside Settings, for whatever the list is scoped to, and a button opens a three-quarter
sheet of those chats with a switch between the two (`mobile/src/features/chat/ShelfSheet.tsx`). The app shows no toasts but errors,
beside Settings, for whatever the list is scoped to (liquid glass on iOS 26, melted into one
shape), and a button opens a three-quarter glass sheet of those chats with a switch between the two (`mobile/src/features/chat/ShelfSheet.tsx`). The app shows no toasts but errors,
so its settle has no Undo toast; Un-settle in the sheet puts a chat back.

- **Settle** (✓ on hover, the chat menu, or the leader shortcut `c s`) shelves a chat
Expand Down
34 changes: 30 additions & 4 deletions mobile/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ Use `npx expo install <pkg>` for dependencies so versions match the SDK.
on the step `shell/drawerKeyboard.ts` names. The composer rides the keyboard over the drawer, so a keyboard left up
covered half of it. KeyboardController resigns whatever holds the keyboard, not only the input React Native's focus
tracker knows, which is all `Keyboard.dismiss()` blurs. A new way to open the drawer needs nothing more.
- `src/shell/` is the frame: `AppDrawer` (the sidebar: Search, which opens the Search page, by the wordmark; Overview, Totems
(a dot while a totem's report waits; totems' chats are not in the list), the Productivity tools as a
4 + 3 grid the heading's chevron folds away, remembered per device, then the chats, all in one scroll; a pinned foot
with the list's Snoozed and Settled buttons, which open `features/chat/ShelfSheet.tsx`, and New chat and Settings on the right), `Screen` (top bar with the AI usage pill on the right, where the web phone bar has new chat; plus the voice/new-chat buttons), `nav.ts` (`navigateTo` takes the
- `src/shell/` is the frame: `AppDrawer` (the sidebar, the whole screen wide, with a close button in its head: Search,
which opens the Search page, by the wordmark; Overview (a dot while a totem's report waits, as on the Overview's
Totems tile), the Productivity tools as a
4 + 3 grid the heading's chevron folds away, remembered per device, then the chats, all in one scroll; a foot floating
over the scroll's end with the list's Snoozed and Settled buttons, which open `features/chat/ShelfSheet.tsx`, and New
chat and Settings on the right; no Totems row: totems' chats are not in the list, and the Totems page opens from the
Overview's app row), `Screen` (top bar with the AI usage pill on the right, where the web phone bar has new chat; plus
the corner new-chat button; voice mode starts from the home-screen quick action, not a corner button), `nav.ts` (`navigateTo` takes the
web's tab/app ids, `openChat`, `newChat`, `startVoice`), `routes.ts` (where each id lands, pure and
tested by `routes.test.mjs`), `ToolIcon` (each tool's mark), `quickActions.ts` (home-screen long-press).
- `src/app/` holds routes only. `(app)/` is the drawer with one screen per web tab. Pushed screens and sheets
Expand All @@ -116,6 +120,28 @@ Use `npx expo install <pkg>` for dependencies so versions match the SDK.
`navigateTo('todos')`, `{ tab: 'productivity', app }`, notification links (`destination.ts`) and the
landing-tab preference all go through `routes.ts`.

- **Liquid glass** (`src/ui/glass.tsx`, `expo-glass-effect`, already in the build): the drawer's foot, the corner
new-chat button, the composer and the shelf sheet. `GlassButton` is a pressable glass shape with a solid `fallback`
for iOS before 26, and `GlassGroup` (a `GlassContainer`) melts shapes within `spacing` into one, so neighbouring
buttons read as one piece; keep a row of floating buttons in one group. A sheet is glass when its route uses
`glassSheet` in `src/app/_layout.tsx` (a formSheet over a clear screen, which iOS 26 draws in glass) and its content
is clear too; rows on it pass `glass` to `ThreadItem`, which is clear at rest and takes its solid fill the
frame it starts to move (its swipe progress copied on the UI thread), so the actions never show through its text.
- **Over-the-air updates arrive without a cold start** (`shell/otaUpdates.tsx`, rules in `shell/otaPolicy.ts`):
expo-updates on its own checks only at launch and applies at the next launch, and iOS keeps the app suspended for
days, so a merge once seemed not to reach the phone. Coming back to the foreground checks (at most every 10 minutes)
and fetches an update or a rollback; a fetched one is applied on a return after 30 minutes away, only on the
Overview or an open chat (`safePage`: the pages whose every input saves as it changes or holds the reload; any other
page, sheet or editor may keep edits only in memory), with no input focused (a chat excepted: its drafts are flushed
just before, `onBeforeReload`), and only if nothing lands in the 1.5 s after (a
tapped notification, a quick action calling `noteArrival`, a link that moves the page or chat). Before reloading it
notes the page and chat, and the next launch goes back there (`resumedFromUpdate`) and skips the quick action the
app was first cold-launched from, which the native module never clears. Anything else a reload would lose takes
`holdReload()` while it lasts (voice mode, dictation, a journal take or typed entry, the Overview's ask box, a queued
message or sent message being edited, an inbox card's note, unsent answers to an agent's questions, an edited
LinkedIn draft); a chat not started yet is never reloaded under. An input added to the Overview or the chat screen
that keeps unsent words only in React state takes a hold too; widening `safePage` needs the same audit of that page. A build from
before this code needs two cold starts once to pick it up.
- **The drawer's chats** (`features/chat/ChatsNav.tsx`, docs/chat.md → The chats panel): the web chats panel, T3 Code's
flat list. Every chat in every project and folder on one list (unsent drafts, Pinned, the chats still in play latest
first, then Working), each a card with its place, its status in words and its linked task (`features/work/TaskBadge.tsx`,
Expand Down
21 changes: 17 additions & 4 deletions mobile/src/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// The signed-in app: the push drawer around every tab (ChatGPT's layout — the
// page slides right to reveal the sidebar, and follows a finger from the edge).
// page slides right to reveal the sidebar, which fills the screen, and follows a
// finger from the edge).
import React, { useEffect } from 'react'
import { useWindowDimensions } from 'react-native'
import { router } from 'expo-router'
import { Drawer, useDrawerProgress, type DrawerContentComponentProps } from 'expo-router/drawer'
import { KeyboardController } from 'react-native-keyboard-controller'
import { useAnimatedReaction } from 'react-native-reanimated'
Expand All @@ -13,7 +15,8 @@ import { useQuickActions } from '../../shell/quickActions'
import { usePush } from '../../shell/push'
import { useAccessReauth } from '../../shell/accessReauth'
import { useMorningCheckin } from '../../shell/morningCheckin'
import { navigateTo } from '../../shell/nav'
import { OtaUpdates, takeResumedFromUpdate } from '../../shell/otaUpdates'
import { navigateTo, openChat } from '../../shell/nav'
import { PRODUCTIVITY_APPS, TOOL_LABELS } from '../../shell/routes'
import { getSettings } from '../../lib/settings'
import { colors } from '../../theme'
Expand All @@ -39,17 +42,26 @@ export default function AppLayout() {
// landing tab is one navigation on first mount. (A quick action, handled a tick
// later, still wins.)
useEffect(() => {
// Just reloaded into an update (shell/otaUpdates.tsx): back to the page and chat he was on.
const resume = takeResumedFromUpdate()
if (resume) {
if (resume.chatId) openChat(resume.chatId)
else if (resume.path !== '/') router.navigate(resume.path as any)
return
}
const landing = getSettings().landingTab
if (landing && landing !== 'overview') navigateTo(landing)
}, [])
return (
<>
<OtaUpdates />
<Drawer
drawerContent={(props) => <DrawerContent {...props} />}
screenOptions={{
headerShown: false,
drawerType: 'slide',
// shell.css: --sh-w: min(84vw, 330px)
drawerStyle: { width: Math.min(width * 0.84, 330), backgroundColor: colors.bg2 },
// The whole screen: the page slides off to the right (the web drawer is min(84vw, 330px)).
drawerStyle: { width, backgroundColor: colors.bg2 },
overlayColor: 'rgba(0,0,0,0.35)',
swipeEnabled: true,
swipeEdgeWidth: 40,
Expand All @@ -70,5 +82,6 @@ export default function AppLayout() {
<Drawer.Screen name="fleet" options={{ title: 'Fleet' }} />
<Drawer.Screen name="settings" options={{ title: 'Settings' }} />
</Drawer>
</>
)
}
Loading
Loading