2025-09-17 09:30:24 +00:00
|
|
|
import { useTheme } from '@emotion/react';
|
|
|
|
|
import styled from '@emotion/styled';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
|
|
|
|
import { IconChevronDown, IconChevronUp } from 'twenty-ui/display';
|
2025-10-22 13:02:41 +00:00
|
|
|
import { JsonTree } from 'twenty-ui/json-visualizer';
|
2025-11-06 11:28:00 +00:00
|
|
|
import { AnimatedExpandableContainer } from 'twenty-ui/layout';
|
2025-09-17 09:30:24 +00:00
|
|
|
|
feat(ai): add code interpreter for AI data analysis (#16559)
## Summary
- Add code interpreter tool that enables AI to execute Python code for
data analysis, CSV processing, and chart generation
- Support for both local (development) and E2B (sandboxed production)
execution drivers
- Real-time streaming of stdout/stderr and generated files
- Frontend components for displaying code execution results with
expandable sections
## Code Quality Improvements
- Extract `getMimeType` to shared utility to reduce code duplication
between drivers
- Fix security issue: escape single quotes/backslashes in E2B driver env
variable injection
- Add `buildExecutionState` helper to reduce duplicated state object
construction
- Add `DEFAULT_CODE_INTERPRETER_TIMEOUT_MS` constant for consistency
- Fix lingui linting warning and TypeScript theme errors in frontend
## Test Plan
- [ ] Test code interpreter with local driver in development
- [ ] Test code interpreter with E2B driver in production environment
- [ ] Verify streaming output displays correctly in chat UI
- [ ] Verify generated files (charts, CSVs) are uploaded and
downloadable
- [ ] Test file upload flow (CSV, Excel) triggers code interpreter
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Updates generated i18n catalogs for Polish and pseudo-English, adding
strings for code execution/output (code interpreter) and various UI
messages, with minor text adjustments.
>
> - **Localization**:
> - **Generated catalogs**: Refresh `locales/generated/pl-PL.ts` and
`locales/generated/pseudo-en.ts`.
> - Add strings for code execution/output (e.g., code, copy code/output,
running/waiting states, download files, generated files, Python code
execution).
> - Include new UI texts (errors, prompts, menus) and minor text
corrections.
> - No changes to `pt-BR`; other files unchanged functionally.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
befc13d02c21e5a6647bc1aa6daa2a89f60b7ef8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-12-15 15:11:24 +00:00
|
|
|
import { CodeExecutionDisplay } from '@/ai/components/CodeExecutionDisplay';
|
2025-09-17 09:30:24 +00:00
|
|
|
import { ShimmeringText } from '@/ai/components/ShimmeringText';
|
2025-09-22 20:13:43 +00:00
|
|
|
import { getToolIcon } from '@/ai/utils/getToolIcon';
|
2026-02-09 13:26:02 +00:00
|
|
|
import {
|
|
|
|
|
getToolDisplayMessage,
|
|
|
|
|
resolveToolInput,
|
|
|
|
|
} from '@/ai/utils/getToolDisplayMessage';
|
2025-10-22 13:02:41 +00:00
|
|
|
import { useLingui } from '@lingui/react/macro';
|
2025-10-01 16:37:21 +00:00
|
|
|
import { type ToolUIPart } from 'ai';
|
2025-09-22 20:13:43 +00:00
|
|
|
import { isDefined } from 'twenty-shared/utils';
|
2025-10-22 13:02:41 +00:00
|
|
|
import { type JsonValue } from 'type-fest';
|
|
|
|
|
import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';
|
2025-09-17 09:30:24 +00:00
|
|
|
|
|
|
|
|
const StyledContainer = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledLoadingContainer = styled.div`
|
|
|
|
|
align-items: center;
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledContentContainer = styled.div`
|
|
|
|
|
background: ${({ theme }) => theme.background.transparent.lighter};
|
2025-11-07 12:31:05 +00:00
|
|
|
border: 1px solid ${({ theme }) => theme.border.color.light};
|
2025-09-17 09:30:24 +00:00
|
|
|
border-radius: ${({ theme }) => theme.border.radius.sm};
|
2025-11-07 12:31:05 +00:00
|
|
|
min-width: 0;
|
2025-09-17 09:30:24 +00:00
|
|
|
padding: ${({ theme }) => theme.spacing(3)};
|
2025-11-07 12:31:05 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledJsonTreeContainer = styled.div`
|
|
|
|
|
overflow-x: auto;
|
|
|
|
|
|
|
|
|
|
ul {
|
|
|
|
|
min-width: 0;
|
|
|
|
|
}
|
2025-09-17 09:30:24 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledToggleButton = styled.div<{ isExpandable: boolean }>`
|
|
|
|
|
align-items: center;
|
|
|
|
|
background: none;
|
|
|
|
|
border: none;
|
|
|
|
|
cursor: ${({ isExpandable }) => (isExpandable ? 'pointer' : 'auto')};
|
|
|
|
|
display: flex;
|
|
|
|
|
color: ${({ theme }) => theme.font.color.tertiary};
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
|
|
|
padding: ${({ theme }) => theme.spacing(1)} 0;
|
|
|
|
|
transition: color ${({ theme }) => theme.animation.duration.normal}s;
|
feat: simplify AI chat architecture and add record links (#16463)
## Summary
This PR significantly simplifies the AI chat architecture by removing
complex routing/planning mechanisms and introduces clickable record
links in AI responses.
## Changes
### AI Chat Architecture Simplification
- **Removed** the entire `ai-chat-router` module (~850 lines) including:
- Strategy decider service
- Plan generator service
- Complex routing logic
- **Removed** agent execution planning services (~700 lines):
- `agent-execution.service.ts`
- `agent-plan-executor.service.ts`
- `agent-tool-generator.service.ts`
- **Added** centralized `ToolRegistryService` for tool management:
- Builds searchable tool index (database, action, workflow tools)
- Provides tool lookup by name
- Supports agent search for loading expertise
- **Added** `ChatExecutionService` as simple replacement:
- Includes full tool catalog in system prompt
- Pre-loads common tools (find/create/update for company, person,
opportunity, task, note)
- Uses `load_tools` mechanism for dynamic tool activation
- Enables native web search by default
### Record References in AI Responses
- Added `recordReferences` field to tool outputs for create, find, and
update operations
- Implemented `[[record:objectName:recordId:displayName]]` syntax for AI
to reference records
- Created `RecordLink` component that renders clickable chips with
object icons
- Integrated record link parsing into the markdown renderer
- Users can now click directly on created/found records in AI responses
### Workflow Agent Fixes
- Fixed cache invalidation issue when creating agents in workflows
- Added default prompt for workflow-created agents to prevent validation
errors
- Relaxed agent validation to only check properties being updated (not
all required properties)
### Code Quality Improvements
- Extracted `getRecordDisplayName` utility that mirrors frontend's
`getLabelIdentifierFieldValue` logic
- Uses object metadata to determine the correct label identifier field
- Handles `FULL_NAME` composite type for person/workspaceMember objects
- Shared across create, find, and update record services
## Net Impact
- **~1,200 lines deleted** (complex routing/planning code)
- **~500 lines added** (simpler tool registry + record links)
- Significantly reduced code complexity
- Better tool discovery through full catalog in system prompt
- Improved UX with clickable record references
## Testing
- Typecheck passes
- Lint passes
- Manual testing of AI chat with record creation and linking
2025-12-10 14:14:12 +00:00
|
|
|
justify-content: space-between;
|
|
|
|
|
width: 100%;
|
2025-09-17 09:30:24 +00:00
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
color: ${({ theme }) => theme.font.color.secondary};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
feat: simplify AI chat architecture and add record links (#16463)
## Summary
This PR significantly simplifies the AI chat architecture by removing
complex routing/planning mechanisms and introduces clickable record
links in AI responses.
## Changes
### AI Chat Architecture Simplification
- **Removed** the entire `ai-chat-router` module (~850 lines) including:
- Strategy decider service
- Plan generator service
- Complex routing logic
- **Removed** agent execution planning services (~700 lines):
- `agent-execution.service.ts`
- `agent-plan-executor.service.ts`
- `agent-tool-generator.service.ts`
- **Added** centralized `ToolRegistryService` for tool management:
- Builds searchable tool index (database, action, workflow tools)
- Provides tool lookup by name
- Supports agent search for loading expertise
- **Added** `ChatExecutionService` as simple replacement:
- Includes full tool catalog in system prompt
- Pre-loads common tools (find/create/update for company, person,
opportunity, task, note)
- Uses `load_tools` mechanism for dynamic tool activation
- Enables native web search by default
### Record References in AI Responses
- Added `recordReferences` field to tool outputs for create, find, and
update operations
- Implemented `[[record:objectName:recordId:displayName]]` syntax for AI
to reference records
- Created `RecordLink` component that renders clickable chips with
object icons
- Integrated record link parsing into the markdown renderer
- Users can now click directly on created/found records in AI responses
### Workflow Agent Fixes
- Fixed cache invalidation issue when creating agents in workflows
- Added default prompt for workflow-created agents to prevent validation
errors
- Relaxed agent validation to only check properties being updated (not
all required properties)
### Code Quality Improvements
- Extracted `getRecordDisplayName` utility that mirrors frontend's
`getLabelIdentifierFieldValue` logic
- Uses object metadata to determine the correct label identifier field
- Handles `FULL_NAME` composite type for person/workspaceMember objects
- Shared across create, find, and update record services
## Net Impact
- **~1,200 lines deleted** (complex routing/planning code)
- **~500 lines added** (simpler tool registry + record links)
- Significantly reduced code complexity
- Better tool discovery through full catalog in system prompt
- Improved UX with clickable record references
## Testing
- Typecheck passes
- Lint passes
- Manual testing of AI chat with record creation and linking
2025-12-10 14:14:12 +00:00
|
|
|
const StyledToolName = styled.span`
|
|
|
|
|
background: ${({ theme }) => theme.background.transparent.light};
|
|
|
|
|
border-radius: ${({ theme }) => theme.border.radius.xs};
|
|
|
|
|
color: ${({ theme }) => theme.font.color.light};
|
|
|
|
|
font-family: ${({ theme }) => theme.font.family};
|
|
|
|
|
font-size: ${({ theme }) => theme.font.size.xs};
|
|
|
|
|
padding: ${({ theme }) => theme.spacing(0.5)}
|
|
|
|
|
${({ theme }) => theme.spacing(1)};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledLeftContent = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledRightContent = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
|
|
|
`;
|
|
|
|
|
|
2025-09-17 09:30:24 +00:00
|
|
|
const StyledDisplayMessage = styled.span`
|
|
|
|
|
color: ${({ theme }) => theme.font.color.tertiary};
|
|
|
|
|
font-size: ${({ theme }) => theme.font.size.md};
|
|
|
|
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledIconTextContainer = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
|
|
|
|
|
|
|
|
svg {
|
|
|
|
|
min-width: ${({ theme }) => theme.icon.size.sm}px;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2025-10-22 13:02:41 +00:00
|
|
|
const StyledTabContainer = styled.div`
|
|
|
|
|
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: ${({ theme }) => theme.spacing(3)};
|
|
|
|
|
margin-bottom: ${({ theme }) => theme.spacing(3)};
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledTab = styled.div<{ isActive: boolean }>`
|
|
|
|
|
color: ${({ theme, isActive }) =>
|
|
|
|
|
isActive ? theme.font.color.primary : theme.font.color.tertiary};
|
|
|
|
|
font-size: ${({ theme }) => theme.font.size.sm};
|
|
|
|
|
font-weight: ${({ theme, isActive }) =>
|
|
|
|
|
isActive ? theme.font.weight.medium : theme.font.weight.regular};
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: color ${({ theme }) => theme.animation.duration.normal}s;
|
|
|
|
|
padding-bottom: ${({ theme }) => theme.spacing(2)};
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
color: ${({ theme }) => theme.font.color.secondary};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
type TabType = 'output' | 'input';
|
|
|
|
|
|
2025-11-06 11:28:00 +00:00
|
|
|
export const ToolStepRenderer = ({ toolPart }: { toolPart: ToolUIPart }) => {
|
2025-10-22 13:02:41 +00:00
|
|
|
const { t } = useLingui();
|
2025-09-17 09:30:24 +00:00
|
|
|
const theme = useTheme();
|
2025-10-22 13:02:41 +00:00
|
|
|
const { copyToClipboard } = useCopyToClipboard();
|
2025-09-17 09:30:24 +00:00
|
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
2025-10-22 13:02:41 +00:00
|
|
|
const [activeTab, setActiveTab] = useState<TabType>('output');
|
2025-09-17 09:30:24 +00:00
|
|
|
|
2025-11-06 11:28:00 +00:00
|
|
|
const { input, output, type, errorText } = toolPart;
|
2026-02-09 13:26:02 +00:00
|
|
|
const rawToolName = type.split('-')[1];
|
2025-11-06 11:28:00 +00:00
|
|
|
|
2026-02-09 13:26:02 +00:00
|
|
|
const { resolvedInput: toolInput, resolvedToolName: toolName } =
|
|
|
|
|
resolveToolInput(input, rawToolName);
|
2025-11-11 10:08:26 +00:00
|
|
|
|
2025-11-06 11:28:00 +00:00
|
|
|
const hasError = isDefined(errorText);
|
|
|
|
|
const isExpandable = isDefined(output) || hasError;
|
2025-09-17 09:30:24 +00:00
|
|
|
|
feat(ai): add code interpreter for AI data analysis (#16559)
## Summary
- Add code interpreter tool that enables AI to execute Python code for
data analysis, CSV processing, and chart generation
- Support for both local (development) and E2B (sandboxed production)
execution drivers
- Real-time streaming of stdout/stderr and generated files
- Frontend components for displaying code execution results with
expandable sections
## Code Quality Improvements
- Extract `getMimeType` to shared utility to reduce code duplication
between drivers
- Fix security issue: escape single quotes/backslashes in E2B driver env
variable injection
- Add `buildExecutionState` helper to reduce duplicated state object
construction
- Add `DEFAULT_CODE_INTERPRETER_TIMEOUT_MS` constant for consistency
- Fix lingui linting warning and TypeScript theme errors in frontend
## Test Plan
- [ ] Test code interpreter with local driver in development
- [ ] Test code interpreter with E2B driver in production environment
- [ ] Verify streaming output displays correctly in chat UI
- [ ] Verify generated files (charts, CSVs) are uploaded and
downloadable
- [ ] Test file upload flow (CSV, Excel) triggers code interpreter
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Updates generated i18n catalogs for Polish and pseudo-English, adding
strings for code execution/output (code interpreter) and various UI
messages, with minor text adjustments.
>
> - **Localization**:
> - **Generated catalogs**: Refresh `locales/generated/pl-PL.ts` and
`locales/generated/pseudo-en.ts`.
> - Add strings for code execution/output (e.g., code, copy code/output,
running/waiting states, download files, generated files, Python code
execution).
> - Include new UI texts (errors, prompts, menus) and minor text
corrections.
> - No changes to `pt-BR`; other files unchanged functionally.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
befc13d02c21e5a6647bc1aa6daa2a89f60b7ef8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2025-12-15 15:11:24 +00:00
|
|
|
if (toolName === 'code_interpreter') {
|
|
|
|
|
const codeInput = toolInput as { code?: string } | undefined;
|
|
|
|
|
const codeOutput = output as {
|
|
|
|
|
result?: {
|
|
|
|
|
stdout?: string;
|
|
|
|
|
stderr?: string;
|
|
|
|
|
exitCode?: number;
|
|
|
|
|
files?: Array<{ filename: string; url: string; mimeType?: string }>;
|
|
|
|
|
};
|
|
|
|
|
} | null;
|
|
|
|
|
|
|
|
|
|
const isRunning = !output && !hasError;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<CodeExecutionDisplay
|
|
|
|
|
code={codeInput?.code ?? ''}
|
|
|
|
|
stdout={codeOutput?.result?.stdout ?? ''}
|
|
|
|
|
stderr={codeOutput?.result?.stderr || errorText || ''}
|
|
|
|
|
exitCode={codeOutput?.result?.exitCode}
|
|
|
|
|
files={codeOutput?.result?.files}
|
|
|
|
|
isRunning={isRunning}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 11:28:00 +00:00
|
|
|
if (!output && !hasError) {
|
2025-09-17 09:30:24 +00:00
|
|
|
return (
|
|
|
|
|
<StyledContainer>
|
feat: simplify AI chat architecture and add record links (#16463)
## Summary
This PR significantly simplifies the AI chat architecture by removing
complex routing/planning mechanisms and introduces clickable record
links in AI responses.
## Changes
### AI Chat Architecture Simplification
- **Removed** the entire `ai-chat-router` module (~850 lines) including:
- Strategy decider service
- Plan generator service
- Complex routing logic
- **Removed** agent execution planning services (~700 lines):
- `agent-execution.service.ts`
- `agent-plan-executor.service.ts`
- `agent-tool-generator.service.ts`
- **Added** centralized `ToolRegistryService` for tool management:
- Builds searchable tool index (database, action, workflow tools)
- Provides tool lookup by name
- Supports agent search for loading expertise
- **Added** `ChatExecutionService` as simple replacement:
- Includes full tool catalog in system prompt
- Pre-loads common tools (find/create/update for company, person,
opportunity, task, note)
- Uses `load_tools` mechanism for dynamic tool activation
- Enables native web search by default
### Record References in AI Responses
- Added `recordReferences` field to tool outputs for create, find, and
update operations
- Implemented `[[record:objectName:recordId:displayName]]` syntax for AI
to reference records
- Created `RecordLink` component that renders clickable chips with
object icons
- Integrated record link parsing into the markdown renderer
- Users can now click directly on created/found records in AI responses
### Workflow Agent Fixes
- Fixed cache invalidation issue when creating agents in workflows
- Added default prompt for workflow-created agents to prevent validation
errors
- Relaxed agent validation to only check properties being updated (not
all required properties)
### Code Quality Improvements
- Extracted `getRecordDisplayName` utility that mirrors frontend's
`getLabelIdentifierFieldValue` logic
- Uses object metadata to determine the correct label identifier field
- Handles `FULL_NAME` composite type for person/workspaceMember objects
- Shared across create, find, and update record services
## Net Impact
- **~1,200 lines deleted** (complex routing/planning code)
- **~500 lines added** (simpler tool registry + record links)
- Significantly reduced code complexity
- Better tool discovery through full catalog in system prompt
- Improved UX with clickable record references
## Testing
- Typecheck passes
- Lint passes
- Manual testing of AI chat with record creation and linking
2025-12-10 14:14:12 +00:00
|
|
|
<StyledToggleButton isExpandable={false}>
|
|
|
|
|
<StyledLeftContent>
|
|
|
|
|
<StyledLoadingContainer>
|
|
|
|
|
<ShimmeringText>
|
|
|
|
|
<StyledDisplayMessage>
|
2026-02-09 13:26:02 +00:00
|
|
|
{getToolDisplayMessage(input, rawToolName, false)}
|
feat: simplify AI chat architecture and add record links (#16463)
## Summary
This PR significantly simplifies the AI chat architecture by removing
complex routing/planning mechanisms and introduces clickable record
links in AI responses.
## Changes
### AI Chat Architecture Simplification
- **Removed** the entire `ai-chat-router` module (~850 lines) including:
- Strategy decider service
- Plan generator service
- Complex routing logic
- **Removed** agent execution planning services (~700 lines):
- `agent-execution.service.ts`
- `agent-plan-executor.service.ts`
- `agent-tool-generator.service.ts`
- **Added** centralized `ToolRegistryService` for tool management:
- Builds searchable tool index (database, action, workflow tools)
- Provides tool lookup by name
- Supports agent search for loading expertise
- **Added** `ChatExecutionService` as simple replacement:
- Includes full tool catalog in system prompt
- Pre-loads common tools (find/create/update for company, person,
opportunity, task, note)
- Uses `load_tools` mechanism for dynamic tool activation
- Enables native web search by default
### Record References in AI Responses
- Added `recordReferences` field to tool outputs for create, find, and
update operations
- Implemented `[[record:objectName:recordId:displayName]]` syntax for AI
to reference records
- Created `RecordLink` component that renders clickable chips with
object icons
- Integrated record link parsing into the markdown renderer
- Users can now click directly on created/found records in AI responses
### Workflow Agent Fixes
- Fixed cache invalidation issue when creating agents in workflows
- Added default prompt for workflow-created agents to prevent validation
errors
- Relaxed agent validation to only check properties being updated (not
all required properties)
### Code Quality Improvements
- Extracted `getRecordDisplayName` utility that mirrors frontend's
`getLabelIdentifierFieldValue` logic
- Uses object metadata to determine the correct label identifier field
- Handles `FULL_NAME` composite type for person/workspaceMember objects
- Shared across create, find, and update record services
## Net Impact
- **~1,200 lines deleted** (complex routing/planning code)
- **~500 lines added** (simpler tool registry + record links)
- Significantly reduced code complexity
- Better tool discovery through full catalog in system prompt
- Improved UX with clickable record references
## Testing
- Typecheck passes
- Lint passes
- Manual testing of AI chat with record creation and linking
2025-12-10 14:14:12 +00:00
|
|
|
</StyledDisplayMessage>
|
|
|
|
|
</ShimmeringText>
|
|
|
|
|
</StyledLoadingContainer>
|
|
|
|
|
</StyledLeftContent>
|
|
|
|
|
<StyledRightContent>
|
|
|
|
|
<StyledToolName>{toolName}</StyledToolName>
|
|
|
|
|
</StyledRightContent>
|
|
|
|
|
</StyledToggleButton>
|
2025-09-17 09:30:24 +00:00
|
|
|
</StyledContainer>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 13:26:02 +00:00
|
|
|
// For execute_tool, the actual result is nested inside output.result
|
|
|
|
|
const unwrappedOutput =
|
|
|
|
|
rawToolName === 'execute_tool' &&
|
|
|
|
|
isDefined(output) &&
|
|
|
|
|
typeof output === 'object' &&
|
|
|
|
|
'result' in output
|
|
|
|
|
? (output as { result: unknown }).result
|
|
|
|
|
: output;
|
|
|
|
|
|
2025-11-06 11:28:00 +00:00
|
|
|
const displayMessage = hasError
|
feat: add lingui/no-unlocalized-strings ESLint rule and fix translations (#16610)
## Summary
This PR adds the `lingui/no-unlocalized-strings` ESLint rule to detect
untranslated strings and fixes translation issues across multiple
components.
## Changes
### ESLint Configuration (`eslint.config.react.mjs`)
- Added comprehensive `ignore` patterns for non-translatable strings
(CSS values, HTML attributes, technical identifiers)
- Added `ignoreNames` for props that don't need translation (className,
data-*, aria-*, etc.)
- Added `ignoreFunctions` for console methods, URL APIs, and other
non-user-facing functions
- Disabled rule for debug files, storybook, and test files
### Components Fixed (~19 files)
- Object record components (field inputs, pickers, merge dialogs)
- Settings components (accounts, admin panel)
- Serverless function components
- Record table and title cell components
## Status
🚧 **Work in Progress** - ~124 files remaining to fix
This PR is being submitted as draft to allow progressive fixing of
remaining translation issues.
## Testing
- Run `npx eslint "src/**/*.tsx"` in `packages/twenty-front` to check
remaining issues
2025-12-17 21:08:33 +00:00
|
|
|
? t`Tool execution failed`
|
2026-02-09 13:26:02 +00:00
|
|
|
: rawToolName === 'learn_tools' || rawToolName === 'execute_tool'
|
|
|
|
|
? getToolDisplayMessage(input, rawToolName, true)
|
|
|
|
|
: unwrappedOutput &&
|
|
|
|
|
typeof unwrappedOutput === 'object' &&
|
|
|
|
|
'message' in unwrappedOutput &&
|
|
|
|
|
typeof unwrappedOutput.message === 'string'
|
|
|
|
|
? unwrappedOutput.message
|
|
|
|
|
: getToolDisplayMessage(input, rawToolName, true);
|
2025-09-17 09:30:24 +00:00
|
|
|
|
2025-09-29 11:31:55 +00:00
|
|
|
const result =
|
2026-02-09 13:26:02 +00:00
|
|
|
unwrappedOutput &&
|
|
|
|
|
typeof unwrappedOutput === 'object' &&
|
|
|
|
|
'result' in unwrappedOutput
|
|
|
|
|
? (unwrappedOutput as { result: string }).result
|
|
|
|
|
: unwrappedOutput;
|
2025-09-29 11:31:55 +00:00
|
|
|
|
|
|
|
|
const ToolIcon = getToolIcon(toolName);
|
2025-09-17 09:30:24 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<StyledContainer>
|
|
|
|
|
<StyledToggleButton
|
|
|
|
|
onClick={() => setIsExpanded(!isExpanded)}
|
|
|
|
|
isExpandable={isExpandable}
|
|
|
|
|
>
|
feat: simplify AI chat architecture and add record links (#16463)
## Summary
This PR significantly simplifies the AI chat architecture by removing
complex routing/planning mechanisms and introduces clickable record
links in AI responses.
## Changes
### AI Chat Architecture Simplification
- **Removed** the entire `ai-chat-router` module (~850 lines) including:
- Strategy decider service
- Plan generator service
- Complex routing logic
- **Removed** agent execution planning services (~700 lines):
- `agent-execution.service.ts`
- `agent-plan-executor.service.ts`
- `agent-tool-generator.service.ts`
- **Added** centralized `ToolRegistryService` for tool management:
- Builds searchable tool index (database, action, workflow tools)
- Provides tool lookup by name
- Supports agent search for loading expertise
- **Added** `ChatExecutionService` as simple replacement:
- Includes full tool catalog in system prompt
- Pre-loads common tools (find/create/update for company, person,
opportunity, task, note)
- Uses `load_tools` mechanism for dynamic tool activation
- Enables native web search by default
### Record References in AI Responses
- Added `recordReferences` field to tool outputs for create, find, and
update operations
- Implemented `[[record:objectName:recordId:displayName]]` syntax for AI
to reference records
- Created `RecordLink` component that renders clickable chips with
object icons
- Integrated record link parsing into the markdown renderer
- Users can now click directly on created/found records in AI responses
### Workflow Agent Fixes
- Fixed cache invalidation issue when creating agents in workflows
- Added default prompt for workflow-created agents to prevent validation
errors
- Relaxed agent validation to only check properties being updated (not
all required properties)
### Code Quality Improvements
- Extracted `getRecordDisplayName` utility that mirrors frontend's
`getLabelIdentifierFieldValue` logic
- Uses object metadata to determine the correct label identifier field
- Handles `FULL_NAME` composite type for person/workspaceMember objects
- Shared across create, find, and update record services
## Net Impact
- **~1,200 lines deleted** (complex routing/planning code)
- **~500 lines added** (simpler tool registry + record links)
- Significantly reduced code complexity
- Better tool discovery through full catalog in system prompt
- Improved UX with clickable record references
## Testing
- Typecheck passes
- Lint passes
- Manual testing of AI chat with record creation and linking
2025-12-10 14:14:12 +00:00
|
|
|
<StyledLeftContent>
|
|
|
|
|
<StyledIconTextContainer>
|
|
|
|
|
<ToolIcon size={theme.icon.size.sm} />
|
|
|
|
|
<StyledDisplayMessage>{displayMessage}</StyledDisplayMessage>
|
|
|
|
|
</StyledIconTextContainer>
|
|
|
|
|
</StyledLeftContent>
|
|
|
|
|
<StyledRightContent>
|
|
|
|
|
<StyledToolName>{toolName}</StyledToolName>
|
|
|
|
|
{isExpandable &&
|
|
|
|
|
(isExpanded ? (
|
|
|
|
|
<IconChevronUp size={theme.icon.size.sm} />
|
|
|
|
|
) : (
|
|
|
|
|
<IconChevronDown size={theme.icon.size.sm} />
|
|
|
|
|
))}
|
|
|
|
|
</StyledRightContent>
|
2025-09-17 09:30:24 +00:00
|
|
|
</StyledToggleButton>
|
|
|
|
|
|
|
|
|
|
{isExpandable && (
|
2025-11-07 12:31:05 +00:00
|
|
|
<AnimatedExpandableContainer isExpanded={isExpanded} mode="fit-content">
|
2025-09-17 09:30:24 +00:00
|
|
|
<StyledContentContainer>
|
2025-11-06 11:28:00 +00:00
|
|
|
{hasError ? (
|
2025-11-07 12:31:05 +00:00
|
|
|
errorText
|
2025-11-06 11:28:00 +00:00
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<StyledTabContainer>
|
|
|
|
|
<StyledTab
|
|
|
|
|
isActive={activeTab === 'output'}
|
|
|
|
|
onClick={() => setActiveTab('output')}
|
|
|
|
|
>
|
feat: add lingui/no-unlocalized-strings ESLint rule and fix translations (#16610)
## Summary
This PR adds the `lingui/no-unlocalized-strings` ESLint rule to detect
untranslated strings and fixes translation issues across multiple
components.
## Changes
### ESLint Configuration (`eslint.config.react.mjs`)
- Added comprehensive `ignore` patterns for non-translatable strings
(CSS values, HTML attributes, technical identifiers)
- Added `ignoreNames` for props that don't need translation (className,
data-*, aria-*, etc.)
- Added `ignoreFunctions` for console methods, URL APIs, and other
non-user-facing functions
- Disabled rule for debug files, storybook, and test files
### Components Fixed (~19 files)
- Object record components (field inputs, pickers, merge dialogs)
- Settings components (accounts, admin panel)
- Serverless function components
- Record table and title cell components
## Status
🚧 **Work in Progress** - ~124 files remaining to fix
This PR is being submitted as draft to allow progressive fixing of
remaining translation issues.
## Testing
- Run `npx eslint "src/**/*.tsx"` in `packages/twenty-front` to check
remaining issues
2025-12-17 21:08:33 +00:00
|
|
|
{t`Output`}
|
2025-11-06 11:28:00 +00:00
|
|
|
</StyledTab>
|
|
|
|
|
<StyledTab
|
|
|
|
|
isActive={activeTab === 'input'}
|
|
|
|
|
onClick={() => setActiveTab('input')}
|
|
|
|
|
>
|
feat: add lingui/no-unlocalized-strings ESLint rule and fix translations (#16610)
## Summary
This PR adds the `lingui/no-unlocalized-strings` ESLint rule to detect
untranslated strings and fixes translation issues across multiple
components.
## Changes
### ESLint Configuration (`eslint.config.react.mjs`)
- Added comprehensive `ignore` patterns for non-translatable strings
(CSS values, HTML attributes, technical identifiers)
- Added `ignoreNames` for props that don't need translation (className,
data-*, aria-*, etc.)
- Added `ignoreFunctions` for console methods, URL APIs, and other
non-user-facing functions
- Disabled rule for debug files, storybook, and test files
### Components Fixed (~19 files)
- Object record components (field inputs, pickers, merge dialogs)
- Settings components (accounts, admin panel)
- Serverless function components
- Record table and title cell components
## Status
🚧 **Work in Progress** - ~124 files remaining to fix
This PR is being submitted as draft to allow progressive fixing of
remaining translation issues.
## Testing
- Run `npx eslint "src/**/*.tsx"` in `packages/twenty-front` to check
remaining issues
2025-12-17 21:08:33 +00:00
|
|
|
{t`Input`}
|
2025-11-06 11:28:00 +00:00
|
|
|
</StyledTab>
|
|
|
|
|
</StyledTabContainer>
|
|
|
|
|
|
2025-11-07 12:31:05 +00:00
|
|
|
<StyledJsonTreeContainer>
|
2025-11-06 11:28:00 +00:00
|
|
|
<JsonTree
|
|
|
|
|
value={
|
2025-11-11 10:08:26 +00:00
|
|
|
(activeTab === 'output' ? result : toolInput) as JsonValue
|
2025-11-06 11:28:00 +00:00
|
|
|
}
|
2025-11-07 12:31:05 +00:00
|
|
|
shouldExpandNodeInitially={() => false}
|
2025-11-06 11:28:00 +00:00
|
|
|
emptyArrayLabel={t`Empty Array`}
|
|
|
|
|
emptyObjectLabel={t`Empty Object`}
|
|
|
|
|
emptyStringLabel={t`[empty string]`}
|
|
|
|
|
arrowButtonCollapsedLabel={t`Expand`}
|
|
|
|
|
arrowButtonExpandedLabel={t`Collapse`}
|
|
|
|
|
onNodeValueClick={copyToClipboard}
|
|
|
|
|
/>
|
2025-11-07 12:31:05 +00:00
|
|
|
</StyledJsonTreeContainer>
|
2025-11-06 11:28:00 +00:00
|
|
|
</>
|
|
|
|
|
)}
|
2025-09-17 09:30:24 +00:00
|
|
|
</StyledContentContainer>
|
|
|
|
|
</AnimatedExpandableContainer>
|
|
|
|
|
)}
|
|
|
|
|
</StyledContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|