Skip to content

Commit fdb18ef

Browse files
committed
fix(ai): skip fixing terminated command
1 parent c9ab88f commit fdb18ef

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

addons/ai/src/renderer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default () => {
2828
status
2929
&& command.command
3030
&& command.exitCode
31+
&& commas.workspace.isErrorExitCode(command.exitCode)
3132
&& !command.actions?.length
3233
) {
3334
const recommendation = await ipcRenderer.invoke('ai-fix', command.command, output)

src/api/modules/workspace.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
useTerminalTabGroupSeparating,
2020
useTerminalTabs,
2121
} from '../../renderer/compositions/terminal'
22-
import { createTerminalTabContextMenu, getTerminalExecutorCommand, TERMINAL_DIRECTORY_SHELL } from '../../renderer/utils/terminal'
22+
import { createTerminalTabContextMenu, getTerminalExecutorCommand, isErrorExitCode, TERMINAL_DIRECTORY_SHELL } from '../../renderer/utils/terminal'
2323
import type { RendererAPIContext } from '../types'
2424

2525
const tabs = $(useTerminalTabs())
@@ -160,4 +160,5 @@ export {
160160
TERMINAL_DIRECTORY_SHELL,
161161
useReadonlyTerminal,
162162
getTerminalExecutorCommand,
163+
isErrorExitCode,
163164
}

src/renderer/utils/shell-integration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getCursorPosition, scrollToMarker } from '../compositions/terminal'
1212
import { useTheme } from '../compositions/theme'
1313
import { openContextMenu } from './frame'
1414
import { translate } from './i18n'
15-
import { getReadableSignal } from './terminal'
15+
import { getReadableSignal, isErrorExitCode } from './terminal'
1616

1717
declare module '@commas/api/modules/app' {
1818
export interface Events {
@@ -248,7 +248,7 @@ export class ShellIntegrationAddon implements ITerminalAddon {
248248
if (!this.currentCommand.marker.isDisposed) {
249249
const theme = useTheme()
250250
this.currentCommand.decoration.dispose()
251-
const shouldHighlight = exitCode > 0 && exitCode < 128 && settings['terminal.shell.highlightErrors']
251+
const shouldHighlight = isErrorExitCode(exitCode) && settings['terminal.shell.highlightErrors']
252252
if (shouldHighlight) {
253253
this._createHighlightDecoration(
254254
xterm,
@@ -599,7 +599,7 @@ export class ShellIntegrationAddon implements ITerminalAddon {
599599
}
600600

601601
_generateQuickFixActions(command: IntegratedShellCommand | undefined) {
602-
if (command?.command && command.exitCode) {
602+
if (command?.command && command.exitCode && isErrorExitCode(command.exitCode)) {
603603
const output = this._getCommandOutput(command)
604604
return this._getQuickFixActionsByOutput(command.command, output)
605605
}

src/renderer/utils/terminal.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ export function getTerminalTabID(tab: TerminalTab) {
145145
}
146146
}
147147

148+
export function isErrorExitCode(code: number) {
149+
return code > 0 && code < 128
150+
}
151+
148152
export function getReadableSignal(code: number) {
149153
if (code > 128 && code < 256) {
150154
return Object.entries(os.constants.signals)

0 commit comments

Comments
 (0)