-
Notifications
You must be signed in to change notification settings - Fork 53.3k
feat(core, editor): Better distinguish personal and workflow agents in chat (no-changelog) #23032
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7fff6db
feat: add icon to personal and workflow agent
autologie 5187b59
revert workflow agent grouping for now
autologie ba8bbba
change icon for personal agents
autologie c90295b
adjust icon size
autologie 645a43f
fix: use agent icon in model selector
autologie dbb905e
format
autologie f4c1cd6
design feedback
autologie 3b41d2d
add skeleton
autologie 844e627
refactor
autologie 3e47533
fix: cache icon
autologie b0a1411
fix: make icon nullable
autologie 6dc84bd
remove projectName for now
autologie 86372ae
fix import order
autologie cfe2dc9
revert some changes
autologie 84a1650
fix test
autologie 752a1fa
refactor
autologie a4d7d1b
revert some changes
autologie bff4a3e
add tests
autologie 5f321be
AI review
autologie a061d6b
refactor: remove agentIcon column from session table
autologie 198defb
Merge branch 'master' into chat-split-custom-agents
autologie 50614ef
fix: show icon even if agent is no longer available
autologie 6fdb3b0
change agentId type to UUID and add FK constraint
autologie b6b09a1
Merge branch 'master' into chat-split-custom-agents
autologie c888ab8
fix error in conflict resolution
autologie 8327d14
Merge branch 'master' into chat-split-custom-agents
Cadiac 9e4a2c0
add FK constraint on agentId column in chat messages table
autologie 181907c
add explicit name to FKs
autologie 1840e1d
update migration timestamp
autologie 7449aff
feat: add tooltip in model selector
autologie ab79ad0
exclude FKs from migration
autologie bd4daeb
refactor
autologie f40df38
Merge branch 'master' into chat-split-custom-agents
autologie 41cced4
Merge branch 'master' into chat-split-custom-agents
Cadiac c6e0246
fix: add back migration for updating column type
autologie 752c6f2
Merge branch 'master' into chat-split-custom-agents
autologie 328d3c1
lint
autologie 2f6ce74
fix type
autologie 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
change agentId type to UUID and add FK constraint
- Loading branch information
commit 6fdb3b0b98ad455f9480b1298147feb303dc9717
There are no files selected for viewing
42 changes: 23 additions & 19 deletions
42
packages/@n8n/db/src/migrations/common/1765361177092-AddIconToAgentTable.ts
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,49 +1,53 @@ | ||
| import type { MigrationContext, ReversibleMigration } from '../migration-types'; | ||
|
|
||
| const tableName = 'chat_hub_agents'; | ||
| const table = { | ||
| agents: 'chat_hub_agents', | ||
| sessions: 'chat_hub_sessions', | ||
| } as const; | ||
|
|
||
| export class AddIconToAgentTable1765361177092 implements ReversibleMigration { | ||
| async up({ | ||
| schemaBuilder: { addColumns, column }, | ||
| schemaBuilder: { addColumns, column, addForeignKey }, | ||
| runQuery, | ||
| isMysql, | ||
| isPostgres, | ||
| escape, | ||
| }: MigrationContext) { | ||
| const escapedTableName = escape.tableName(tableName); | ||
| const escapedIdColumn = escape.columnName('id'); | ||
|
|
||
| // Add icon column to agents table (nullable) | ||
| await addColumns(tableName, [column('icon').json]); | ||
| await addColumns(table.agents, [column('icon').json]); | ||
|
|
||
| // Change agents.id from UUID to varchar to match foreign key references | ||
| // For PostgreSQL: convert agentId from varchar(36) to uuid to match agents.id type | ||
| if (isPostgres) { | ||
| await runQuery( | ||
| `ALTER TABLE ${escapedTableName} ALTER COLUMN ${escapedIdColumn} TYPE VARCHAR`, | ||
| `ALTER TABLE ${escape.tableName(table.sessions)} ALTER COLUMN "agentId" TYPE uuid USING "agentId"::uuid`, | ||
| ); | ||
| } else if (isMysql) { | ||
| await runQuery(`ALTER TABLE ${escapedTableName} MODIFY COLUMN \`id\` VARCHAR(255)`); | ||
| } | ||
|
|
||
| // Clean up orphaned agentId references before adding foreign key constraint | ||
| await runQuery( | ||
| `UPDATE ${escape.tableName(table.sessions)} SET "agentId" = NULL WHERE "agentId" IS NOT NULL AND "agentId" NOT IN (SELECT id FROM ${escape.tableName(table.agents)})`, | ||
| ); | ||
|
|
||
| // Add foreign key constraint for agentId in sessions table | ||
| await addForeignKey(table.sessions, 'agentId', [table.agents, 'id'], undefined, 'SET NULL'); | ||
| } | ||
|
|
||
| async down({ | ||
| schemaBuilder: { dropColumns }, | ||
| schemaBuilder: { dropColumns, dropForeignKey }, | ||
| runQuery, | ||
| isMysql, | ||
| isPostgres, | ||
| escape, | ||
| }: MigrationContext) { | ||
| const escapedTableName = escape.tableName(tableName); | ||
| const escapedIdColumn = escape.columnName('id'); | ||
| // Drop foreign key constraint | ||
| await dropForeignKey(table.sessions, 'agentId', [table.agents, 'id']); | ||
Cadiac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // For PostgreSQL: revert agentId from uuid back to varchar(36) | ||
| if (isPostgres) { | ||
| await runQuery( | ||
| `ALTER TABLE ${escapedTableName} ALTER COLUMN ${escapedIdColumn} TYPE UUID USING ${escapedIdColumn}::UUID`, | ||
| `ALTER TABLE ${escape.tableName(table.sessions)} ALTER COLUMN "agentId" TYPE varchar(36)`, | ||
| ); | ||
| } else if (isMysql) { | ||
| await runQuery(`ALTER TABLE ${escapedTableName} MODIFY COLUMN \`id\` CHAR(36)`); | ||
| } | ||
|
|
||
| await dropColumns(tableName, ['icon']); | ||
| // Drop icon column | ||
| await dropColumns(table.agents, ['icon']); | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.