refactor: reduce cognitive complexity in AgentPanel (batch 3c) - #145
Merged
Conversation
Extract module-level helpers and sub-components to bring every function in AgentPanel.tsx below the CCN 20 threshold: - Extract handleTerminalEvent into applyTerminalEvent and event-specific handlers (applyOutputEvent, applyStartedEvent, etc.) - Extract agentLaunchCommand into claudeLaunchCommand/codexLaunchCommand - Extract terminalFromSaved into restoredTerminal* helpers - Extract normalizeSavedAgentTerminal into normalize* field helpers - Extract sendPrompt state update into appendPromptSentState - Extract startTerminal validation into resolveStartTerminalSource - Extract startTerminal params into startAgentTerminalParams - Extract stopTerminal, archiveTerminal, sendPrompt, runPaneShellCommand, startConversations, launchIndexedSession, attachExistingSession, openWorkItemConversation, restartTerminal to module-level functions - Extract AgentPanelHeader and AgentPanelContent sub-components from JSX - Extract SidebarTerminalRow and SidebarSessionRow from WorkConversationSidebar - Extract ConversationBlockView and SessionActionButton from WorkSessionView - Extract sessionStatusText, sessionDescriptionText, attentionButtonText, composerPlaceholder, computeIsThinking helpers from WorkSessionView - Extract canSubmitConversation, buildConversationSeeds, submitButtonText from ConversationStart - Extract terminalStatusDotClass, conversationStateTextClass, emptyNavigatorMessage helpers All 12 original complexity violations now resolved (0 remaining). Quality gates: lint PASS, typecheck PASS, complexity PASS (0 baseline exceptions).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentPanel.tsx(the final batch for Reduce the historical cognitive-complexity baseline #117)SidebarTerminalRow,SidebarSessionRow,ConversationBlockView,SessionActionButton,AgentPanelHeader,AgentPanelContent) to bring every function below CCN 20Verification
pnpm lint— PASSpnpm typecheck— PASSpnpm quality:complexity— PASS (0 violations)pnpm quality:knip— PASSPart of #117. Once merged, #117 can be closed.
Generated with Devin