MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / stop

Method stop

apps/kimi-code/src/tui/kimi-tui.ts:766–811  ·  view source on GitHub ↗
(exitCode?: number)

Source from the content-addressed store, hash-verified

764 }
765
766 async stop(exitCode?: number): Promise<void> {
767 if (this.isShuttingDown) return;
768 this.isShuttingDown = true;
769 this.unregisterSignalHandlers();
770 this.aborted = true;
771 this.streamingUI.discardPending();
772 // Stop background polling, streaming intervals, and per-component timers
773 // before tearing the UI down, so they can't keep firing requestRender after
774 // stop() returns (or leak when stop() runs without process.exit).
775 this.tasksBrowserController.close();
776 this.btwPanelController.clear();
777 this.stopActivitySpinner();
778 this.streamingUI.disposeActiveCompactionBlock();
779 this.streamingUI.resetToolUi();
780 this.disposeTranscriptChildren();
781 this.editorKeyboard.dispose();
782 this.state.footer.dispose();
783 for (const dispose of this.reverseRpcDisposers) {
784 dispose();
785 }
786 this.reverseRpcDisposers.length = 0;
787 this.disposeTerminalTracking();
788 // Restore the terminal even if closing the session / harness throws — a
789 // SIGTERM during a network or MCP shutdown must not leave the user stuck in
790 // raw mode with a hidden cursor.
791 try {
792 await this.closeSession('shutting down');
793 await this.harness.close();
794 } finally {
795 this.sessionEventHandler.stopAllMcpServerStatusSpinners();
796 this.uninstallRainbowDance();
797 try {
798 await this.state.terminal.drainInput();
799 } catch {
800 // best effort — the terminal may already be dead (SIGHUP / EIO).
801 }
802 try {
803 this.state.ui.stop();
804 } catch {
805 // best effort terminal restore.
806 }
807 }
808 if (this.onExit) {
809 await this.onExit(exitCode);
810 }
811 }
812
813 // SIGHUP / dead-terminal EIO → emergencyTerminalExit (no cleanup, avoids
814 // EIO write-loop that can pin a CPU core). SIGTERM → normal stop().

Callers 4

handlerMethod · 0.95
openSessionPickerMethod · 0.95

Calls 15

stopActivitySpinnerMethod · 0.95
closeSessionMethod · 0.95
discardPendingMethod · 0.80
resetToolUiMethod · 0.80
onExitMethod · 0.80
closeMethod · 0.65
clearMethod · 0.65

Tested by

no test coverage detected