MCPcopy Create free account
hub / github.com/anthropics/claude-code / togglePane

Function togglePane

mods/diff/hooks/register.ts:1106–1174  ·  view source on GitHub ↗
(
    engine: Host,
    presentation: Args<'command.run'>['presentation'],
  )

Source from the content-addressed store, hash-verified

1104 })
1105
1106 async function togglePane(
1107 engine: Host,
1108 presentation: Args<'command.run'>['presentation'],
1109 ): Promise<ResultOf['command.run']> {
1110 if (!isPaneOpen) {
1111 if (model.unknownReason !== null) {
1112 unpin()
1113 model = { ...model, unknownReason: null }
1114 }
1115
1116 const isAnswered =
1117 (await pinBackend(engine, true)) || (await pinBackend(engine, true))
1118
1119 if (!backend) {
1120 return {
1121 text: isAnswered
1122 ? Names.NOT_IN_REPOSITORY_TEXT
1123 : Names.GIT_UNANSWERED_TEXT,
1124 }
1125 }
1126 }
1127
1128 const { isFullscreen } = presentation
1129
1130 columns = presentation.columns
1131 model = { ...model, isFullscreen }
1132
1133 const toggle = PaneToggle.paneToggleOf({
1134 isOpen: isPaneOpen,
1135 columns: isFullscreen ? columns : null,
1136 })
1137
1138 if (toggle === 'too-narrow') {
1139 return { text: Names.RESIZE_TERMINAL_TEXT }
1140 }
1141
1142 const isOpening = toggle === 'open'
1143
1144 if (!isOpening) {
1145 personCloses += 1
1146 hasAutoOpened = true
1147 }
1148
1149 const outcome = isOpening
1150 ? await openPane(engine, 'manual')
1151 : await closePane(engine).then(() => 'placed' as const)
1152
1153 if (outcome === 'withdrawn') {
1154 return { text: Names.RESIZE_TERMINAL_TEXT }
1155 }
1156
1157 if (outcome === 'awaited') {
1158 return { text: Names.AWAITS_SURFACE_TEXT }
1159 }
1160
1161 if (!isFullscreen) {
1162 return isOpening ? {} : { text: Names.DIALOG_DISMISSED_TEXT }
1163 }

Callers 1

registerFunction · 0.85

Calls 5

unpinFunction · 0.85
pinBackendFunction · 0.85
openPaneFunction · 0.85
closePaneFunction · 0.85
markTabSwitchFunction · 0.85

Tested by

no test coverage detected