Skip to content
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

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5afc528
Starting adding tab support, but cannot extend directly from history.
mohamedilaiwi Jun 18, 2024
90bc82a
Added tab support with highlighting
mohamedilaiwi Jun 19, 2024
94295d0
Making LLMSession more Generic
mohamedilaiwi Jun 22, 2024
87a6ae6
parsing bug with chat and format
Jun 22, 2024
25e9dd0
Need to resolve answering questions properly
milaiwi Jun 22, 2024
5f59c9b
Merge branch 'create-dir-files-on-rightclick'
milaiwi Jun 26, 2024
dde3f79
Merge branch 'main' into add-tab-support
milaiwi Jun 26, 2024
5b7665e
Added new tab support
milaiwi Jun 26, 2024
f254e94
Refined some code
mohamedilaiwi Jun 27, 2024
8eb8e84
Refined UI even more
mohamedilaiwi Jul 9, 2024
47667e2
Merging UI and Tab Support
mohamedilaiwi Jul 9, 2024
cee70b6
Merge branch 'add-tab-support' into ui-tab-support
mohamedilaiwi Jul 9, 2024
7c9a9b9
Merged with add-tab-support
mohamedilaiwi Jul 9, 2024
4f34822
Added Tab Support with more UI Changes
mohamedilaiwi Jul 9, 2024
13ae394
More changes to UI. Added Scrolling
mohamedilaiwi Jul 10, 2024
9b456f5
Tab better UI.Does not display + on null tabs. Shifts tabs on delete
mohamedilaiwi Jul 12, 2024
b1e17c2
Temp save
mohamedilaiwi Jul 13, 2024
b62e4e4
Mostly complete. Need to add name dropping on hover.
mohamedilaiwi Jul 15, 2024
bc51bd5
Added displaying tab path when hovering
mohamedilaiwi Jul 15, 2024
2e23e7d
Complete
mohamedilaiwi Jul 16, 2024
a9ce1bd
Changes needed
mohamedilaiwi Jul 16, 2024
b79d432
Completely fixed
mohamedilaiwi Jul 17, 2024
b5f38e9
Complete with fixed merge conflicts
mohamedilaiwi Jul 17, 2024
6f9c6a4
replaceWord added. cleaned up codebase
mohamedilaiwi Jul 21, 2024
df16e5d
Added replaceWord. Cleaned up codebase
mohamedilaiwi Jul 21, 2024
a1702d5
cleaned up sidebars. Final commit
milaiwi Jul 24, 2024
16589ff
Complete
milaiwi Jul 24, 2024
32a86f4
force line ending lf
samlhuillier Jul 29, 2024
66ba83c
test no notarize unless on main branch
samlhuillier Jul 29, 2024
3402938
update release notarize script
samlhuillier Jul 29, 2024
2bc39af
Revert "update release notarize script"
samlhuillier Jul 29, 2024
d6be068
notarize on release intentional
samlhuillier Jul 29, 2024
83478f3
Merge branch 'fix/test-line-endings' into ui-tab-backup
samlhuillier Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf

36 changes: 10 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,88 @@
name: Build and Package Electron App

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
build_and_package:
strategy:
matrix:
include:
- os: macos-13
# arch: x64
- os: macos-latest
# arch: arm64
- os: windows-latest
- os: ubuntu-latest
arch: x64

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Cache TypeScript build
uses: actions/cache@v3
with:
path: ./dist
key: ${{ runner.os }}-tsc-${{ hashFiles('**/tsconfig.json') }}
restore-keys: |
${{ runner.os }}-tsc-

- name: Install dependencies
run: npm install

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test

- name: Set up environment for macOS build
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
# APPLE_ID: ${{ secrets.APPLE_ID }}
# APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If you use GitHub token for auto-update
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build

- name: Build for non-macos
- name: Build for non-macOS
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
npm run build

- name: Notarize macOS build
if: (matrix.os == 'macos-13' || matrix.os == 'macos-latest') && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: npm run notarize
- name: Set version as env
run: echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Print APP_VERSION
run: echo "APP_VERSION=${{ env.APP_VERSION }}"

