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

Function openOnFirstEdit

mods/diff/hooks/register.ts:731–811  ·  view source on GitHub ↗
(engine: Host)

Source from the content-addressed store, hash-verified

729 }
730
731 async function openOnFirstEdit(engine: Host): Promise<void> {
732 const isTaken = () => isPaneOpen || hasAutoOpened
733
734 if (isTaken()) {
735 return
736 }
737
738 /**
739 * An ask after one that did not open the pane reads the repository again,
740 * so it waits like a read an edit or command causes. Asks made during the
741 * wait become one ask when it ends.
742 */
743 if (isAutoOpenPending && timers.has('rest')) {
744 isOpenAskKept = true
745 void endOverdueRest(engine)
746
747 return
748 }
749
750 isOpenAskKept = false
751
752 const closesBefore = personCloses
753 const preference = await engine.storeGet(Names.STORE_OPEN_KEY)
754 const isKeptOpen = preference === true
755
756 const floor = isKeptOpen
757 ? Limits.OPEN_MIN_COLUMNS
758 : Limits.AUTO_OPEN_MIN_COLUMNS
759
760 const hasRoom =
761 preference !== false &&
762 model.isFullscreen === true &&
763 columns !== null &&
764 columns >= floor
765
766 if (!hasRoom || isTaken()) {
767 return
768 }
769
770 const isCheckpointed = await engine.isCheckpointing().catch(() => true)
771
772 if (!isCheckpointed || isTaken()) {
773 return
774 }
775
776 await pinBackend(engine)
777
778 if (!backend || isTaken()) {
779 return
780 }
781
782 const landedBefore = landed
783 const { epoch } = pin
784
785 hasAutoOpened = true
786
787 const outcome = await openPane(engine, 'auto_open', closesBefore).catch(
788 (): OpenOutcome.OpenOutcome => 'withdrawn',

Callers 4

askKeptOpenFunction · 0.85
openOnRestoreFunction · 0.85
registerFunction · 0.85
afterToolFunction · 0.85

Calls 5

isTakenFunction · 0.85
endOverdueRestFunction · 0.85
pinBackendFunction · 0.85
openPaneFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected