feat(dashboard): add editable organization business context - #762
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Unkey Deploy
|
This comment has been minimized.
This comment has been minimized.
Greptile SummaryThis PR adds editable organization business context across the dashboard, RPC layer, PostgreSQL-backed organization metadata, AI generation queue, and Insights consumers. It also prevents general Better Auth organization routes from modifying metadata.
Confidence Score: 3/5The PR is not safe to merge until organization creation remains compatible with the dashboard and organization context is loaded only while the website scope is still current; the explicit-type repository requirement must also be satisfied. The metadata hook concretely rejects the standard organization-creation payload, while the Insights loader can continue into selection and agent execution when a website changes scope after its last validation. The generation lifecycle and stale-write handling otherwise have appropriate transactional and revision guards. Files Needing Attention: apps/insights/src/business-context.ts, packages/auth/src/auth.ts, apps/insights/src/organization-business-context.ts Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Admin[Organization admin] --> Editor[Business Context editor]
Editor --> RPC[Business Context RPC]
RPC --> Metadata[(Organization metadata)]
RPC --> Queue[Insights queue]
Queue --> Generator[AI context generator]
Generator --> Website[Authorized website pages]
Generator --> Metadata
Metadata --> Loader[Business context loader]
Loader --> Selection[Investigation selection]
Selection --> Investigator[Insights investigator]
Reviews (1): Last reviewed commit: "feat(dashboard): add editable organizati..." | Re-trigger Greptile |
Organizations can now inspect and correct the business context used by Insights instead of relying on an invisible website summary. Organization Settings has one editable brief, Generate with AI / Regenerate with AI, and Save/Discard when needed. Generation produces a reviewable draft and preserves unsaved typing.
The new oRPC businessContext.get/save/generate procedures use organization permissions, revision checks, and the existing Insights queue. The canonical profile is durable PostgreSQL organization metadata; Better Auth's general create/update routes now reject client metadata so they cannot bypass that contract. The dashboard create/update callers omit protected metadata; ordinary organization creation and name, slug, and logo edits continue to work. No new database table or migration is required.
Saved profiles, their public/team provenance, and inspected source references reach investigation selection and the investigator. Newer team corrections take priority over public pages, invalid website scopes stop private-context loading, and source locks prevent stale generation results being accepted during website transfers or edits. Regeneration retains existing team provenance and exact custom URLs. Keeping an older AI draft preserves its exact generation ID and sources through a bounded five-draft history; successful saves clear that history. Scope is rechecked after organization-profile retrieval before private context reaches the agent. It uses at most two model calls and six additional page reads.
Validation: root lint and all 33 type-check tasks; 558 Insights tests and the RPC suite; eight authenticated browser checks (including both organization-isolation flows and six business-context regressions) including real API persistence, typing during generation, discard/refetch, conflict review, and member access; 19 isolated PostgreSQL concurrency/provenance tests and native Better Auth metadata-protection tests. The new persistence/auth regressions run in CI. Desktop light/dark and 390px mobile layouts were inspected.
Fresh synthetic context on/off evaluations show explicit event meanings and priorities can change useful findings and selection; general marketing background adds little measured depth. Native Databuddy generation was audited before/after: seven page reads became four, the fresh brief shortened from 440 to 390 words, and exact custom URL preservation improved from 0/3 to 3/3 with all eight supplied team constraints retained. This small sample is not a general quality or speed claim; reads were partly cached and metric-unit wording remains an identified investigation limitation.
Scope: organization context settings, API, persistence, generation, and consumption. No dependency on draft #751; that draft's richer website-profile storage overlaps the consumer conceptually but remains separate and is not required here. Existing Supermemory website/reply behavior is unchanged; this adds no organization mirror or provider deletion. AI-assisted implementation and independent agent review.