- name: List output files
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
ls ./release/${{ env.APP_VERSION }}/

- name: Check runner architecture
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: uname -m


- name: Rename artifacts for ARM architecture
if: matrix.os == 'macos-latest'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-arm64.dmg

- name: Rename artifacts for Intel architecture
if: matrix.os == 'macos-13'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-intel.dmg

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
35 changes: 11 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,77 @@
name: Release script

on:
push:
tags:
- "v*"

jobs:
build_and_package:
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- os: macos-13
# arch: x64
- os: macos-latest
# arch: arm64
- os: windows-latest
- os: ubuntu-latest
arch: x64
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Cache TypeScript build
uses: actions/cache@v3
with:
path: ./dist
key: ${{ runner.os }}-tsc-${{ hashFiles('**/tsconfig.json') }}
restore-keys: |
${{ runner.os }}-tsc-

- name: Install dependencies
run: npm install

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test

- name: Set up environment for macOS build
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If you use GitHub token for auto-update
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build

- name: Build for non-macos
if: matrix.os != 'macos-latest' && matrix.os != 'macos-latest-xlarge'
- name: Notarize macOS build
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: npm run notarize
- name: Build for non-macOS
if: matrix.os != 'macos-13' && matrix.os != 'macos-latest'
run: |
npm run build

- name: Set version as env
run: echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Rename artifacts for ARM architecture
if: matrix.os == 'macos-latest'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-arm64.dmg

- name: Rename artifacts for Intel architecture
if: matrix.os == 'macos-13'
run: |
mv ./release/${{ env.APP_VERSION }}/*.dmg ./release/${{ env.APP_VERSION }}/Reor_${{ env.APP_VERSION }}-intel.dmg

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -101,7 +89,6 @@ jobs:
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -110,4 +97,4 @@ jobs:
**/*.AppImage
**/*.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"trailingComma": "all",
"tabWidth": 2,
"semi": false,
"singleQuote": true
"singleQuote": true,
"endOfLine": "lf"
}
73 changes: 70 additions & 3 deletions electron/main/electron-store/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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))
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator Author

@milaiwi milaiwi Jul 30, 2024

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 think we should just have a standard default for things like padding so that we reduce user load in having to make decisions

I don't think this impacts user load that much.

Copy link
Collaborator

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"?

Copy link
Collaborator

@samlhuillier samlhuillier Jul 31, 2024

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?


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)
})
Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic: Potential issue: Ensure idx and newIndex are valid indices to avoid runtime errors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add the checking the bot recommends here @milaiwi ?

Copy link
Collaborator Author

@milaiwi milaiwi Jul 30, 2024

Choose a reason for hiding this comment

The 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 idx and newIndex not to be valid since tabId is guaranteed to exist which means idx and newIndex must exist.

}

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 {
Expand Down
13 changes: 13 additions & 0 deletions electron/main/electron-store/storeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export type HardwareConfig = {
useVulkan: boolean
}

export type Tab = {
id: string // Unique ID for the tab, useful for operations
filePath: string // Path to the file open in the tab
title: string // Title of the tab
lastAccessed: boolean
// timeOpened: Date; // Timestamp to preserve order
// isDirty: boolean; // Flag to indicate unsaved changes
}

export interface StoreSchema {
hasUserOpenedAppBefore: boolean
schemaVersion: number
Expand All @@ -72,6 +81,8 @@ export interface StoreSchema {
isSBCompact: boolean
DisplayMarkdown: boolean
spellCheck: string
EditorFlexCenter: boolean
OpenTabs: Tab[]
}

export enum StoreKeys {
Expand All @@ -91,4 +102,6 @@ export enum StoreKeys {
IsSBCompact = 'isSBCompact',
DisplayMarkdown = 'DisplayMarkdown',
SpellCheck = 'spellCheck',
EditorFlexCenter = 'editorFlexCenter',
OpenTabs = 'OpenTabs',
}
Loading
Loading