-
-
Notifications
You must be signed in to change notification settings - Fork 100
feat: create dashboard databases #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RambokDev
wants to merge
19
commits into
dev
Choose a base branch
from
feat/create-databases
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ca0dfa5
feat(db): add config jsonb column to databases
f1de8d0
fix(db): type config jsonb column to align row/zod types
dbee3c9
feat(database): zod config schema + field defs for all dbms types
28c24a3
feat(database): data-driven config field renderer
732c30b
feat(database): upsert config server action + agent-scope acl
3f73e66
feat(database): config modal with form/json tabs and two-way sync
f77c065
feat(agents): add/configure database triggers on agent detail page
9768140
feat(status): send db config to agent (encrypted, version-gated) + in…
e0e93a5
feat(database): modal UX polish
351a83c
feat(database): JSON tab uses agent config shape; name/type inside tabs
14cd8c3
fix(database): reset fields on type change; full-width type dropdown
8ddc5e7
fix(database): full-width clean_mode dropdown in config fields
a5fcb82
fix(database): remount config fields on type change so port clears
3138359
fix(database): reliable two-way form<->JSON sync
1442ebf
feat(database): optional selects are clearable (unset removes the key)
cd62e95
fix: removed comments
e99a2b1
feat(status): send full agent-entry config to agent; withhold on delete
c000665
fix
1ebe7a9
fix
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
140 changes: 72 additions & 68 deletions
140
app/(customer)/dashboard/(admin)/agents/[agentId]/page.tsx
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 |
|---|---|---|
| @@ -1,88 +1,92 @@ | ||
| import { PageParams } from "@/types/next"; | ||
| import {PageParams} from "@/types/next"; | ||
| import { | ||
| Page, | ||
| PageContent, | ||
| PageDescription, | ||
| PageTitle, | ||
| Page, | ||
| PageContent, | ||
| PageDescription, | ||
| PageTitle, | ||
| } from "@/features/layout/components/page"; | ||
| import { db } from "@/db"; | ||
| import {db} from "@/db"; | ||
| import * as drizzleDb from "@/db"; | ||
| import {eq, isNull} from "drizzle-orm"; | ||
| import { notFound } from "next/navigation"; | ||
| import { ButtonDeleteAgent } from "@/features/agents/components/agent-delete-button"; | ||
| import { capitalizeFirstLetter } from "@/utils/text"; | ||
| import { generateEdgeKey } from "@/utils/edge_key"; | ||
| import { getServerUrl } from "@/utils/get-server-url"; | ||
| import { AgentContentPage } from "@/features/agents/components/agent-content"; | ||
| import { AgentDialog } from "@/features/agents/components/agent-dialog"; | ||
| import {notFound} from "next/navigation"; | ||
| import {ButtonDeleteAgent} from "@/features/agents/components/agent-delete-button"; | ||
| import {capitalizeFirstLetter} from "@/utils/text"; | ||
| import {generateEdgeKey} from "@/utils/edge_key"; | ||
| import {getServerUrl} from "@/utils/get-server-url"; | ||
| import {AgentContentPage} from "@/features/agents/components/agent-content"; | ||
| import {AgentDialog} from "@/features/agents/components/agent-dialog"; | ||
| import {maskDatabasesSecretsForClient} from "@/features/database/utils/credential-fields"; | ||
|
|
||
|
|
||
| export default async function RoutePage( | ||
| props: PageParams<{ agentId: string }>, | ||
| props: PageParams<{ agentId: string }>, | ||
| ) { | ||
| const { agentId } = await props.params; | ||
| const {agentId} = await props.params; | ||
|
|
||
| const agent = await db.query.agent.findFirst({ | ||
| where: eq(drizzleDb.schemas.agent.id, agentId), | ||
| with: { | ||
| databases: true, | ||
| organizations: true, | ||
| }, | ||
| }); | ||
| const agent = await db.query.agent.findFirst({ | ||
| where: eq(drizzleDb.schemas.agent.id, agentId), | ||
| with: { | ||
| databases: true, | ||
| organizations: true, | ||
| }, | ||
| }); | ||
|
|
||
| const organizations = await db.query.organization.findMany({ | ||
| where: (fields) => isNull(fields.deletedAt), | ||
| with: { | ||
| members: true, | ||
| }, | ||
| }); | ||
| const organizations = await db.query.organization.findMany({ | ||
| where: (fields) => isNull(fields.deletedAt), | ||
| with: { | ||
| members: true, | ||
| }, | ||
| }); | ||
|
|
||
|
|
||
| if (!agent) { | ||
| notFound(); | ||
| } | ||
| if (!agent) { | ||
| notFound(); | ||
| } | ||
|
|
||
| const isOwnerByAnOrganization = agent.organizationId | ||
| agent.databases = maskDatabasesSecretsForClient(agent.databases); | ||
|
|
||
| if (isOwnerByAnOrganization){ | ||
| notFound(); | ||
| } | ||
| const isOwnerByAnOrganization = agent.organizationId | ||
|
|
||
| const organizationIds = agent.organizations.map(org => org.organizationId) | ||
| if (isOwnerByAnOrganization) { | ||
| notFound(); | ||
| } | ||
|
|
||
| const edgeKey = await generateEdgeKey(agent.overrideUrl ?? getServerUrl(), agent.id); | ||
| const organizationIds = agent.organizations.map(org => org.organizationId) | ||
|
|
||
| return ( | ||
| <Page> | ||
| <div className="justify-between gap-2 sm:flex"> | ||
| <PageTitle className="flex flex-col md:flex-row items-center justify-between w-full "> | ||
| <div className="min-w-full md:min-w-fit "> | ||
| {capitalizeFirstLetter(agent.name)} | ||
| </div> | ||
| <div className="flex items-center gap-2 md:justify-between w-full "> | ||
| <div className="flex items-center gap-2"> | ||
| <AgentDialog | ||
| agent={agent} | ||
| typeTrigger={"edit"} | ||
| adminView={true} | ||
| organizations={organizations} | ||
| /> | ||
| </div> | ||
| <div className="flex items-center gap-2"> | ||
| <ButtonDeleteAgent organizationIds={organizationIds} agentId={agentId} text={"Delete Agent"} /> | ||
| const edgeKey = await generateEdgeKey(agent.overrideUrl ?? getServerUrl(), agent.id); | ||
|
|
||
| return ( | ||
| <Page> | ||
| <div className="justify-between gap-2 sm:flex"> | ||
| <PageTitle className="flex flex-col md:flex-row items-center justify-between w-full "> | ||
| <div className="min-w-full md:min-w-fit "> | ||
| {capitalizeFirstLetter(agent.name)} | ||
| </div> | ||
| <div className="flex items-center gap-2 md:justify-between w-full "> | ||
| <div className="flex items-center gap-2"> | ||
| <AgentDialog | ||
| agent={agent} | ||
| typeTrigger={"edit"} | ||
| adminView={true} | ||
| organizations={organizations} | ||
| /> | ||
| </div> | ||
| <div className="flex items-center gap-2"> | ||
| <ButtonDeleteAgent organizationIds={organizationIds} agentId={agentId} | ||
| text={"Delete Agent"}/> | ||
| </div> | ||
| </div> | ||
| </PageTitle> | ||
| </div> | ||
| </div> | ||
| </PageTitle> | ||
| </div> | ||
|
|
||
| {agent.description && ( | ||
| <PageDescription className="mt-5 sm:mt-0"> | ||
| {agent.description} | ||
| </PageDescription> | ||
| )} | ||
| <PageContent className="flex flex-col w-full h-full justify-between gap-6"> | ||
| <AgentContentPage agent={agent} edgeKey={edgeKey} canDeleteDatabases={true} /> | ||
| </PageContent> | ||
| </Page> | ||
| ); | ||
| {agent.description && ( | ||
| <PageDescription className="mt-5 sm:mt-0"> | ||
| {agent.description} | ||
| </PageDescription> | ||
| )} | ||
| <PageContent className="flex flex-col w-full h-full justify-between gap-6"> | ||
| <AgentContentPage agent={agent} edgeKey={edgeKey} canDeleteDatabases={true}/> | ||
| </PageContent> | ||
| </Page> | ||
| ); | ||
| } |
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
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE "databases" ADD COLUMN "config" jsonb; | ||
Oops, something went wrong.
Oops, something went wrong.
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.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Enforce the
agent_database_ididentity invariant before configuration sync.src/db/schema/07_database.ts, Lines 14-35 definesagentDatabaseIdas nullable. The new action accepts caller-selected IDs atsrc/features/database/actions/database-config.action.ts, Lines 19-22, and stores them at Lines 74-82. The status handler resolves records by this ID alone atsrc/features/agents/utils/status/status.helpers.ts, Lines 62-67.A configured legacy record with
agent_database_id = NULLis now appended to the agent response withgeneratedId: null. Duplicate IDs can also make the status handler select and update an unrelated record.Backfill missing IDs, make
agent_database_idNOT NULL, and add a unique constraint before enabling configuration synchronization. Handle unique-constraint conflicts inupsertDatabaseConfigAction.🤖 Prompt for AI Agents