Skip to content

refactor: reduce cognitive complexity in AgentPanel (batch 3c) - #145

Merged
sarthakagrawal927 merged 2 commits into
mainfrom
fix/reduce-complexity-batch3c
Aug 15, 2026
Merged

refactor: reduce cognitive complexity in AgentPanel (batch 3c)#145
sarthakagrawal927 merged 2 commits into
mainfrom
fix/reduce-complexity-batch3c

Conversation

@sarthakagrawal927

Copy link
Copy Markdown
Member

Summary

  • Resolves all 6 remaining cognitive complexity violations in AgentPanel.tsx (the final batch for Reduce the historical cognitive-complexity baseline #117)
  • Extracted module-level helpers and sub-components (SidebarTerminalRow, SidebarSessionRow, ConversationBlockView, SessionActionButton, AgentPanelHeader, AgentPanelContent) to bring every function below CCN 20
  • Pure refactoring — no behavior changes, no suppressions

Verification

  • pnpm lint — PASS
  • pnpm typecheck — PASS
  • pnpm quality:complexity — PASS (0 violations)
  • pnpm quality:knip — PASS

Part of #117. Once merged, #117 can be closed.

Generated with Devin

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).
@sarthakagrawal927
sarthakagrawal927 merged commit 45d2755 into main Aug 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant