Skip to content

Commit c687f70

Browse files
fix(cli): resolve all ESLint warnings and remove unused code
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 39fd2c4 commit c687f70

17 files changed

+65
-146
lines changed

cli/src/branch-item.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { type ReactNode } from 'react'
21
import { TextAttributes } from '@opentui/core'
2+
import React, { type ReactNode } from 'react'
3+
34
import type { ChatTheme } from './theme-system'
45

56
interface BranchItemProps {
6-
id: string
77
name: string
88
content: ReactNode
99
isCollapsed: boolean
@@ -16,7 +16,6 @@ interface BranchItemProps {
1616
}
1717

1818
export const BranchItem = ({
19-
id,
2019
name,
2120
content,
2221
isCollapsed,

cli/src/chat.tsx

Lines changed: 18 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,38 @@
1-
import {
2-
InputRenderable,
3-
LayoutEvents,
4-
ScrollBoxRenderable,
5-
TextAttributes,
6-
} from '@opentui/core'
7-
import { render, useKeyboard, useRenderer } from '@opentui/react'
8-
import { MultilineInput } from './multiline-input'
9-
import {
10-
renderMarkdown,
11-
renderStreamingMarkdown,
12-
hasMarkdown,
13-
type MarkdownPalette,
14-
} from './markdown-renderer'
15-
import {
16-
Fragment,
1+
import { useRenderer } from '@opentui/react'
2+
import React, {
173
useCallback,
184
useEffect,
195
useMemo,
206
useRef,
217
useState,
22-
type ReactNode,
238
} from 'react'
9+
10+
11+
import { logger } from './logger'
12+
import { buildMessageTree } from './message-tree-utils'
13+
import { MultilineInput } from './multiline-input'
14+
import { Separator } from './separator'
15+
import { StatusIndicator, useHasStatus } from './status-indicator'
2416
import {
25-
getCodebuffClient,
26-
getToolDisplayInfo,
27-
formatToolOutput,
28-
} from './codebuff-client'
29-
import type { ToolName } from '@codebuff/sdk'
30-
import {
31-
type ChatTheme,
3217
type ThemeName,
3318
chatThemes,
3419
createMarkdownPalette,
3520
detectSystemTheme,
3621
} from './theme-system'
37-
import { formatTimestamp, formatQueuedPreview } from './utils'
3822
import { useClipboard } from './use-clipboard'
3923
import { useInputHistory } from './use-input-history'
24+
import { useKeyboardHandlers } from './use-keyboard-handlers'
4025
import { useMessageQueue } from './use-message-queue'
41-
import { buildMessageTree } from './message-tree-utils'
42-
import { useSendMessage } from './use-send-message'
4326
import { useMessageRenderer } from './use-message-renderer'
44-
import { useKeyboardHandlers } from './use-keyboard-handlers'
4527
import { useScrollManagement } from './use-scroll-management'
28+
import { useSendMessage } from './use-send-message'
29+
import { formatTimestamp, formatQueuedPreview } from './utils'
4630

47-
import { logger } from './logger'
48-
49-
import { StatusIndicator, useHasStatus } from './status-indicator'
50-
import { Separator } from './separator'
51-
import React from 'react'
31+
import type { ToolName } from '@codebuff/sdk'
32+
import type {
33+
InputRenderable,
34+
ScrollBoxRenderable,
35+
} from '@opentui/core'
5236

5337
type ChatVariant = 'ai' | 'user' | 'agent'
5438

@@ -95,9 +79,6 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
9579
const renderer = useRenderer()
9680
const scrollRef = useRef<ScrollBoxRenderable | null>(null)
9781
const inputRef = useRef<InputRenderable | null>(null)
98-
const [inputRenderable, setInputRenderable] =
99-
useState<InputRenderable | null>(null)
100-
const [inputWidth, setInputWidth] = useState<number>(0)
10182

10283
const [themeName, setThemeName] = useState<ThemeName>(() =>
10384
detectSystemTheme(),
@@ -109,15 +90,13 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
10990
const [inputFocused, setInputFocused] = useState<boolean>(true)
11091

11192
const activeAgentStreamsRef = useRef<number>(0)
112-
const allAgentsScheduledRef = useRef<boolean>(false)
11393
const isChainInProgressRef = useRef<boolean>(false)
11494

11595
const { clipboardMessage } = useClipboard()
11696

11797
const [collapsedAgents, setCollapsedAgents] = useState<Set<string>>(new Set())
11898
const [streamingAgents, setStreamingAgents] = useState<Set<string>>(new Set())
11999
const [focusedAgentId, setFocusedAgentId] = useState<string | null>(null)
120-
const agentIdsRef = useRef<string[]>([])
121100
const agentRefsMap = useRef<Map<string, any>>(new Map())
122101

123102
const [messages, setMessages] = useState<ChatMessage[]>([
@@ -134,42 +113,13 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
134113
const hasAutoSubmittedRef = useRef(false)
135114
const activeSubagentsRef = useRef<Set<string>>(new Set())
136115

137-
const handleInputRef = useCallback((instance: InputRenderable | null) => {
138-
inputRef.current = instance
139-
setInputRenderable(instance)
140-
if (instance) {
141-
setInputWidth(Math.max(0, instance.width))
142-
}
143-
}, [])
144-
145-
146-
147116
useEffect(() => {
148117
renderer?.setBackgroundColor(theme.background)
149118
}, [renderer, theme.background])
150119

151120

152121

153-
useEffect(() => {
154-
const instance = inputRenderable
155-
if (!instance) return
156-
157-
const updateWidth = () => {
158-
setInputWidth(Math.max(0, instance.width))
159-
}
160-
161-
updateWidth()
162122

163-
const handleResize = ({ width }: { width: number }) => {
164-
setInputWidth(Math.max(0, width))
165-
}
166-
167-
instance.on(LayoutEvents.RESIZED, handleResize)
168-
169-
return () => {
170-
instance.off(LayoutEvents.RESIZED, handleResize)
171-
}
172-
}, [inputRenderable])
173123

174124
const abortControllerRef = useRef<AbortController | null>(null)
175125

@@ -181,14 +131,13 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
181131
}
182132
}, [])
183133

184-
const { scrollToLatest, scrollToAgent } = useScrollManagement(
134+
const { scrollToAgent } = useScrollManagement(
185135
scrollRef,
186136
messages,
187137
agentRefsMap,
188138
)
189139

190140
const { saveToHistory, navigateUp, navigateDown } = useInputHistory(
191-
inputRenderable,
192141
inputValue,
193142
setInputValue,
194143
)
@@ -198,14 +147,12 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
198147
const {
199148
queuedMessages,
200149
isStreaming,
201-
canProcessQueue,
202150
isWaitingForResponse,
203151
streamMessageIdRef,
204152
addToQueue,
205153
startStreaming,
206154
stopStreaming,
207155
setIsWaitingForResponse,
208-
clearStreaming,
209156
setCanProcessQueue,
210157
setIsStreaming,
211158
} = useMessageQueue(
@@ -325,7 +272,6 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
325272
isWaitingForResponse,
326273
abortControllerRef,
327274
focusedAgentId,
328-
inputRenderable,
329275
setFocusedAgentId,
330276
setInputFocused,
331277
inputRef,
@@ -352,17 +298,6 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
352298
scrollToAgent,
353299
})
354300

355-
const fallbackInputWidth = Math.max(4, renderer.width - 6)
356-
const effectiveInputWidth = inputWidth > 0 ? inputWidth : fallbackInputWidth
357-
const maxCharsPerLine = Math.max(1, effectiveInputWidth - 1)
358-
const textLengthForRows = Math.max(1, inputValue.length)
359-
const computedLineCount = Math.max(
360-
1,
361-
Math.ceil(textLengthForRows / maxCharsPerLine),
362-
)
363-
const maxInputHeight = 5
364-
const inputHeight = Math.max(1, Math.min(computedLineCount, maxInputHeight))
365-
366301
return (
367302
<box
368303
style={{

cli/src/codebuff-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CodebuffClient } from '@codebuff/sdk'
2+
23
import { logger } from './logger'
34

45
let clientInstance: CodebuffClient | null = null

cli/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env node
22
import { render } from '@opentui/react'
3-
import { App } from './chat'
43
import React from 'react'
54

5+
import { App } from './chat'
6+
67
function parseArgs(): string | null {
78
const args = process.argv.slice(2)
89
const pIndex = args.indexOf('-p')

cli/src/markdown-renderer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { unified } from 'unified'
1+
import React, { type ReactNode } from 'react'
22
import remarkParse from 'remark-parse'
3+
import { unified } from 'unified'
4+
5+
import { logger } from './logger'
6+
37
import type {
48
Root,
59
Content,
@@ -9,13 +13,12 @@ import type {
913
InlineCode,
1014
Code,
1115
Heading,
12-
Paragraph,
1316
List,
1417
ListItem,
1518
Blockquote,
1619
} from 'mdast'
17-
import React, { Fragment, type ReactNode } from 'react'
18-
import { logger } from './logger'
20+
21+
1922

2023
export interface MarkdownPalette {
2124
inlineCodeFg: string

cli/src/message-block.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import React, { type ReactNode } from 'react'
21
import { TextAttributes } from '@opentui/core'
2+
import React, { type ReactNode } from 'react'
3+
4+
import { BranchItem } from './branch-item'
5+
import { getToolDisplayInfo } from './codebuff-client'
36
import {
47
renderMarkdown,
58
renderStreamingMarkdown,
69
hasMarkdown,
710
type MarkdownPalette,
811
} from './markdown-renderer'
9-
import { getToolDisplayInfo } from './codebuff-client'
10-
import { BranchItem } from './branch-item'
11-
import type { ChatTheme } from './theme-system'
12+
1213
import type { ContentBlock } from './chat'
14+
import type { ChatTheme } from './theme-system'
1315

1416
interface MessageBlockProps {
1517
messageId: string
@@ -152,7 +154,6 @@ export const MessageBlock = ({
152154
return (
153155
<box key={`${messageId}-tool-${block.toolCallId}`}>
154156
<BranchItem
155-
id={block.toolCallId}
156157
name={displayInfo.name}
157158
content={displayContent}
158159
isCollapsed={isCollapsed}
@@ -205,7 +206,6 @@ export const MessageBlock = ({
205206
return (
206207
<box key={`${messageId}-agent-${block.agentId}`}>
207208
<BranchItem
208-
id={block.agentId}
209209
name={block.agentName}
210210
content={displayContent}
211211
isCollapsed={isCollapsed}

cli/src/multiline-input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { useCallback, useState, useEffect, useMemo, useRef } from 'react'
21
import { useKeyboard, usePaste } from '@opentui/react'
2+
import { useCallback, useState, useEffect, useMemo, useRef } from 'react'
3+
34
import type { ScrollBoxRenderable } from '@opentui/core'
4-
import { logger } from './logger'
5+
56

67
// Helper functions for text manipulation
78
function findLineStart(text: string, cursor: number): number {

cli/src/separator.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react'
2+
23
import type { ChatTheme } from './theme-system'
34

45
interface SeparatorProps {

cli/src/shimmer-text.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TextAttributes } from '@opentui/core'
2-
import { useEffect, useMemo, useState } from 'react'
3-
import React from 'react'
2+
import React, { useEffect, useMemo, useState } from 'react'
43

54
export const DEFAULT_SHIMMER_COLORS = [
65
'#ff8c00',

cli/src/status-indicator.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useEffect, useState } from 'react'
2-
import { ShimmerText } from './shimmer-text'
2+
33
import { getCodebuffClient } from './codebuff-client'
4+
import { ShimmerText } from './shimmer-text'
5+
46
import type { ChatTheme } from './theme-system'
57

68
const THINKING_SHIMMER_COLORS = [

0 commit comments

Comments
 (0)