fix: clean up code (#5851)

This commit is contained in:
自由的世界人 2025-05-11 00:37:01 +08:00 committed by GitHub
parent 2193a665c6
commit 6ee181ed38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 22 additions and 47 deletions

View File

@ -7,7 +7,6 @@ exports.default = async function notarizing(context) {
}
if (!process.env.APPLE_ID || !process.env.APPLE_APP_SPECIFIC_PASSWORD || !process.env.APPLE_TEAM_ID) {
console.log('Skipping notarization')
return
}

View File

@ -56,7 +56,6 @@ class DifyKnowledgeServer {
private config: DifyKnowledgeServerConfig
constructor(difyKey: string, args: string[]) {
console.log('DifyKnowledgeServer args', args)
if (args.length === 0) {
throw new Error('DifyKnowledgeServer requires at least one argument')
}
@ -113,8 +112,6 @@ class DifyKnowledgeServer {
const errorDetails = JSON.stringify(parsed.error.format(), null, 2)
throw new Error(`无效的参数:\n${errorDetails}`)
}
console.log('DifyKnowledgeServer search_knowledge parsed', parsed.data)
return await this.performSearchKnowledge(
parsed.data.id,
parsed.data.query,

View File

@ -25,7 +25,6 @@ export function handleProtocolUrl(url: string) {
if (!url) return
// Process the URL that was used to open the app
// The url will be in the format: cherrystudio://data?param1=value1&param2=value2
console.log('Received URL:', url)
// Parse the URL and extract parameters
const urlObj = new URL(url)

View File

@ -88,7 +88,6 @@ export function useMessageOperations(topic: Topic) {
console.error('[editMessage] Topic prop is not valid.')
return
}
console.log(`[useMessageOperations] Editing message ${messageId} with updates:`, updates)
const messageUpdates: Partial<Message> & Pick<Message, 'id'> = {
id: messageId,
@ -274,12 +273,10 @@ export function useMessageOperations(topic: Topic) {
}
dispatch(updateOneBlock({ id: blockId, changes }))
await dispatch(updateTranslationBlockThunk(blockId, '', false))
console.log('[getTranslationUpdater] update existing translation block:', blockId)
} else {
blockId = await dispatch(
initiateTranslationThunk(messageId, topic.id, targetLanguage, sourceBlockId, sourceLanguage)
)
console.log('[getTranslationUpdater] create new translation block:', blockId)
}
if (!blockId) {

View File

@ -88,7 +88,6 @@ const MessageMenubar: FC<Props> = (props) => {
const onCopy = useCallback(
(e: React.MouseEvent) => {
e.stopPropagation()
console.log('mainTextContent', mainTextContent)
navigator.clipboard.writeText(removeTrailingDoubleSpaces(mainTextContent.trimStart()))
window.message.success({ content: t('message.copied'), key: 'copy-message' })

View File

@ -495,7 +495,7 @@ export default class AnthropicProvider extends BaseProvider {
/**
* Translate a message
* @param message - The message
* @param content
* @param assistant - The assistant
* @param onResponse - The onResponse callback
* @returns The translated message
@ -622,8 +622,7 @@ export default class AnthropicProvider extends BaseProvider {
)
.finally(cleanup)
const responseContent = response.content[0].type === 'text' ? response.content[0].text : ''
return responseContent
return response.content[0].type === 'text' ? response.content[0].text : ''
}
/**

View File

@ -620,7 +620,7 @@ export default class GeminiProvider extends BaseProvider {
/**
* Translate a message
* @param message - The message
* @param content
* @param assistant - The assistant
* @param onResponse - The onResponse callback
* @returns The translated message
@ -827,7 +827,7 @@ export default class GeminiProvider extends BaseProvider {
/**
* Gemini图像响应
* @param response - Gemini响应
* @param chunk
* @param onChunk -
*/
private processGeminiImageResponse(
@ -961,7 +961,7 @@ export default class GeminiProvider extends BaseProvider {
if ('toolUseId' in mcpToolResponse && mcpToolResponse.toolUseId) {
return mcpToolCallResponseToGeminiMessage(mcpToolResponse, resp, isVisionModel(model))
} else if ('toolCallId' in mcpToolResponse) {
const toolCallOut = {
return {
role: 'user',
parts: [
{
@ -976,7 +976,6 @@ export default class GeminiProvider extends BaseProvider {
}
]
} satisfies Content
return toolCallOut
}
return
}

View File

@ -1239,12 +1239,11 @@ export default class OpenAIProvider extends BaseOpenAiProvider {
if ('toolUseId' in mcpToolResponse && mcpToolResponse.toolUseId) {
return mcpToolCallResponseToOpenAIMessage(mcpToolResponse, resp, isVisionModel(model))
} else if ('toolCallId' in mcpToolResponse && mcpToolResponse.toolCallId) {
const toolCallOut: OpenAI.Responses.ResponseInputItem = {
return {
type: 'function_call_output',
call_id: mcpToolResponse.toolCallId,
output: JSON.stringify(resp.content)
}
return toolCallOut
}
return
}

View File

@ -17,8 +17,6 @@ export default class WebSearchEngineProvider {
httpOptions?: RequestInit
): Promise<WebSearchProviderResponse> {
const result = await this.sdk.search(query, websearch, httpOptions)
const filteredResult = await filterResultWithBlacklist(result, websearch)
return filteredResult
return await filterResultWithBlacklist(result, websearch)
}
}

View File

@ -4,11 +4,7 @@ export function formatApiHost(host: string) {
return true
}
if (host.endsWith('volces.com/api/v3')) {
return true
}
return false
return host.endsWith('volces.com/api/v3')
}
return forceUseOriginalHost() ? host : `${host}/v1/`

View File

@ -190,12 +190,10 @@ export async function parseSubscribeContent(url: string): Promise<string[]> {
const lines = content.split('\n')
// 过滤出有效的匹配模式
const patterns = lines
return lines
.filter((line) => line.trim() !== '' && !line.startsWith('#'))
.map((line) => line.trim())
.filter((pattern) => parseMatchPattern(pattern) !== null)
return patterns
} catch (error) {
console.error('Error parsing subscribe content:', error)
throw error
@ -264,11 +262,7 @@ export async function filterResultWithBlacklist(
// 检查URL是否匹配任何匹配模式规则
const matchesPattern = patternMap.get(result.url).length > 0
if (matchesPattern) {
return false
}
return true
return !matchesPattern
} catch (error) {
console.error('Error processing URL:', result.url, error)
return true // 如果URL解析失败保留该结果

View File

@ -13,8 +13,12 @@ import type {
ToolMessageBlock,
TranslationMessageBlock
} from '@renderer/types/newMessage'
import { AssistantMessageStatus, UserMessageStatus } from '@renderer/types/newMessage'
import { MessageBlockStatus, MessageBlockType } from '@renderer/types/newMessage'
import {
AssistantMessageStatus,
MessageBlockStatus,
MessageBlockType,
UserMessageStatus
} from '@renderer/types/newMessage'
import { v4 as uuidv4 } from 'uuid'
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
@ -184,7 +188,7 @@ export function createFileBlock(
/**
* Creates an Error Message Block.
* @param messageId - The ID of the parent message.
* @param error - The error object/details.
* @param errorData
* @param overrides - Optional properties to override the defaults.
* @returns An ErrorMessageBlock object.
*/
@ -273,7 +277,6 @@ export function createCitationBlock(
* @param role - The role of the message sender ('user' or 'assistant').
* @param topicId - The ID of the topic this message belongs to.
* @param assistantId - The ID of the assistant (relevant for assistant messages).
* @param type - The type of the message ('text', '@', 'clear').
* @param overrides - Optional properties to override the defaults. Initial blocks can be passed here.
* @returns A Message object.
*/
@ -311,8 +314,8 @@ export function createMessage(
/**
* Creates a new Assistant Message object (stub) based on the LATEST definition.
* Contains only metadata, no content or block data initially.
* @param assistant - The assistant configuration.
* @param topic - The topic this message belongs to.
* @param assistantId
* @param topicId
* @param overrides - Optional properties to override the defaults (e.g., model, askId).
* @returns An Assistant Message stub object.
*/
@ -395,7 +398,7 @@ export const resetAssistantMessage = (
}
// Create the base reset message
const resetMsg: Message = {
return {
// --- Retain Core Identifiers ---
id: originalMessage.id, // Keep the same message ID
topicId: originalMessage.topicId,
@ -420,8 +423,6 @@ export const resetAssistantMessage = (
// --- Apply Overrides ---
...updates // Apply any specific updates passed in (e.g., a different status)
}
return resetMsg
}
// 需要一个重置助手消息

View File

@ -135,10 +135,7 @@ export function filterUsefulMessages(messages: Message[]): Message[] {
// Filter adjacent user messages, keeping only the last one
_messages = _messages.filter((message, index, origin) => {
if (message.role === 'user' && index + 1 < origin.length && origin[index + 1].role === 'user') {
return false
}
return true
return !(message.role === 'user' && index + 1 < origin.length && origin[index + 1].role === 'user')
})
return _messages

View File

@ -6,6 +6,7 @@ const requestQueues: { [topicId: string]: PQueue } = {}
/**
* Get or create a queue for a specific topic
* @param topicId The ID of the topic
* @param options
* @returns A PQueue instance for the topic
*/
export const getTopicQueue = (topicId: string, options = {}): PQueue => {