@thegitai/cli 1.0.0-preview.6 → 1.0.0-preview.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,7 +57,8 @@ const HELP_MARKDOWN = [
57
57
  '## Keys & clipboard',
58
58
  '',
59
59
  '- **Enter** sends • **Shift+Tab** cycles modes • **Esc** cancels the turn •',
60
- ' **Ctrl+C** quits. These are the same on macOS, Linux, and Windows.',
60
+ ' **Ctrl+C** clears the composer or the queued message, and quits once there',
61
+ ' is nothing left to clear. These are the same on macOS, Linux, and Windows.',
61
62
  `- **Paste** into the composer with your terminal's paste shortcut (\`${PASTE_SHORTCUT}\``,
62
63
  ' on this system) or by right-clicking the composer.',
63
64
  '- **Copy** from the transcript by dragging to select; double-click copies a',
@@ -405,15 +405,18 @@ function composerFooterLines(state) {
405
405
  }));
406
406
  return lines;
407
407
  }
408
+ const busyHelperText = state.queuedMessage
409
+ ? 'Enter re-queues • ↑ edit queued • Esc / Ctrl+C clear queued'
410
+ : state.input
411
+ ? 'Enter queues • Esc cancels turn • Ctrl+C clears draft'
412
+ : 'Enter queues • Esc / Ctrl+C cancel turn';
408
413
  const helperText = state.busy
409
- ? state.queuedMessage
410
- ? 'Enter re-queues • ↑ edit queued • Esc cancels queued'
411
- : 'Enter queues • Esc / Ctrl+C cancel turn'
414
+ ? busyHelperText
412
415
  : process.platform === 'win32'
413
- ? 'Enter sends • Shift+Tab mode • Alt+V image • Esc cancel turn • Ctrl+C quits'
416
+ ? 'Enter sends • Shift+Tab mode • Alt+V image • Esc cancel turn • Ctrl+C clears / quits'
414
417
  : process.platform === 'darwin'
415
- ? 'Enter sends • Shift+Tab mode • Ctrl+V image • Esc cancel turn • Ctrl+C quits'
416
- : 'Enter sends • Shift+Tab mode • Ctrl+V image • Esc cancel turn • Ctrl+C quits';
418
+ ? 'Enter sends • Shift+Tab mode • Ctrl+V image • Esc cancel turn • Ctrl+C clears / quits'
419
+ : 'Enter sends • Shift+Tab mode • Ctrl+V image • Esc cancel turn • Ctrl+C clears / quits';
417
420
  const agentLabel = agentModeLabel(state.agentMode).padEnd(AGENT_MODE_LABEL_WIDTH);
418
421
  const tokenUsageText = state.tokenUsage || formatClientTokenUsage(null);
419
422
  const footerSpans = [
@@ -9,6 +9,17 @@ function isClipboardImagePasteKey(key) {
9
9
  }
10
10
  return key.ctrl && key.input === 'v' && !key.shift && !key.meta;
11
11
  }
