Skip to content

feat(dashboard): add editable organization business context - #762

Merged
izadoesdev merged 2 commits into
stagingfrom
codex/business-context-settings
Sep 8, 2026
Merged

feat(dashboard): add editable organization business context#762
izadoesdev merged 2 commits into
stagingfrom
codex/business-context-settings

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 8, 2026

Copy link
Copy Markdown
Member

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.

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dashboard Ready Ready Preview Sep 8, 2026 4:51pm UTC
databuddy-status Ready Ready Preview Sep 8, 2026 4:51pm UTC
documentation Ready Ready Preview Sep 8, 2026 4:51pm UTC

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7e922410-6b1d-407a-bdb0-b1d1b780df0c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unkey-deploy

unkey-deploy Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 8, 2026 4:50pm

@blacksmith-sh

This comment has been minimized.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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.

  • Adds a reviewable business-brief editor with generation, save/discard, and conflict handling.
  • Persists revisioned profiles and generation state in organization metadata.
  • Generates drafts through the Insights worker and includes saved context in signal selection and investigation.
  • Introduces metadata-protection hooks and integration/regression coverage.
  • Two blocking regressions remain: organization creation rejects the dashboard’s existing payload, and a website-scope race allows invalidated investigation work to consume context.

Confidence Score: 3/5

The 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

Filename Overview
packages/auth/src/auth.ts Adds metadata-protection hooks, but the create hook rejects the payload used by the existing organization-creation dialog.
apps/insights/src/business-context.ts Adds canonical organization profiles to website context after the final website-scope validation, creating a transfer/edit race.
apps/insights/src/organization-business-context.ts Implements bounded website inspection, model generation, billing, provenance checks, and draft publication; it also contains explicit-type rule violations.
packages/services/src/organization-business-context.ts Implements transactionally locked profile revisions and generation lifecycle state with source-website validation.
packages/rpc/src/routers/business-context.ts Adds authorized read, save, and rate-limited generation procedures with audit scoping.
apps/dashboard/app/(main)/organizations/components/business-context-editor.tsx Adds the editable brief, generation review, unsaved-text preservation, and revision-conflict workflow.
packages/shared/src/organization-business-context.ts Defines the shared profile, generation, settings, and length-limit contracts.

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]
Loading

Reviews (1): Last reviewed commit: "feat(dashboard): add editable organizati..." | Re-trigger Greptile

Comment thread apps/insights/src/business-context.ts
Comment thread packages/auth/src/auth.ts
Comment thread apps/insights/src/organization-business-context.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant