mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
feat: 优化工具名称和描述的样式,增强可读性;添加 TopicType 支持到导出测试
This commit is contained in:
parent
4a671a9bc2
commit
da18ff3d48
@ -440,9 +440,9 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
|
|||||||
{(tool) => (
|
{(tool) => (
|
||||||
<SelectItem key={tool.id} textValue={tool.name}>
|
<SelectItem key={tool.id} textValue={tool.name}>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<span className="text-sm font-medium">{tool.name}</span>
|
<span className="font-medium text-sm">{tool.name}</span>
|
||||||
{tool.description ? (
|
{tool.description ? (
|
||||||
<span className="text-xs text-foreground-500">{tool.description}</span>
|
<span className="text-foreground-500 text-xs">{tool.description}</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|||||||
@ -376,9 +376,9 @@ export const SessionModal: React.FC<Props> = ({
|
|||||||
{(tool) => (
|
{(tool) => (
|
||||||
<SelectItem key={tool.id} textValue={tool.name}>
|
<SelectItem key={tool.id} textValue={tool.name}>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<span className="text-sm font-medium">{tool.name}</span>
|
<span className="font-medium text-sm">{tool.name}</span>
|
||||||
{tool.description ? (
|
{tool.description ? (
|
||||||
<span className="text-xs text-foreground-500">{tool.description}</span>
|
<span className="text-foreground-500 text-xs">{tool.description}</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
import { loggerService } from '@logger'
|
||||||
|
|
||||||
|
const logger = loggerService.withContext('Feature Flag')
|
||||||
/**
|
/**
|
||||||
* Feature flags for controlling gradual rollout of new features
|
* Feature flags for controlling gradual rollout of new features
|
||||||
* These flags can be toggled to enable/disable features without code changes
|
* These flags can be toggled to enable/disable features without code changes
|
||||||
@ -33,7 +36,6 @@ export function initializeFeatureFlags(): void {
|
|||||||
// Usage: VITE_USE_UNIFIED_DB_SERVICE=true yarn dev
|
// Usage: VITE_USE_UNIFIED_DB_SERVICE=true yarn dev
|
||||||
if (import.meta.env?.VITE_USE_UNIFIED_DB_SERVICE === 'true') {
|
if (import.meta.env?.VITE_USE_UNIFIED_DB_SERVICE === 'true') {
|
||||||
featureFlags.USE_UNIFIED_DB_SERVICE = true
|
featureFlags.USE_UNIFIED_DB_SERVICE = true
|
||||||
console.log('[FeatureFlags] USE_UNIFIED_DB_SERVICE enabled via environment variable')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then check localStorage for runtime overrides (higher priority)
|
// Then check localStorage for runtime overrides (higher priority)
|
||||||
@ -45,15 +47,12 @@ export function initializeFeatureFlags(): void {
|
|||||||
Object.keys(overrides).forEach((key) => {
|
Object.keys(overrides).forEach((key) => {
|
||||||
if (key in featureFlags) {
|
if (key in featureFlags) {
|
||||||
featureFlags[key as keyof FeatureFlags] = overrides[key]
|
featureFlags[key as keyof FeatureFlags] = overrides[key]
|
||||||
console.log(`[FeatureFlags] ${key} set to ${overrides[key]} via localStorage`)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[FeatureFlags] Failed to parse feature flags from localStorage:', e)
|
logger.warn('Failed to parse feature flags from localStorage:', e as Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[FeatureFlags] Current flags:', featureFlags)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { AccordionItem } from '@heroui/react'
|
import { AccordionItem } from '@heroui/react'
|
||||||
import { Bot } from 'lucide-react'
|
import { Bot } from 'lucide-react'
|
||||||
|
|
||||||
import { ToolTitle } from './GenericTools'
|
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
|
|
||||||
|
import { ToolTitle } from './GenericTools'
|
||||||
import type { TaskToolInput as TaskToolInputType, TaskToolOutput as TaskToolOutputType } from './types'
|
import type { TaskToolInput as TaskToolInputType, TaskToolOutput as TaskToolOutputType } from './types'
|
||||||
|
|
||||||
export function TaskTool({ input, output }: { input: TaskToolInputType; output?: TaskToolOutputType }) {
|
export function TaskTool({ input, output }: { input: TaskToolInputType; output?: TaskToolOutputType }) {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { AccordionItem, Chip, Card, CardBody } from '@heroui/react'
|
import { AccordionItem, Card, CardBody, Chip } from '@heroui/react'
|
||||||
import { ListTodo, CheckCircle, Clock, Circle } from 'lucide-react'
|
import { CheckCircle, Circle, Clock, ListTodo } from 'lucide-react'
|
||||||
|
|
||||||
import { ToolTitle } from './GenericTools'
|
import { ToolTitle } from './GenericTools'
|
||||||
import type {
|
import type {
|
||||||
|
TodoItem,
|
||||||
TodoWriteToolInput as TodoWriteToolInputType,
|
TodoWriteToolInput as TodoWriteToolInputType,
|
||||||
TodoWriteToolOutput as TodoWriteToolOutputType,
|
TodoWriteToolOutput as TodoWriteToolOutputType
|
||||||
TodoItem
|
|
||||||
} from './types'
|
} from './types'
|
||||||
import { AgentToolsType } from './types'
|
import { AgentToolsType } from './types'
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ import { SearchTool } from './SearchTool'
|
|||||||
import { TaskTool } from './TaskTool'
|
import { TaskTool } from './TaskTool'
|
||||||
import { TodoWriteTool } from './TodoWriteTool'
|
import { TodoWriteTool } from './TodoWriteTool'
|
||||||
import { AgentToolsType, ToolInput, ToolOutput } from './types'
|
import { AgentToolsType, ToolInput, ToolOutput } from './types'
|
||||||
|
import { WebFetchTool } from './WebFetchTool'
|
||||||
import { WebSearchTool } from './WebSearchTool'
|
import { WebSearchTool } from './WebSearchTool'
|
||||||
import { WriteTool } from './WriteTool'
|
import { WriteTool } from './WriteTool'
|
||||||
import { WebFetchTool } from './WebFetchTool'
|
|
||||||
|
|
||||||
const logger = loggerService.withContext('MessageAgentTools')
|
const logger = loggerService.withContext('MessageAgentTools')
|
||||||
|
|
||||||
|
|||||||
@ -215,8 +215,8 @@ const AgentEssentialSettings: FC<AgentEssentialSettingsProps> = ({ agent, update
|
|||||||
{(tool) => (
|
{(tool) => (
|
||||||
<SelectItem key={tool.id} textValue={tool.name}>
|
<SelectItem key={tool.id} textValue={tool.name}>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<span className="text-sm font-medium">{tool.name}</span>
|
<span className="font-medium text-sm">{tool.name}</span>
|
||||||
{tool.description ? <span className="text-xs text-foreground-500">{tool.description}</span> : null}
|
{tool.description ? <span className="text-foreground-500 text-xs">{tool.description}</span> : null}
|
||||||
</div>
|
</div>
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -5,14 +5,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Export main service
|
// Export main service
|
||||||
export { DbService,dbService } from './DbService'
|
export { DbService, dbService } from './DbService'
|
||||||
|
|
||||||
// Export types
|
// Export types
|
||||||
export type { MessageDataSource, MessageExchange } from './types'
|
export type { MessageDataSource, MessageExchange } from './types'
|
||||||
export {
|
export {
|
||||||
buildAgentSessionTopicId,
|
buildAgentSessionTopicId,
|
||||||
extractSessionId,
|
extractSessionId,
|
||||||
isAgentSessionTopicId} from './types'
|
isAgentSessionTopicId
|
||||||
|
} from './types'
|
||||||
|
|
||||||
// Export implementations (for testing or direct access if needed)
|
// Export implementations (for testing or direct access if needed)
|
||||||
export { AgentMessageDataSource } from './AgentMessageDataSource'
|
export { AgentMessageDataSource } from './AgentMessageDataSource'
|
||||||
|
|||||||
@ -205,7 +205,7 @@ export enum TopicType {
|
|||||||
|
|
||||||
export type Topic = {
|
export type Topic = {
|
||||||
id: string
|
id: string
|
||||||
type: TopicType
|
type?: TopicType
|
||||||
assistantId: string
|
assistantId: string
|
||||||
name: string
|
name: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
|||||||
@ -75,7 +75,7 @@ vi.mock('@renderer/utils/markdown', async (importOriginal) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Import the functions to test AFTER setting up mocks
|
// Import the functions to test AFTER setting up mocks
|
||||||
import { Topic } from '@renderer/types'
|
import { Topic, TopicType } from '@renderer/types'
|
||||||
import { markdownToPlainText } from '@renderer/utils/markdown'
|
import { markdownToPlainText } from '@renderer/utils/markdown'
|
||||||
|
|
||||||
import { copyMessageAsPlainText } from '../copy'
|
import { copyMessageAsPlainText } from '../copy'
|
||||||
@ -452,7 +452,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test_formatted',
|
assistantId: 'asst_test_formatted',
|
||||||
messages: [userMsg, assistantMsg] as any,
|
messages: [userMsg, assistantMsg] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -552,7 +553,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test_multi_formatted',
|
assistantId: 'asst_test_multi_formatted',
|
||||||
messages: [msg1, msg2] as any,
|
messages: [msg1, msg2] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -587,7 +589,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test',
|
assistantId: 'asst_test',
|
||||||
messages: [msgWithEmpty] as any,
|
messages: [msgWithEmpty] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -608,7 +611,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test',
|
assistantId: 'asst_test',
|
||||||
messages: [msgWithSpecial] as any,
|
messages: [msgWithSpecial] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -634,7 +638,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test',
|
assistantId: 'asst_test',
|
||||||
messages: [msg1, msg2] as any,
|
messages: [msg1, msg2] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -655,7 +660,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test',
|
assistantId: 'asst_test',
|
||||||
messages: [] as any,
|
messages: [] as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return empty array
|
// Mock TopicManager.getTopicMessages to return empty array
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
@ -674,7 +680,8 @@ describe('export', () => {
|
|||||||
assistantId: 'asst_test',
|
assistantId: 'asst_test',
|
||||||
messages: null as any,
|
messages: null as any,
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: ''
|
updatedAt: '',
|
||||||
|
type: TopicType.Chat
|
||||||
}
|
}
|
||||||
// Mock TopicManager.getTopicMessages to return empty array for null case
|
// Mock TopicManager.getTopicMessages to return empty array for null case
|
||||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user