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

Function showUndoSelector

apps/kimi-code/src/tui/commands/undo.ts:127–161  ·  view source on GitHub ↗
(host: SlashCommandHost)

Source from the content-addressed store, hash-verified

125}
126
127async function showUndoSelector(host: SlashCommandHost): Promise<void> {
128 if (host.session === undefined) {
129 host.showError(NO_ACTIVE_SESSION_MESSAGE);
130 return;
131 }
132
133 const availability = await resolveUndoAvailability(host);
134 const choices = createUndoChoices(
135 host.state.transcriptEntries,
136 host.state.transcriptContainer.children,
137 availability.maxCount,
138 );
139 if (choices.length === 0) {
140 showUndoLimitStatus(host, formatNothingToUndoMessage(availability));
141 return;
142 }
143
144 host.mountEditorReplacement(
145 new UndoSelectorComponent({
146 choices,
147 onSelect: (choice) => {
148 void undoByCount(host, choice.count).then((undone) => {
149 if (undone) {
150 host.restoreInputText(choice.input);
151 return;
152 }
153 host.restoreEditor();
154 });
155 },
156 onCancel: () => {
157 host.restoreEditor();
158 },
159 }),
160 );
161}
162
163function parseUndoCount(args: string): number | undefined {
164 const value = args.trim();

Callers 1

handleUndoCommandFunction · 0.85

Calls 9

resolveUndoAvailabilityFunction · 0.85
createUndoChoicesFunction · 0.85
showUndoLimitStatusFunction · 0.85
undoByCountFunction · 0.85
showErrorMethod · 0.65
restoreInputTextMethod · 0.65
restoreEditorMethod · 0.65

Tested by

no test coverage detected