MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / createUpdatedBlock

Function createUpdatedBlock

cli/src/utils/collapse-helpers.ts:65–89  ·  view source on GitHub ↗

* Creates an updated block with new collapsed state if different from current. * Returns null if no change is needed. * Thinking blocks use thinkingCollapseState; others use isCollapsed.

(
  block: CollapsibleBlock,
  collapsed: boolean,
)

Source from the content-addressed store, hash-verified

63 * Thinking blocks use thinkingCollapseState; others use isCollapsed.
64 */
65function createUpdatedBlock(
66 block: CollapsibleBlock,
67 collapsed: boolean,
68): CollapsibleBlock | null {
69 if (isThinkingTextBlock(block)) {
70 const targetState: ThinkingCollapseState = collapsed ? 'hidden' : 'expanded'
71 if (block.thinkingCollapseState === targetState) {
72 return null
73 }
74 return {
75 ...block,
76 thinkingCollapseState: targetState,
77 userOpened: !collapsed ? true : block.userOpened,
78 }
79 }
80 const currentCollapsed = getBlockCollapsedState(block)
81 if (currentCollapsed === collapsed) {
82 return null
83 }
84 return {
85 ...block,
86 isCollapsed: collapsed,
87 userOpened: !collapsed ? true : block.userOpened,
88 }
89}
90
91/**
92 * Checks if any collapsible block in the given blocks array is expanded.

Callers 1

updateBlocksRecursivelyFunction · 0.85

Calls 2

isThinkingTextBlockFunction · 0.85
getBlockCollapsedStateFunction · 0.85

Tested by

no test coverage detected