Repository navigation
feat(chat): add the Memory page, Use memory and the workspace's memory switch (W3-12b) - #2017
Merged
Merged
Conversation
…3-DB, 00457–00459) Chat's Wave 3 tables in one PR (one DB PR per wave), behind CHAT_AGENTIC: nothing reads or writes them while the flag is off. Tables, types, tests and the demo's coverage only; the code that uses them comes in W3-01, W3-06 and W3-11. Every new table has row level security on; members only ever read, anon gets nothing, and every write is the server's. - 00457: chat_schedules (CHAT-12): once, recurring or a follow-up check; run at / ready by, due and next run, the RRULE and time zone; title, prompt or skill, the brand fixed at creation, the creator it acts as and its own chat; delivery to chat and/or email, recipients only people of the workspace (a trigger checks), change-only with the last fingerprint; mode, model, effort; on/off with the reason, failures in a row, the one retry; a follow-up check's target, metric and who set it (card or full_auto, the latter only for follow-up checks). A job whose brand or creator is deleted turns off (missing_source, owner_role) instead of running on without them. chat_schedule_runs: slot and attempt (unique, so a slot never runs twice), Run now, the Chat run and answer, status, parts done, fingerprint, usage as a share, email outcome. chat_conversations.schedule_id with origin 'schedule' (one live chat per job; it stays the creator's), prompt_improve_usage.schedule_id, and reserve_chat_ai_usage taking p_schedule_id (default null, old calls still match): the row is named by the chat's job, a job that isn't the chat's is refused. Creator and Admins read a job, within their brands. - 00458: chat_skills (CHAT-13): name unique in the workspace in the format's rules, body up to 50 KB, licenses MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC (an import needs one), source user or import with the pinned commit and checksum, scan and removed parts, review status (only an approved skill can be on), private or workspace. Private or unapproved: creator and Admins; approved workspace skills: every member. chat_settings.disabled_skills for library skills. - 00459: chat_memory_items (CHAT-14): Me, brand and workspace lines, 1–300 characters, at most 4,000 a scope (a trigger under a lock per scope, deleted lines left out), one profile line a person, deleted_at for Undo; brand lines go with the brand, Me lines with the account and when the person leaves the workspace (trigger on profiles). Me: only its person; brand lines: brand access; workspace lines: every member. chat_settings.memory_enabled and chat_user_prefs.memory_enabled, both on. web/src/types/supabase.ts carries the new tables and columns; schema.test.ts checks the Wave 3 policies, limits, vocabularies, triggers and the hold's signature from the SQL; brand-access-policies.test.js lists the new tables; the demo coverage skips chat_schedules and chat_memory_items. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-09) Each / menu shortcut (CHAT-08) now has a hidden playbook in skills/ (metadata.hidden: "true"): its allowed reads, default scope, output, question rules and next moves, checked by the same format, scan and CI as the library skills. The menu gains /start, /optimize, /opportunities and /audit; "Create a report on" moves to /new-report, as /report is the Weekly report skill's. The composer sends shortcutId with the message while its trigger words stay (rewritten, it drops), and keeps it on Retry. Home chips whose job is a shortcut's send its id; chips for the focus areas' skills ask with the skill's /name. The server takes the id only for a message that is still that shortcut's, writes chat_messages.shortcut_id, loads the playbook first as one of the run's three skill bodies, offers only the reads in its data plan, and tells the model in one line what the plan leaves out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rt (W2-03)
Before work in several like parts (drafts, pages, tasks), the model calls
the engine's plan_parts with how many; the server counts how many the AI
limit left covers (fitChatUnits and POST /api/internal/chat/budget/fit,
each part one write step's worst case, an agent run's own cap included):
a count, never dollars.
All covered, the work goes on. None, the run pauses at the AI limit as
before. Some, a question card asks "Your remaining AI limit covers about
{k} of the {n} ...": Do the first {k} now (Recommended), Get more AI
credits (pauses at the limit) or Cancel (stops). With no one there (an
agent's or a scheduled run), the first {k} are done and filed and the run
stops at the AI limit as it ends. A skill's run is checked as it starts,
before anything is read. Nothing is checked on the workspace's own key.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…duled jobs Move the RRULE subset (DAILY/WEEKLY/MONTHLY on a zone's clock) from agent-schedule.ts to schedule/rule.ts, which agent-schedule.ts re-exports, and add nextJobRun for a chat_schedules row. Extract openHeadlessRun (headless-run.ts) from openAgentRun: the chat, the message, the answer, the Chat run and its state, written in the same order; agent runs use it unchanged. No behaviour change: the agent tests pass as they are. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chat's scheduled jobs (CHAT-12) now run by themselves, behind CHAT_AGENTIC. The server's minute cron calls the new /api/internal/chat/schedules/tick (CHAT_INTERNAL_SECRET) right after the agents' tick; it settles open runs, resumes jobs the AI limit paused and runs the due ones (schedule/worker.ts): - A due job is claimed by moving next_run_at (or retry_at) from what was read, so two workers run a slot once; chat_schedule_runs' unique slot and attempt is the backstop. A recurring slot over an hour late is skipped (no catch-up); a busy workspace waits for the next minute. - Each run re-checks its creator: Admin or Manager and the brand still theirs (else owner_role), brand there (missing_source), skill on (skill_off), AI limit (paused_cap, the job pauses at cap). A read-only workspace skips the slot; with Chat off nothing is touched. - The run opens in the job's own chat as its creator (openHeadlessRun), Queued then claimRunSlot, always Auto · Normal, with no session, so every change waits as a card. - A failed run retries once 10 minutes on; 3 failures in a row turn the job off. After the reset a cap-paused job goes on at its next slot. Engine (thin hooks): a job's own run is metered as feature 'schedule' with its scheduleId (budget.ts meteredAs; the server passes p_schedule_id), and a question in it takes the Recommended option and lists it at the top of the answer (schedule/unattended.ts). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…API (W3-06)
A workspace's own skills (CHAT-13, chat_skills from 00458), behind
CHAT_AGENTIC, with no new screen:
- skills/store.ts: saving a skill made in Chat (Admins and Managers),
checked as its SKILL.md with checkSkillFile, never with an Ansvisor
skill's name, under the plan's My skills limit (trial 3, Starter 10,
Growth 50, Enterprise 200; none self-hosted). Approved, on and private
to its creator at once. Its checksum is of the file as stored.
- What a person may use (enabledSkillsFor): the library but for what the
workspace turned off (chat_settings.disabled_skills), then the approved
skills that are on and theirs or shared. The / menu reads the same
(skillMenuFor), so a saved skill shows there at once.
- Engine, a thin hook: a workspace skill's body is read from its row when
a run loads it, only while it matches its checksum (else it is switched
off). "Used skill" says where it comes from (Ansvisor library, You, Your
workspace, the repo owner). An imported skill taints the run (CHAT-20
§16a): a change shows its card even in Full auto, and its block is
marked as written outside the workspace.
- Agents: an agent whose skill is off, rejected, gone or changed is
refused on Activate/Resume/Run now, and a triggered one pauses with
skill_off. Workspace skills need no connection.
- Registry: save_skill (CHAT-20 §9 row 75: AskFA, Admins and Managers,
Undo 30 days by deleting it while private and unchanged), through the
saveChatSkill server action (assertWritable first).
- API: GET /api/chat/skills; PATCH and DELETE /api/chat/skills/{id} (an
Admin or the creator); POST /api/chat/skills/{id}/share (an Admin
shares and answers the requests; the creator asks the Admins through
chat_access_requests); PATCH /api/chat/skills/library/{name} (Admins).
Every write checks the plan first (writeRefusal).
- Help: skills.md gets "Save your own skill" (still unapproved).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…worker Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tore Co-Authored-By: Claude Opus 5.5 <[email protected]>
…W3-02)
- schedule/when.ts reads a date phrase on the person's clock: 09:00 for a
day with no time, working days only when said, ready by vs run at, the
RRULE subset for repeats (at most once a day), and ambiguous phrases
("next Friday", "the 31st") returned with their likely dates for a
question card. CHAT-12's acceptance examples are its tests.
- create_schedule registry row (Scheduling area, row 78): WRITE, Ask, a
card in every mode, Admins and Managers; its precheck refuses what
won't read, a skill that's off and a full plan (Trial 1 · Starter 5 ·
Growth 25 · Enterprise 100 active jobs; follow-up checks don't count).
It runs through a session server action and logs with a 30-day Undo
that deletes the job.
- A reusable editable approval card: ChatConfirm.form, FormCard and the
row hooks form/stepKind/doneStep. The Approve sends the edited values;
the server applies them and checks them against the row's schema
before the change runs. W3-08 and W3-12a reuse it.
- The schedule step shows "Scheduled: {title}" with when and where.
- The card's usage line comes from a new internal estimate route (the
workspace's average Chat run over 30 days, as a share; never dollars).
- Help article help/chat/scheduling.md (approved: false).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-card # Conflicts: # server/src/routes/internal-chat-budget.js # server/src/routes/internal-chat-budget.test.js
The worker checked a job's /skill against the library alone, so a job on a workspace skill was turned off as skill_off, and a library skill the workspace turned off still ran. It now reads the creator's skills as a run does (enabledSkillsFor) and checks the skill's checksum. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and the workspace (W3-11)
- memory/rules.ts: 300 characters a line, 4,000 a scope, 12,000 a request;
refuses secrets (keys, passwords, Luhn cards, IBANs, Turkish ID
numbers), personal data, rule changes and hidden text; Me for every
role, Brand for Admins and Managers, Workspace for Admins (a Manager's
becomes a request an Admin's approval saves).
- memory/store.ts: a run's Me, brand and workspace lines while both
switches are on (a scheduled run gets its creator's), "Call me {first
name}" from the profile, save/edit/delete with a 10-second Undo, the
Memory list, and the switches.
- The engine puts the lines in the workspace block as <saved_notes>, data
not instructions; a change whose target only a note named waits on its
card in Full auto too. The first step that carries them shows "Used
memory", and Data used "Memory · n items".
- save_memory (always a card, every mode) and forget_memory (Ask, auto in
Full auto), each checked before its card, with Undo.
- /api/chat/memory routes; the minute tick deletes lines past their Undo.
- Help article help/chat/memory.md (approved: false).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A workspace skill could be saved as /analyze or another shortcut's command (W2-09), which would then mean two things. Saving refuses the seven shortcut names as it refuses the library's, and a skill that already has one stays out of the / menu and the run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
My skills' plan limit (Trial 3 / Starter 10 / Growth 50 / Enterprise 200) counted every skill row, so an import an Admin rejected kept taking a place. The count, and the list's "used", now leave rejected skills out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The layout now reads the / menu's skills from skills/store.ts, which
opens the admin client, so the test file failed to load ("supabaseUrl
is required"). The test stubs skillMenuFor as it stubs the other Chat
reads.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/messages/en.json # web/src/lib/chat/engine.ts
# Conflicts: # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts # web/src/lib/chat/registry/define-tool.ts # web/src/lib/chat/registry/tools.test.ts # web/src/lib/chat/registry/tools.ts # web/src/lib/chat/undo.ts
- "Remember that…" opens the editable card (W3-02's form): the line with
its counter, Save to Me / Brand: {brand} / Workspace with the scopes the
person's role doesn't change shown but off (and Brand off without a
brand), a Manager told a Workspace note goes to the Admins, and
"Replaces: “{old}”" for the line it repeats, untickable to keep both.
- The card's edits are checked as a save is (memory/card.ts): a line memory
can't keep is refused on the card in its words, and Replaces holds only
in the replaced line's scope.
- The live help counts the line and says why one can't be kept before Save
(form-assist.ts); FormCard's choices can be off; the card's context
carries the person, whose role the scopes follow.
- The step once made: "Saved to memory" with the scope under it, "Sent to
your Admins" for a Manager's Workspace note, "Removed from memory" for
"Forget that…".
- Help article help/chat/memory.md updated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y switch (W3-12b)
- /dashboard/chat/memory, from the chat header's ⋯ › Memory: "What Chat
remembers between chats.", tabs with counts for Me, Brand: {the brand
in the switcher} and Workspace, rows with Memory, Source and Updated,
each scope's characters of 4,000, and "Say “remember that…” in any chat
to add one."
- Edit inline with a counter and Delete at once with a 10-second Undo
where the person's role changes that scope; off, with who changes it,
where it doesn't.
- The Brand tab shows the brand's rules (00450 brands.brand_rules)
read-only, linked to Settings › Content and outside its 4,000; read by
the whole row, so before 00450 is applied there are none.
- "Use memory" at the top right; the workspace's switch for Admins in
Settings › Chat; with it off only Admins see the notes.
- save_memory and forget_memory open the Memory page; Help updated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hile rendering Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ff on a read-only workspace A person's Me lines are their personal data (KVKK/GDPR; owner decision 2026-11-02): on a read-only workspace they can still delete one (and Undo it) and turn their own "Use memory" off. Adding, editing, Brand and Workspace lines and the workspace's switch stay closed (402 from the store). The three routes no longer check the plan first and are named in the subscription-guard coverage list with why. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ad-only workspace The Memory page follows the store (W3-11): on a read-only workspace a person's own Me notes can still be deleted (with Undo) and "Use memory" turned off, their personal data (KVKK/GDPR; owner decision 2026-11-02). Editing, and Brand and Workspace changes, still open the upgrade dialog. Help says so in one sentence. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 of 13 tasks
gkhngyk
previously approved these changes
Nov 2, 2026
…e a switch that is on The Memory page's "Use memory" and Settings › Chat's Memory switch read "Off: …" even while on (smoke test 2026-11-02). Both now say "When off, …". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eature/chat-memory-page
Collaborator
Author
|
Heads-up: I pushed one small copy fix on top of your commits here (beb4310, a fast-forward merge of 29cecde, no conflicts). The "Use memory" note now reads "When off, Chat doesn't use your notes or save new ones." instead of starting with "Off:" while the switch is on; Settings › Chat's Memory row reads the same way, with a test. Nothing else changed. We won't push to the Wave 3 chain again while you're updating it. |
# Conflicts: # help/chat/chat.md # server/src/lib/chat-budget.test.js # server/src/routes/internal-chat-budget.js # server/src/routes/internal-chat-budget.test.js # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
# Conflicts: # server/src/lib/brand-access-policies.test.js # server/src/lib/chat-budget.js # supabase/schema.sql # web/src/lib/chat/agent-driver.ts # web/src/lib/chat/schema.test.ts # web/src/types/supabase.ts
# Conflicts: # web/messages/en.json # web/src/lib/chat/agent-driver.ts # web/src/lib/chat/agents.ts
# Conflicts: # server/src/lib/chat-budget.js # server/src/lib/chat-budget.test.js # server/src/routes/internal-chat-budget.js # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
# Conflicts: # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
# Conflicts: # server/src/lib/chat-budget.js # server/src/lib/chat-budget.test.js # server/src/routes/internal-chat-budget.js # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
# Conflicts: # web/src/components/chat-access/chat-settings-section.tsx
gkhngyk
previously approved these changes
Nov 2, 2026
8 of 13 tasks
# Conflicts: # help/chat/skills.md # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts # web/src/lib/chat/registry/define-tool.ts # web/src/lib/chat/registry/tools.test.ts # web/src/lib/chat/registry/tools.ts # web/src/lib/chat/skills/store.ts # web/src/lib/chat/undo.ts # web/src/lib/chat/write.test.ts # web/src/lib/help/approved-articles.json
# Conflicts: # help/chat/chat.md # server/src/routes/internal-chat-budget.js # server/src/routes/internal-chat-budget.test.js # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts # web/src/lib/chat/registry/define-tool.ts # web/src/lib/chat/registry/tools.test.ts # web/src/lib/chat/registry/tools.ts # web/src/lib/chat/schedule/worker.test.ts # web/src/lib/chat/schedule/worker.ts # web/src/lib/chat/undo.ts
8 of 13 tasks
…chat-memory-cards
…chat-memory-cards # Conflicts: # web/messages/en.json # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts # web/src/lib/chat/registry/define-tool.ts # web/src/lib/chat/registry/tools.test.ts # web/src/lib/chat/registry/tools.ts # web/src/lib/chat/undo.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-page # Conflicts: # web/messages/en.json # web/src/components/chat/chat-shell.tsx
gkhngyk
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Memory page (CHAT-14 items 21–25), behind
CHAT_AGENTIC: what Chat remembers between chats, where a person reads, edits and deletes the notes, and turns memory off. No migration. Stacked on W3-12a (which is stacked on #2014 and W3-11).Memory (
/dashboard/chat/memory, from the chat header's ⋯ › Memory)brands.brand_rules, Settings › Content) read-only, with a link to edit them there; they don't count toward the tab's 4,000 (Wave 3 decision 14). 00450 isn't on this branch's base: the rules are read from the whole brand row, so before 00450 is applied (or merged in) there are simply none, and after it they show with no change here.Settings › Chat
PATCH /api/chat/memory/settings(W3-11).Also
save_memoryandforget_memorynow point at the Memory page (their registry route and Undo's link).help/chat/memory.mdgets "The Memory page" and "Turn memory off", and its route is the page (approved: false).Related issue
None. Chat waves plan, Wave 3 (W3-12b). Stacked on #2016 (W3-12a, the Remember cards).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
With
CHAT_AGENTIC=true:Automated:
yarn vitest run src/components/chat/chat-memory.test.tsx src/lib/chat/memory src/components/chat src/components/chat-access src/lib/chat/registry src/lib/helpScreenshots
Screens: shown to the owner in a local preview and approved.
Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (9a11e75), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41489295224): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code