fix linting errors with comments for dallin

This commit is contained in:
Nate Kelley 2025-10-09 09:48:43 -06:00
parent 29af17ede8
commit aeca703665
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
18 changed files with 42 additions and 32 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -3,5 +3,12 @@
"extends": ["../../biome2.json"], "extends": ["../../biome2.json"],
"files": { "files": {
"includes": ["src/**/*", "scripts/**/*"] "includes": ["src/**/*", "scripts/**/*"]
},
"linter": {
"rules": {
"suspicious": {
"noConsole": "off"
}
}
} }
} }

View File

@ -35,7 +35,6 @@ import { z } from 'zod';
// Get DocDeployResultSchema from deploy namespace // Get DocDeployResultSchema from deploy namespace
const DocDeployResultSchema = deploy.DocDeployResultSchema; const DocDeployResultSchema = deploy.DocDeployResultSchema;
type DocDeployResult = deploy.DocDeployResult;
// Re-export all the shared schemas from server-shared // Re-export all the shared schemas from server-shared
export { export {

View File

@ -8,7 +8,7 @@ vi.mock('bun', () => ({
public pattern: string, public pattern: string,
public options: any public options: any
) {} ) {}
async *scan() { async scan() {
// Return empty for tests // Return empty for tests
return []; return [];
} }

View File

@ -28,7 +28,7 @@ type AppMode = 'Planning' | 'Auto-accept' | 'None';
export function Main() { export function Main() {
const { exit } = useApp(); const { exit } = useApp();
const [input, setInput] = useState(''); const [input, setInput] = useState('');
const [history, setHistory] = useState<ChatHistoryEntry[]>([]); const [_history, setHistory] = useState<ChatHistoryEntry[]>([]);
const [messages, setMessages] = useState<CliAgentMessage[]>([]); const [messages, setMessages] = useState<CliAgentMessage[]>([]);
const historyCounter = useRef(0); const historyCounter = useRef(0);
const messageCounter = useRef(0); const messageCounter = useRef(0);
@ -45,6 +45,7 @@ export function Main() {
const abortControllerRef = useRef<AbortController | null>(null); const abortControllerRef = useRef<AbortController | null>(null);
// Callback to update messages from agent stream // Callback to update messages from agent stream
// biome-ignore lint/suspicious/noExplicitAny: We need to fix this to actually make it typesafe
const handleMessageUpdate = useCallback((modelMessages: any[]) => { const handleMessageUpdate = useCallback((modelMessages: any[]) => {
const transformedMessages = transformModelMessagesToUI(modelMessages); const transformedMessages = transformModelMessagesToUI(modelMessages);
@ -125,6 +126,7 @@ export function Main() {
role: 'user', role: 'user',
content: trimmed, content: trimmed,
}; };
// biome-ignore lint/suspicious/noExplicitAny: We need to fix this to actually make it typesafe
const updatedModelMessages = [...existingModelMessages, userMessage] as any; const updatedModelMessages = [...existingModelMessages, userMessage] as any;
// Update UI state immediately // Update UI state immediately

View File

@ -127,7 +127,7 @@ export function ChatInput({
// Slash command state // Slash command state
const [slashQuery, setSlashQuery] = useState<string | null>(null); const [slashQuery, setSlashQuery] = useState<string | null>(null);
const [slashStart, setSlashStart] = useState<number>(-1); const [_slashStart, setSlashStart] = useState<number>(-1);
const [commandResults, setCommandResults] = useState<SlashCommand[]>([]); const [commandResults, setCommandResults] = useState<SlashCommand[]>([]);
const [showCommandAutocomplete, setShowCommandAutocomplete] = useState(false); const [showCommandAutocomplete, setShowCommandAutocomplete] = useState(false);
const [selectedCommandIndex, setSelectedCommandIndex] = useState(0); const [selectedCommandIndex, setSelectedCommandIndex] = useState(0);

View File

@ -65,7 +65,7 @@ function parseDiff(diff: string): { lines: ParsedDiffLine[]; additions: number;
*/ */
export function EditMessage({ message }: EditMessageProps) { export function EditMessage({ message }: EditMessageProps) {
const isExpanded = useExpansion(); const isExpanded = useExpansion();
const { args, result } = message; const { result } = message;
if (!result) { if (!result) {
return null; return null;
@ -128,6 +128,7 @@ export function EditMessage({ message }: EditMessageProps) {
return ( return (
<Text <Text
// biome-ignore lint/suspicious/noArrayIndexKey: Messages are stable and won't be reordered? Dallin can confirm?
key={idx} key={idx}
color={UI_CONSTANTS.COLORS.TEXT_PRIMARY} color={UI_CONSTANTS.COLORS.TEXT_PRIMARY}
{...(backgroundColor && { backgroundColor })} {...(backgroundColor && { backgroundColor })}

View File

@ -21,6 +21,7 @@ export function ExecuteMessage({ message }: ExecuteMessageProps) {
const { args, result } = message; const { args, result } = message;
// Get command description and output based on tool type // Get command description and output based on tool type
// biome-ignore lint/correctness/noUnusedVariables: false positive
let description = ''; let description = '';
let output = ''; let output = '';
let exitCode: number | undefined; let exitCode: number | undefined;
@ -38,7 +39,7 @@ export function ExecuteMessage({ message }: ExecuteMessageProps) {
description = `Search for "${args.pattern}"${args.glob ? ` in ${args.glob}` : ''}`; description = `Search for "${args.pattern}"${args.glob ? ` in ${args.glob}` : ''}`;
} }
if (result && 'matches' in result) { if (result && 'matches' in result) {
output = result.matches.map((m: any) => `${m.path}:${m.lineNum}: ${m.lineText}`).join('\n'); output = result.matches.map((m) => `${m.path}:${m.lineNum}: ${m.lineText}`).join('\n');
success = result.totalMatches > 0; success = result.totalMatches > 0;
} }
} else if (message.kind === 'ls') { } else if (message.kind === 'ls') {

View File

@ -40,7 +40,6 @@ function getRelativeTime(dateString: string): string {
} }
export function HistoryBrowser({ workingDirectory, onSelect, onCancel }: HistoryBrowserProps) { export function HistoryBrowser({ workingDirectory, onSelect, onCancel }: HistoryBrowserProps) {
const { exit } = useApp();
const [conversations, setConversations] = useState<ConversationListItem[]>([]); const [conversations, setConversations] = useState<ConversationListItem[]>([]);
const [selectedIndex, setSelectedIndex] = useState(0); const [selectedIndex, setSelectedIndex] = useState(0);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
@ -59,7 +58,7 @@ export function HistoryBrowser({ workingDirectory, onSelect, onCancel }: History
let title = 'Untitled conversation'; let title = 'Untitled conversation';
if (fullConvo?.modelMessages) { if (fullConvo?.modelMessages) {
const firstUserMsg = fullConvo.modelMessages.find( const firstUserMsg = fullConvo.modelMessages.find(
(msg: any) => msg.message.kind === 'user' (msg) => msg.message.kind === 'user'
); );
if (firstUserMsg && firstUserMsg.message.kind === 'user') { if (firstUserMsg && firstUserMsg.message.kind === 'user') {
// Truncate to first line and max 60 chars // Truncate to first line and max 60 chars

View File

@ -168,6 +168,7 @@ export function MultiLineTextInput({
if (action.preventDefault) { if (action.preventDefault) {
// Apply the action // Apply the action
if (action.type === 'mode-change' && action.mode) { if (action.type === 'mode-change' && action.mode) {
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
setVimState((prev) => ({ ...prev, mode: action.mode! })); setVimState((prev) => ({ ...prev, mode: action.mode! }));
if (action.mode === 'visual') { if (action.mode === 'visual') {
setVimState((prev) => ({ ...prev, visualStart: cursorPosition })); setVimState((prev) => ({ ...prev, visualStart: cursorPosition }));
@ -180,9 +181,11 @@ export function MultiLineTextInput({
onChange(action.text); onChange(action.text);
} }
if (action.yankedText !== undefined) { if (action.yankedText !== undefined) {
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
setVimState((prev) => ({ ...prev, yankedText: action.yankedText! })); setVimState((prev) => ({ ...prev, yankedText: action.yankedText! }));
} }
if (action.mode !== undefined) { if (action.mode !== undefined) {
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
setVimState((prev) => ({ ...prev, mode: action.mode! })); setVimState((prev) => ({ ...prev, mode: action.mode! }));
} }
return; return;
@ -324,7 +327,9 @@ export function MultiLineTextInput({
let positionInLine = cursorPosition; let positionInLine = cursorPosition;
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
const lineLength = lines[i]!.length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line const lineLength = lines[i]!.length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
if (cursorPosition <= currentLineStart + lines[i]!.length) { if (cursorPosition <= currentLineStart + lines[i]!.length) {
currentLineIndex = i; currentLineIndex = i;
positionInLine = cursorPosition - currentLineStart; positionInLine = cursorPosition - currentLineStart;
@ -337,6 +342,7 @@ export function MultiLineTextInput({
const previousLineStart = lines const previousLineStart = lines
.slice(0, currentLineIndex - 1) .slice(0, currentLineIndex - 1)
.reduce((acc, line) => acc + line.length + 1, 0); .reduce((acc, line) => acc + line.length + 1, 0);
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
const previousLineLength = lines[currentLineIndex - 1]!.length; const previousLineLength = lines[currentLineIndex - 1]!.length;
const newPosition = previousLineStart + Math.min(positionInLine, previousLineLength); const newPosition = previousLineStart + Math.min(positionInLine, previousLineLength);
setCursorPosition(newPosition); setCursorPosition(newPosition);
@ -352,7 +358,9 @@ export function MultiLineTextInput({
let positionInLine = cursorPosition; let positionInLine = cursorPosition;
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
const lineLength = lines[i]!.length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line const lineLength = lines[i]!.length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line
// biome-ignore lint/style/noNonNullAssertion: Dallin can confirm if this is safe
if (cursorPosition <= currentLineStart + lines[i]!.length) { if (cursorPosition <= currentLineStart + lines[i]!.length) {
currentLineIndex = i; currentLineIndex = i;
positionInLine = cursorPosition - currentLineStart; positionInLine = cursorPosition - currentLineStart;
@ -365,7 +373,7 @@ export function MultiLineTextInput({
const nextLineStart = lines const nextLineStart = lines
.slice(0, currentLineIndex + 1) .slice(0, currentLineIndex + 1)
.reduce((acc, line) => acc + line.length + 1, 0); .reduce((acc, line) => acc + line.length + 1, 0);
const nextLineLength = lines[currentLineIndex + 1]!.length; const nextLineLength = lines[currentLineIndex + 1]?.length ?? 0;
const newPosition = nextLineStart + Math.min(positionInLine, nextLineLength); const newPosition = nextLineStart + Math.min(positionInLine, nextLineLength);
setCursorPosition(newPosition); setCursorPosition(newPosition);
} }

View File

@ -20,7 +20,7 @@ interface ReadMessageProps {
*/ */
export function ReadMessage({ message }: ReadMessageProps) { export function ReadMessage({ message }: ReadMessageProps) {
const isExpanded = useExpansion(); const isExpanded = useExpansion();
const { args, result } = message; const { result } = message;
if (!result) { if (!result) {
return null; return null;

View File

@ -17,6 +17,7 @@ export function ContentLines({
return ( return (
<> <>
{lines.map((line, idx) => ( {lines.map((line, idx) => (
// biome-ignore lint/suspicious/noArrayIndexKey: Lines position stable during rendering? Dallin can confirm?
<Text key={idx} color={color}> <Text key={idx} color={color}>
{line} {line}
</Text> </Text>

View File

@ -42,6 +42,7 @@ export function WriteMessage({ message }: WriteMessageProps) {
return ( return (
<Box <Box
// biome-ignore lint/suspicious/noArrayIndexKey: Messages are stable and won't be reordered? Dallin can confirm?
key={fileIdx} key={fileIdx}
flexDirection="column" flexDirection="column"
marginBottom={fileIdx < args.files.length - 1 ? 1 : 0} marginBottom={fileIdx < args.files.length - 1 ? 1 : 0}

View File

@ -155,7 +155,7 @@ export async function runAnalyticsEngineerAgent(params: RunAnalyticsEngineerAgen
accumulatorState, accumulatorState,
part.toolCallId, part.toolCallId,
part.toolName, part.toolName,
part.output part.output as string | Record<string, unknown>
); );
onMessageUpdate?.(accumulatorState.messages); onMessageUpdate?.(accumulatorState.messages);
} }

View File

@ -68,7 +68,7 @@ export function addReasoningContent(
state.currentStepAssistantMessage && state.currentStepAssistantMessage &&
Array.isArray(state.currentStepAssistantMessage.content) Array.isArray(state.currentStepAssistantMessage.content)
) { ) {
(state.currentStepAssistantMessage.content as Array<typeof reasoningContent>).push( (state.currentStepAssistantMessage.content as (typeof reasoningContent)[]).push(
reasoningContent reasoningContent
); );
} }
@ -108,7 +108,7 @@ export function addTextContent(
state.currentStepAssistantMessage && state.currentStepAssistantMessage &&
Array.isArray(state.currentStepAssistantMessage.content) Array.isArray(state.currentStepAssistantMessage.content)
) { ) {
(state.currentStepAssistantMessage.content as Array<typeof textContent>).push(textContent); (state.currentStepAssistantMessage.content as (typeof textContent)[]).push(textContent);
} }
return state; return state;
@ -121,7 +121,7 @@ export function addToolCall(
state: MessageAccumulatorState, state: MessageAccumulatorState,
toolCallId: string, toolCallId: string,
toolName: string, toolName: string,
input: any input: unknown
): MessageAccumulatorState { ): MessageAccumulatorState {
const toolCallContent = { const toolCallContent = {
type: 'tool-call' as const, type: 'tool-call' as const,
@ -150,9 +150,7 @@ export function addToolCall(
state.currentStepAssistantMessage && state.currentStepAssistantMessage &&
Array.isArray(state.currentStepAssistantMessage.content) Array.isArray(state.currentStepAssistantMessage.content)
) { ) {
(state.currentStepAssistantMessage.content as Array<typeof toolCallContent>).push( (state.currentStepAssistantMessage.content as (typeof toolCallContent)[]).push(toolCallContent);
toolCallContent
);
} }
return state; return state;
@ -166,7 +164,7 @@ export function addToolResult(
state: MessageAccumulatorState, state: MessageAccumulatorState,
toolCallId: string, toolCallId: string,
toolName: string, toolName: string,
output: any output: string | Record<string, unknown>
): MessageAccumulatorState { ): MessageAccumulatorState {
const toolResultContent = { const toolResultContent = {
type: 'tool-result' as const, type: 'tool-result' as const,
@ -194,7 +192,7 @@ export function addToolResult(
// Append to existing tool message // Append to existing tool message
if (Array.isArray(state.currentToolMessage.content)) { if (Array.isArray(state.currentToolMessage.content)) {
(state.currentToolMessage.content as Array<typeof toolResultContent>).push(toolResultContent); (state.currentToolMessage.content as (typeof toolResultContent)[]).push(toolResultContent);
} }
return state; return state;

View File

@ -46,13 +46,6 @@ function encodePathForDirectory(path: string): string {
return Buffer.from(path).toString('base64url'); return Buffer.from(path).toString('base64url');
} }
/**
* Decodes a directory name back to the original path
*/
function decodePathFromDirectory(encoded: string): string {
return Buffer.from(encoded, 'base64url').toString('utf-8');
}
/** /**
* Gets the history directory for a specific working directory * Gets the history directory for a specific working directory
*/ */
@ -112,7 +105,7 @@ export async function loadConversation(
const data = await readFile(filePath, 'utf-8'); const data = await readFile(filePath, 'utf-8');
const parsed = JSON.parse(data); const parsed = JSON.parse(data);
return ConversationSchema.parse(parsed); return ConversationSchema.parse(parsed);
} catch (error) { } catch (_error) {
// File doesn't exist or is invalid // File doesn't exist or is invalid
return null; return null;
} }
@ -124,6 +117,7 @@ export async function loadConversation(
export async function saveModelMessages( export async function saveModelMessages(
chatId: string, chatId: string,
workingDirectory: string, workingDirectory: string,
// biome-ignore lint/suspicious/noExplicitAny: We need to fix this to actually make it typesafe
modelMessages: any[] modelMessages: any[]
): Promise<void> { ): Promise<void> {
let conversation = await loadConversation(chatId, workingDirectory); let conversation = await loadConversation(chatId, workingDirectory);
@ -134,6 +128,7 @@ export async function saveModelMessages(
} }
// Replace the model messages with the new array // Replace the model messages with the new array
// biome-ignore lint/suspicious/noExplicitAny: We need to fix this to actually make it typesafe
conversation.modelMessages = modelMessages as any[]; conversation.modelMessages = modelMessages as any[];
conversation.updatedAt = new Date().toISOString(); conversation.updatedAt = new Date().toISOString();
@ -174,7 +169,7 @@ export async function listConversations(
return conversations return conversations
.filter((c): c is NonNullable<typeof c> => c !== null) .filter((c): c is NonNullable<typeof c> => c !== null)
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()); .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
} catch (error) { } catch (_error) {
// Directory doesn't exist or can't be read // Directory doesn't exist or can't be read
return []; return [];
} }
@ -228,7 +223,7 @@ export async function loadTodos(
const data = await readFile(filePath, 'utf-8'); const data = await readFile(filePath, 'utf-8');
const parsed = JSON.parse(data); const parsed = JSON.parse(data);
return TodoListSchema.parse(parsed); return TodoListSchema.parse(parsed);
} catch (error) { } catch (_error) {
// File doesn't exist or is invalid // File doesn't exist or is invalid
return null; return null;
} }

View File

@ -93,7 +93,7 @@ class FileSearcher {
return `**/${pattern}`; return `**/${pattern}`;
}); });
patterns.push(...adjustedPatterns); patterns.push(...adjustedPatterns);
} catch (error) { } catch (_error) {
// Silently ignore // Silently ignore
} }
} }

View File

@ -17,8 +17,6 @@ const TOOL_NAMES = {
IDLE: 'idleTool', IDLE: 'idleTool',
} as const; } as const;
type ToolName = (typeof TOOL_NAMES)[keyof typeof TOOL_NAMES];
/** /**
* Type guards for tool arguments and results * Type guards for tool arguments and results
*/ */