This repository was archived by the owner on Aug 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
docs(agents): persist durable state to cloud, not localStorage #3253
Closed
raquelmsmith
wants to merge
1
commit into
main
from
posthog-code/persist-durable-state-to-cloud-guidance
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,19 @@ For each new file or meaningful change: | |
| - Domain fact read by business logic: core store. | ||
| - Pure view state: UI store. | ||
|
|
||
| ## Persisting State | ||
|
|
||
| PostHog Code has no local database. Durable, account-scoped state (settings, custom instructions, saved preferences) persists to PostHog cloud through `@posthog/api-client`, called from a `core` service. It is not `localStorage` and not host-local files. Cloud persistence is what makes state survive a reinstall and sync to the user's other machines. | ||
|
|
||
| `localStorage` and host-local files are for device-local, ephemeral view state only. If a user would be surprised to lose it after switching machines or reinstalling, it is account state and belongs in the cloud. | ||
|
|
||
| | State | Home | | ||
| | --- | --- | | ||
| | Account/durable (settings, custom instructions, preferences that should sync) | PostHog cloud via `@posthog/api-client`, from a `core` service | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| | Device-local ephemeral view state (panel sizes, last-open tab, dismissed hints) | UI store or host-local storage | | ||
|
|
||
| Do not default to `localStorage` because the repo has no database of its own. The database is PostHog cloud, reached through `api-client`. | ||
|
|
||
| ## Forbidden Patterns | ||
|
|
||
| - Business logic in store actions. | ||
|
|
@@ -113,6 +126,7 @@ For each new file or meaningful change: | |
| - Bespoke clients that wrap `trpcClient.x` one-to-one. | ||
| - `*Port`, `*_PORT`, or `ports.ts` naming. | ||
| - Business logic in `apps/<host>`. | ||
| - Persisting account-scoped or durable state to `localStorage` or host-local files instead of PostHog cloud via `@posthog/api-client`. | ||
|
|
||
| ## Host Boundary | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing
@posthog/api-clientpersistence methods are primarily scoped to the current project/team, but custom instructions and personal preferences are user-owned. An implementer following this rule can place one user's settings in a team resource, allowing another team member to read or overwrite them. The guidance should require an explicit user, project, or organization ownership scope and an ownership-validating endpoint.Rule Used: When implementing new features, ensure that owners... (source)
Learned From
PostHog/posthog#31236