diff --git a/src/components/tabs.tsx b/src/components/tabs.tsx index 294fa83..97a35f0 100644 --- a/src/components/tabs.tsx +++ b/src/components/tabs.tsx @@ -39,7 +39,8 @@ function Tab({ tid }: { tid: number }) { function revertTabsChildrenEvents() { if (tabDiv.current) { tabDiv.current.style.background = '' - const tabs = tabDiv.current.parentElement?.getElementsByClassName('tab') + const tabs = + tabDiv.current.parentElement?.getElementsByClassName('tab') for (const tab of tabs || []) { tab.childNodes.forEach((child) => { const childElement = child as HTMLElement @@ -113,7 +114,6 @@ function Tab({ tid }: { tid: number }) { ) } - function TabPath({ tid }: { tid: number }) { const tab = useAppSelector(getTab(tid)) const filePath = useAppSelector(getRelativeFilePath(tab.fileId)) @@ -144,12 +144,15 @@ function TabPath({ tid }: { tid: number }) { ) } -function TabRemainder({children}: {children: React.ReactNode}) { +function TabRemainder({ children }: { children: React.ReactNode }) { const containerDiv = useRef(null) function revertTabsChildrenEvents() { if (containerDiv.current) { containerDiv.current.style.background = '' - const tabs = containerDiv.current.parentElement?.getElementsByClassName('tab') + const tabs = + containerDiv.current.parentElement?.getElementsByClassName( + 'tab' + ) for (const tab of tabs || []) { tab.childNodes.forEach((child) => { const childElement = child as HTMLElement @@ -159,13 +162,14 @@ function TabRemainder({children}: {children: React.ReactNode}) { } } return ( -
{ event.preventDefault() if (containerDiv.current) { - containerDiv.current.style.background = 'rgba(255, 255, 255, 0.3)' + containerDiv.current.style.background = + 'rgba(255, 255, 255, 0.3)' containerDiv.current.childNodes.forEach((child) => { const childElement = child as HTMLElement childElement.style.pointerEvents = 'none' // we don't want onDragLeave event for tab children while reordering @@ -182,7 +186,7 @@ function TabRemainder({children}: {children: React.ReactNode}) { event.preventDefault() revertTabsChildrenEvents() // revert for new pane }} - > + > {children}
) @@ -274,7 +278,6 @@ export function TabBar({ )} - {activeTabId != null ? : null} diff --git a/src/components/terminal.tsx b/src/components/terminal.tsx index e19b51d..bfec742 100644 --- a/src/components/terminal.tsx +++ b/src/components/terminal.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useRef } from 'react' import { Terminal } from 'xterm' import { FitAddon } from 'xterm-addon-fit' -import { WebLinksAddon } from 'xterm-addon-web-links'; +import { WebLinksAddon } from 'xterm-addon-web-links' import 'xterm/css/xterm.css' import { useAppSelector, useAppDispatch } from '../app/hooks' import { FullState } from '../features/window/state' @@ -14,12 +14,12 @@ export function XTermComponent({ height }: { height: number }) { const terminalRef = useRef(null) const terminal = useRef(null) const fitAddon = useRef(new FitAddon()) - const webLinksAddon = useRef(new WebLinksAddon( - (event: MouseEvent, url: string) => { + const webLinksAddon = useRef( + new WebLinksAddon((event: MouseEvent, url: string) => { event.preventDefault() connector.terminalClickLink(url) - }, - )) + }) + ) const handleIncomingData = (e: any, data: any) => { terminal.current!.write(data) @@ -52,7 +52,6 @@ export function XTermComponent({ height }: { height: number }) { terminal.current.onData((e) => { connector.terminalInto(e) }) - connector.registerIncData(handleIncomingData) diff --git a/src/features/chat/chatSlice.ts b/src/features/chat/chatSlice.ts index c7e3453..d0ca469 100644 --- a/src/features/chat/chatSlice.ts +++ b/src/features/chat/chatSlice.ts @@ -104,8 +104,8 @@ export const chatSlice = createSlice({ newResponse( chatState: ChatState, action: PayloadAction<{ - type: BotMessageType, - useDiagnostics?: boolean | number, + type: BotMessageType + useDiagnostics?: boolean | number }> ) { if (action.payload.type === 'markdown') { @@ -491,6 +491,19 @@ export const chatSlice = createSlice({ // Bad - I added lots of tech debt today and will fix later lastBotMessage.maxOrigLine = action.payload }, + setHitTokenLimit( + chatState: ChatState, + action: PayloadAction<{ + conversationId: string + hitTokenLimit: boolean + }> + ) { + const lastBotMessage = getLastBotMessage( + chatState, + action.payload.conversationId + )! + lastBotMessage.hitTokenLimit = action.payload.hitTokenLimit + }, moveCommandBarHistory( chatState: ChatState, action: PayloadAction<'up' | 'down'> @@ -560,6 +573,7 @@ export const { startNewMessage, doSetMessages, doSetChatState, + setHitTokenLimit, _submitCommandBar: dummySubmitCommandBar, // Bad - I added tech debt and will fix later setMaxOrigLine, diff --git a/src/features/chat/chatThunks.ts b/src/features/chat/chatThunks.ts index 5cbb916..b603e5b 100644 --- a/src/features/chat/chatThunks.ts +++ b/src/features/chat/chatThunks.ts @@ -40,6 +40,7 @@ import { setChatOpen, setCurrentDraftMessage, setGenerating, + setHitTokenLimit, startNewMessage, toggleChatHistory, tokenLimitInterrupt, @@ -519,6 +520,7 @@ export const continueGeneration = createAsyncThunk( dispatch(openError(null)) dispatch(interruptGeneration(null)) } + dispatch(setHitTokenLimit({ conversationId, hitTokenLimit: false })) } } ) @@ -799,7 +801,12 @@ export const streamResponse = createAsyncThunk( const processResponse = async () => { let { value, buffer } = await getVariable('', 'type') checkSend() - dispatch(newResponse({ type: value.trim() as BotMessageType, useDiagnostics })) + dispatch( + newResponse({ + type: value.trim() as BotMessageType, + useDiagnostics, + }) + ) await sendBody(''!, value.trim()) if (value.trim() == 'location') { const state = getState() @@ -1322,13 +1329,13 @@ export const pressAICommand = createAsyncThunk( } return case 'k': - if (chatState.chatIsOpen && lastBotMessage?.finished) { - if (editorView) { - // When there is an editorView, we dispatch something - dispatch(changeMsgType('chat_edit')) - dispatch(changeDraftMsgType('chat_edit')) - } - } else if (editorView) { + // if (chatState.chatIsOpen && lastBotMessage?.finished) { + // if (editorView) { + // // When there is an editorView, we dispatch something + // dispatch(changeMsgType('chat_edit')) + // dispatch(changeDraftMsgType('chat_edit')) + // } + if (editorView) { const selPos = getSelectedPos(editorView) const selection = editorView.state.selection.main editorView.dispatch({ diff --git a/src/features/globalSlice.ts b/src/features/globalSlice.ts index 7fa08c6..5b4158c 100644 --- a/src/features/globalSlice.ts +++ b/src/features/globalSlice.ts @@ -1254,7 +1254,11 @@ const globalSlice = createSlice({ }, moveDraggingTabToPane( stobj: Object, - action: PayloadAction<{ paneId: number; hoverState: HoverState, tabPosition: number }> + action: PayloadAction<{ + paneId: number + hoverState: HoverState + tabPosition: number + }> ) { const state = stobj const { paneId, hoverState, tabPosition } = action.payload diff --git a/src/features/window/paneUtils.ts b/src/features/window/paneUtils.ts index d8f66bc..b59b22c 100644 --- a/src/features/window/paneUtils.ts +++ b/src/features/window/paneUtils.ts @@ -247,18 +247,25 @@ export function insertFirstPane(state: State) { return paneId } -export function doMoveTabToPane(state: State, tabId: number, paneId: number, tabPosition?: number) { +export function doMoveTabToPane( + state: State, + tabId: number, + paneId: number, + tabPosition?: number +) { const oldPaneId = state.tabs[tabId].paneId if (oldPaneId == null) return - const newPane = state.paneState.byIds[paneId] + const newPane = state.paneState.byIds[paneId] const tab = state.tabs[tabId] - const isNewPane = oldPaneId !== paneId; - const maybeTabId = newPane.tabIds.find(tabId => state.tabs[tabId].fileId === tab.fileId) - if ((maybeTabId != null) && isNewPane) { - deleteTab(state, tabId); - setActiveTab(state, maybeTabId); - return; + const isNewPane = oldPaneId !== paneId + const maybeTabId = newPane.tabIds.find( + (tabId) => state.tabs[tabId].fileId === tab.fileId + ) + if (maybeTabId != null && isNewPane) { + deleteTab(state, tabId) + setActiveTab(state, maybeTabId) + return } const oldPane = state.paneState.byIds[oldPaneId] @@ -268,14 +275,14 @@ export function doMoveTabToPane(state: State, tabId: number, paneId: number, tab setActiveTab(state, oldPane.tabIds[newIndex]) } oldPane.tabIds.splice(oldPane.tabIds.indexOf(tabId), 1) - + if (tabPosition !== undefined) { - if (isNewPane) { - tabPosition += 1 // adding to new pane the tabs count increases along with the position - } - newPane.tabIds.splice(tabPosition, 0, tabId) + if (isNewPane) { + tabPosition += 1 // adding to new pane the tabs count increases along with the position + } + newPane.tabIds.splice(tabPosition, 0, tabId) } else { - newPane.tabIds.push(tabId) + newPane.tabIds.push(tabId) } setPaneActive(state, paneId) diff --git a/src/main/main.ts b/src/main/main.ts index caed363..ff8d322 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -909,7 +909,7 @@ const createWindow = () => { // click on the terminal link ipcMain.handle('terminal-click-link', (event, data) => { - shell.openExternal(data); + shell.openExternal(data) }) setupLSPs(store) diff --git a/src/preload.ts b/src/preload.ts index b12ed42..9f24d30 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -189,7 +189,8 @@ const electronConnector = { ipcRenderer.removeListener('terminal-incData', callback) }, terminalInto: (data: any) => ipcRenderer.invoke('terminal-into', data), - terminalClickLink: (data: any) => ipcRenderer.invoke('terminal-click-link', data), + terminalClickLink: (data: any) => + ipcRenderer.invoke('terminal-click-link', data), terminalResize: (data: any) => ipcRenderer.invoke('terminal-resize', data), registerFileWasAdded: (callback: Callback) =>