mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-01 01:30:51 +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) => (
|
||||
<SelectItem key={tool.id} textValue={tool.name}>
|
||||
<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>
|
||||
<span className="text-foreground-500 text-xs">{tool.description}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</SelectItem>
|
||||
|
||||
@ -376,9 +376,9 @@ export const SessionModal: React.FC<Props> = ({
|
||||
{(tool) => (
|
||||
<SelectItem key={tool.id} textValue={tool.name}>
|
||||
<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>
|
||||
<span className="text-foreground-500 text-xs">{tool.description}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</SelectItem>
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import { loggerService } from '@logger'
|
||||
|
||||
const logger = loggerService.withContext('Feature Flag')
|
||||
/**
|
||||
* Feature flags for controlling gradual rollout of new features
|
||||
* 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
|
||||
if (import.meta.env?.VITE_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)
|
||||
@ -45,15 +47,12 @@ export function initializeFeatureFlags(): void {
|
||||
Object.keys(overrides).forEach((key) => {
|
||||
if (key in featureFlags) {
|
||||
featureFlags[key as keyof FeatureFlags] = overrides[key]
|
||||
console.log(`[FeatureFlags] ${key} set to ${overrides[key]} via localStorage`)
|
||||
}
|
||||
})
|
||||
}
|
||||
} 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 { Bot } from 'lucide-react'
|
||||
|
||||
import { ToolTitle } from './GenericTools'
|
||||
import Markdown from 'react-markdown'
|
||||
|
||||
import { ToolTitle } from './GenericTools'
|
||||
import type { TaskToolInput as TaskToolInputType, TaskToolOutput as TaskToolOutputType } from './types'
|
||||
|
||||
export function TaskTool({ input, output }: { input: TaskToolInputType; output?: TaskToolOutputType }) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { AccordionItem, Chip, Card, CardBody } from '@heroui/react'
|
||||
import { ListTodo, CheckCircle, Clock, Circle } from 'lucide-react'
|
||||
import { AccordionItem, Card, CardBody, Chip } from '@heroui/react'
|
||||
import { CheckCircle, Circle, Clock, ListTodo } from 'lucide-react'
|
||||
|
||||
import { ToolTitle } from './GenericTools'
|
||||
import type {
|
||||
TodoItem,
|
||||
TodoWriteToolInput as TodoWriteToolInputType,
|
||||
TodoWriteToolOutput as TodoWriteToolOutputType,
|
||||
TodoItem
|
||||
TodoWriteToolOutput as TodoWriteToolOutputType
|
||||
} from './types'
|
||||
import { AgentToolsType } from './types'
|
||||
|
||||
|
||||
@ -14,9 +14,9 @@ import { SearchTool } from './SearchTool'
|
||||
import { TaskTool } from './TaskTool'
|
||||
import { TodoWriteTool } from './TodoWriteTool'
|
||||
import { AgentToolsType, ToolInput, ToolOutput } from './types'
|
||||
import { WebFetchTool } from './WebFetchTool'
|
||||
import { WebSearchTool } from './WebSearchTool'
|
||||
import { WriteTool } from './WriteTool'
|
||||
import { WebFetchTool } from './WebFetchTool'
|
||||
|
||||
const logger = loggerService.withContext('MessageAgentTools')
|
||||
|
||||
|
||||
@ -215,8 +215,8 @@ const AgentEssentialSettings: FC<AgentEssentialSettingsProps> = ({ agent, update
|
||||
{(tool) => (
|
||||
<SelectItem key={tool.id} textValue={tool.name}>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">{tool.name}</span>
|
||||
{tool.description ? <span className="text-xs text-foreground-500">{tool.description}</span> : null}
|
||||
<span className="font-medium text-sm">{tool.name}</span>
|
||||
{tool.description ? <span className="text-foreground-500 text-xs">{tool.description}</span> : null}
|
||||
</div>
|
||||
</SelectItem>
|
||||
)}
|
||||
|
||||
@ -5,14 +5,15 @@
|
||||
*/
|
||||
|
||||
// Export main service
|
||||
export { DbService,dbService } from './DbService'
|
||||
export { DbService, dbService } from './DbService'
|
||||
|
||||
// Export types
|
||||
export type { MessageDataSource, MessageExchange } from './types'
|
||||
export {
|
||||
buildAgentSessionTopicId,
|
||||
extractSessionId,
|
||||
isAgentSessionTopicId} from './types'
|
||||
isAgentSessionTopicId
|
||||
} from './types'
|
||||
|
||||
// Export implementations (for testing or direct access if needed)
|
||||
export { AgentMessageDataSource } from './AgentMessageDataSource'
|
||||
|
||||
@ -205,7 +205,7 @@ export enum TopicType {
|
||||
|
||||
export type Topic = {
|
||||
id: string
|
||||
type: TopicType
|
||||
type?: TopicType
|
||||
assistantId: string
|
||||
name: string
|
||||
createdAt: string
|
||||
|
||||
@ -75,7 +75,7 @@ vi.mock('@renderer/utils/markdown', async (importOriginal) => {
|
||||
})
|
||||
|
||||
// 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 { copyMessageAsPlainText } from '../copy'
|
||||
@ -452,7 +452,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test_formatted',
|
||||
messages: [userMsg, assistantMsg] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -552,7 +553,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test_multi_formatted',
|
||||
messages: [msg1, msg2] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -587,7 +589,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test',
|
||||
messages: [msgWithEmpty] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -608,7 +611,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test',
|
||||
messages: [msgWithSpecial] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -634,7 +638,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test',
|
||||
messages: [msg1, msg2] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return the expected messages
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -655,7 +660,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test',
|
||||
messages: [] as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return empty array
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
@ -674,7 +680,8 @@ describe('export', () => {
|
||||
assistantId: 'asst_test',
|
||||
messages: null as any,
|
||||
createdAt: '',
|
||||
updatedAt: ''
|
||||
updatedAt: '',
|
||||
type: TopicType.Chat
|
||||
}
|
||||
// Mock TopicManager.getTopicMessages to return empty array for null case
|
||||
const { TopicManager } = await import('@renderer/hooks/useTopic')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user