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

Function togglePane

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

Source from the content-addressed store, hash-verified

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

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