12
+ function composerIsEmpty(state) {
13
+ return (!state.input &&
14
+ state.cursor === 0 &&
15
+ state.pastedChunks.length === 0 &&
16
+ state.promptHistoryCursor === null);
17
+ }
18
+ function composerHasDiscardableDraft(state) {
19
+ if (!composerIsEmpty(state))
20
+ return true;
21
+ return !state.busy && state.imageAttachments.length > 0;
22
+ }
12
23
  function shouldShowCommandPalette(state) {
13
24
  if (state.busy ||
14
25
  state.exiting ||
@@ -132,11 +143,41 @@ export function handleShellKeyEvent(store, handlers, event) {
132
143
  return;
133
144
  const key = event;
134
145
  const state = store.getState();
146
+ const commandPaletteActive = shouldShowCommandPalette(state);
147
+ const commandSuggestions = commandPaletteActive
148
+ ? getSlashCommandSuggestions(state.input)
149
+ : [];
150
+ const prepareForComposerInputChange = (current, nextInput) => {
151
+ if (shouldRemountLiveFrameForComposerInputChange(current, nextInput)) {
152
+ handlers.onLiveFrameShapeChange();
153
+ }
154
+ };
135
155
  if (key.ctrl && key.input === 'c') {
136
156
  if (state.sudoPrompt) {
137
157
  handlers.onSudoPasswordInput({ kind: 'cancel' });
138
158
  return;
139
159
  }
160
+ if (state.queuedMessage) {
161
+ handlers.onLiveFrameShapeChange();
162
+ store.update((current) => ({ ...current, queuedMessage: null }));
163
+ return;
164
+ }
165
+ if (composerHasDiscardableDraft(state)) {
166
+ store.update((current) => {
167
+ prepareForComposerInputChange(current, '');
168
+ return {
169
+ ...current,
170
+ commandCursor: 0,
171
+ cursor: 0,
172
+ imageAttachments: current.busy ? current.imageAttachments : [],
173
+ input: '',
174
+ pastedChunks: [],
175
+ promptHistoryCursor: null,
176
+ promptHistoryDraft: '',
177
+ };
178
+ });
179
+ return;
180
+ }
140
181
  if (handlers.onCtrlC) {
141
182
  handlers.onCtrlC();
142
183
  return;
@@ -144,15 +185,6 @@ export function handleShellKeyEvent(store, handlers, event) {
144
185
  handlers.onRequestExit();
145
186
  return;
146
187
  }
147
- const commandPaletteActive = shouldShowCommandPalette(state);
148
- const commandSuggestions = commandPaletteActive
149
- ? getSlashCommandSuggestions(state.input)
150
- : [];
151
- const prepareForComposerInputChange = (current, nextInput) => {
152
- if (shouldRemountLiveFrameForComposerInputChange(current, nextInput)) {
153
- handlers.onLiveFrameShapeChange();
154
- }
155
- };
156
188
  if (state.sudoPrompt) {
157
189
  if (key.escape) {
158
190
  handlers.onSudoPasswordInput({ kind: 'cancel' });
@@ -317,10 +349,7 @@ export function handleShellKeyEvent(store, handlers, event) {
317
349
  return;
318
350
  }
319
351
  store.update((current) => {
320
- if (!current.input &&
321
- current.cursor === 0 &&
322
- current.pastedChunks.length === 0 &&
323
- current.promptHistoryCursor === null) {
352
+ if (composerIsEmpty(current)) {
324
353
  return current;
325
354
  }
326
355
  prepareForComposerInputChange(current, '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thegitai/cli",
3
- "version": "1.0.0-preview.6",
3
+ "version": "1.0.0-preview.7",
4
4
  "description": "TheGitAI is an AI coding agent for your terminal. It indexes your repository, writes and edits files, runs commands, and builds features with you.",
5
5
  "keywords": [
6
6
  "ai",
@@ -37,10 +37,10 @@
37
37
  "@lydell/node-pty-linux-x64": "1.1.0",
38
38
  "@lydell/node-pty-win32-arm64": "1.1.0",
39
39
  "@lydell/node-pty-win32-x64": "1.1.0",
40
- "@thegitai/tui-darwin-arm64": "1.0.0-preview.6",
41
- "@thegitai/tui-darwin-x64": "1.0.0-preview.6",
42
- "@thegitai/tui-linux-x64": "1.0.0-preview.6",
43
- "@thegitai/tui-win32-x64": "1.0.0-preview.6",
40
+ "@thegitai/tui-darwin-arm64": "1.0.0-preview.7",
41
+ "@thegitai/tui-darwin-x64": "1.0.0-preview.7",
42
+ "@thegitai/tui-linux-x64": "1.0.0-preview.7",
43
+ "@thegitai/tui-win32-x64": "1.0.0-preview.7",
44
44
  "@vscode/ripgrep": "1.18.0"
45
45
  },
46
46
  "publishConfig": {