-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI tab backup #319
UI tab backup #319
Changes from all commits
5afc528
90bc82a
94295d0
87a6ae6
25e9dd0
5f59c9b
dde3f79
5b7665e
f254e94
8eb8e84
47667e2
cee70b6
7c9a9b9
4f34822
13ae394
9b456f5
b1e17c2
b62e4e4
bc51bd5
2e23e7d
a9ce1bd
b79d432
b5f38e9
6f9c6a4
df16e5d
a1702d5
16589ff
32a86f4
66ba83c
3402938
2bc39af
d6be068
83478f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto eol=lf | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,17 @@ import path from 'path' | |
|
||
import { ipcMain } from 'electron' | ||
import Store from 'electron-store' | ||
|
||
import WindowsManager from '../common/windowManager' | ||
|
||
import { | ||
Tab, | ||
EmbeddingModelConfig, | ||
EmbeddingModelWithLocalPath, | ||
EmbeddingModelWithRepo, | ||
StoreKeys, | ||
StoreSchema, | ||
} from './storeConfig' | ||
|
||
import WindowsManager from '../common/windowManager' | ||
|
||
import { initializeAndMaybeMigrateStore } from './storeSchemaMigrator' | ||
import { ChatHistory } from '@/components/Chat/chatUtils' | ||
|
||
|
@@ -114,6 +115,13 @@ export const registerStoreHandlers = (store: Store<StoreSchema>, windowsManager: | |
|
||
ipcMain.handle('get-sb-compact', () => store.get(StoreKeys.IsSBCompact)) | ||
|
||
ipcMain.handle('get-editor-flex-center', () => store.get(StoreKeys.EditorFlexCenter)) | ||
|
||
ipcMain.handle('set-editor-flex-center', (event, setEditorFlexCenter) => { | ||
store.set(StoreKeys.EditorFlexCenter, setEditorFlexCenter) | ||
event.sender.send('editor-flex-center-changed', setEditorFlexCenter) | ||
}) | ||
|
||
ipcMain.handle('set-analytics-mode', (event, isAnalytics) => { | ||
store.set(StoreKeys.Analytics, isAnalytics) | ||
}) | ||
|
@@ -191,9 +199,68 @@ export const registerStoreHandlers = (store: Store<StoreSchema>, windowsManager: | |
const chatHistoriesMap = store.get(StoreKeys.ChatHistories) | ||
const allChatHistories = chatHistoriesMap[vaultDir] || [] | ||
const filteredChatHistories = allChatHistories.filter((item) => item.id !== chatID) | ||
|
||
chatHistoriesMap[vaultDir] = filteredChatHistories.reverse() | ||
store.set(StoreKeys.ChatHistories, chatHistoriesMap) | ||
}) | ||
|
||
ipcMain.handle('get-current-open-files', () => store.get(StoreKeys.OpenTabs) || []) | ||
|
||
ipcMain.handle('set-current-open-files', (event, action, args) => { | ||
const openTabs: Tab[] = store.get(StoreKeys.OpenTabs) || [] | ||
|
||
const addTab = ({ tab }: { tab: Tab }) => { | ||
if (tab === null) return | ||
const existingTab = openTabs.findIndex((item) => item.filePath === tab.filePath) | ||
|
||
/* If tab is already open, do not do anything */ | ||
if (existingTab !== -1) return | ||
|
||
openTabs.push(tab) | ||
store.set(StoreKeys.OpenTabs, openTabs) | ||
} | ||
|
||
const removeTab = ({ tabId, idx, newIndex }: { tabId: string; idx: number; newIndex: number }) => { | ||
openTabs[idx].lastAccessed = false | ||
openTabs[newIndex].lastAccessed = true | ||
const updatedTabs = openTabs.filter((tab) => tab.id !== tabId) | ||
store.set(StoreKeys.OpenTabs, updatedTabs) | ||
Comment on lines
+223
to
+227
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic: Potential issue: Ensure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add the checking the bot recommends here @milaiwi ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'll go ahead and add it, but either way I'm pretty sure it is not possible for |
||
} | ||
|
||
const clearAllTabs = () => { | ||
store.set(StoreKeys.OpenTabs, []) | ||
} | ||
|
||
const updateTab = ({ draggedIndex, targetIndex }: { draggedIndex: number; targetIndex: number }) => { | ||
// Swap dragged and target | ||
;[openTabs[draggedIndex], openTabs[targetIndex]] = [openTabs[targetIndex], openTabs[draggedIndex]] | ||
store.set(StoreKeys.OpenTabs, openTabs) | ||
} | ||
|
||
const selectTab = ({ tabs }: { tabs: Tab[] }) => { | ||
store.set(StoreKeys.OpenTabs, tabs) | ||
} | ||
|
||
switch (action) { | ||
case 'add': | ||
addTab(args) | ||
break | ||
case 'remove': | ||
removeTab(args) | ||
break | ||
case 'update': | ||
updateTab(args) | ||
break | ||
case 'select': | ||
selectTab(args) | ||
break | ||
case 'clear': | ||
clearAllTabs() | ||
break | ||
default: | ||
throw new Error('Unsupported action type') | ||
} | ||
}) | ||
} | ||
|
||
export function getDefaultEmbeddingModelConfig(store: Store<StoreSchema>): EmbeddingModelConfig { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what this feature does? I tried it in settings and didn't notice any changes in the editor nor anywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I now see a slight difference in padding - do you have strong opinions on adding this feature? I think it wouldn't really be clear to the user what "Editor Flex" is + I think we should just have a standard default for things like padding so that we reduce user load in having to make decisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference in padding depends on your screen size. On a Mac or small monitor, the difference is negligible. However, on a standard monitor (21–24 inches), like the one I use, it significantly impacts the UI. I can try to change the name and subcaption to make it more clearer.
I don't think this impacts user load that much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok sounds good. Why don't we even say something in the subcaption like "this is useful if you have a big monitor"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps there's even some kind of standard tailwind/css config for this kind of thing where you adjust padding based on screen size?