Skip to content

Commit 9164c7b

Browse files
committed
refactor: additional code cleanup
- Replace inline import with proper type import in message-footer.tsx - Remove keyboard debug logging from use-chat-keyboard.ts - Convert map().filter() to reduce() in use-send-message.ts - Remove duplicate implementor helpers from constants.ts (already in implementor-helpers.ts)
1 parent 75a0e92 commit 9164c7b

File tree

3 files changed

+26
-63
lines changed

3 files changed

+26
-63
lines changed

cli/src/hooks/use-chat-keyboard.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
type ChatKeyboardState,
88
type ChatKeyboardAction,
99
} from '../utils/keyboard-actions'
10-
import { logger } from '../utils/logger'
1110

1211
/**
1312
* Handlers for chat keyboard actions.
@@ -191,21 +190,7 @@ export function useChatKeyboard({
191190
(key: KeyEvent) => {
192191
if (disabled) return
193192

194-
// Debug logging for all keyboard events
195-
logger.debug(
196-
{
197-
name: key.name,
198-
ctrl: key.ctrl,
199-
meta: key.meta,
200-
shift: key.shift,
201-
option: key.option,
202-
sequence: key.sequence,
203-
},
204-
'Keyboard event',
205-
)
206-
207193
const action = resolveChatKeyboardAction(key, state)
208-
logger.debug({ action: action.type }, 'Resolved keyboard action')
209194
const handled = dispatchAction(action, handlers)
210195

211196
// Prevent default for handled actions

cli/src/hooks/use-send-message.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -491,28 +491,32 @@ export const useSendMessage = ({
491491

492492
// Process all images for SDK
493493
const projectRoot = getProjectRoot()
494-
const validImageParts = uniqueImagePaths
495-
.map((imagePath) => {
496-
const result = processImageFile(imagePath, projectRoot)
497-
if (result.success && result.imagePart) {
498-
return {
499-
type: 'image' as const,
500-
image: result.imagePart.image,
501-
mediaType: result.imagePart.mediaType,
502-
filename: result.imagePart.filename,
503-
size: result.imagePart.size,
504-
path: imagePath,
505-
}
506-
}
507-
if (!result.success) {
508-
logger.warn(
509-
{ imagePath, error: result.error },
510-
'Failed to process image for SDK',
511-
)
512-
}
513-
return null
514-
})
515-
.filter((part): part is NonNullable<typeof part> => part !== null)
494+
const validImageParts = uniqueImagePaths.reduce<Array<{
495+
type: 'image'
496+
image: string
497+
mediaType: string
498+
filename: string | undefined
499+
size: number | undefined
500+
path: string
501+
}>>((acc, imagePath) => {
502+
const result = processImageFile(imagePath, projectRoot)
503+
if (result.success && result.imagePart) {
504+
acc.push({
505+
type: 'image',
506+
image: result.imagePart.image,
507+
mediaType: result.imagePart.mediaType,
508+
filename: result.imagePart.filename,
509+
size: result.imagePart.size,
510+
path: imagePath,
511+
})
512+
} else if (!result.success) {
513+
logger.warn(
514+
{ imagePath, error: result.error },
515+
'Failed to process image for SDK',
516+
)
517+
}
518+
return acc
519+
}, [])
516520

517521
// Build message content array for SDK
518522
let messageContent: MessageContent[] | undefined

cli/src/utils/constants.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,3 @@ export const MAIN_AGENT_ID = 'main-agent'
4848

4949
const agentModes = ['DEFAULT', 'MAX', 'PLAN'] as const
5050
export type AgentMode = (typeof agentModes)[number]
51-
52-
// Implementor agent types that generate code proposals
53-
const IMPLEMENTOR_AGENT_TYPES = [
54-
'implementor-gemini',
55-
'implementor-opus',
56-
'implementor-max',
57-
'implementor-fast',
58-
] as const
59-
60-
/**
61-
* Check if an agent type is an implementor agent
62-
*/
63-
export const isImplementorAgent = (agentType: string): boolean => {
64-
return IMPLEMENTOR_AGENT_TYPES.some((impl) => agentType.includes(impl))
65-
}
66-
67-
/**
68-
* Get a display name for implementor agents
69-
*/
70-
export const getImplementorDisplayName = (agentType: string): string => {
71-
if (agentType.includes('implementor-gemini')) return 'Gemini'
72-
if (agentType.includes('implementor-opus')) return 'Opus'
73-
if (agentType.includes('implementor-max')) return 'Max'
74-
if (agentType.includes('implementor-fast')) return 'Fast'
75-
return 'Implementor'
76-
}

0 commit comments

Comments
 (0)