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

enhancement: default open Jan Input Box Settings and Right panel #4234

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions web/containers/Providers/Responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ const Responsive = () => {
const [showRightPanel, setShowRightPanel] = useAtom(showRightPanelAtom)

// Refs to store the last known state of the panels
const lastLeftPanelState = useRef<boolean>(true)
const lastRightPanelState = useRef<boolean>(true)
const lastLeftPanelState = useRef<boolean>(showLeftPanel)
const lastRightPanelState = useRef<boolean>(showRightPanel)

useEffect(() => {
if (matches) {
// Store the last known state before closing the panels
lastLeftPanelState.current = showLeftPanel
lastRightPanelState.current = showRightPanel

setShowLeftPanel(false)
setShowRightPanel(false)
} else {
Expand Down
13 changes: 12 additions & 1 deletion web/helpers/atoms/App.atom.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { atom } from 'jotai'

import { atomWithStorage } from 'jotai/utils'

import { MainViewState } from '@/constants/screens'

export const mainViewStateAtom = atom<MainViewState>(MainViewState.Thread)

export const defaultJanDataFolderAtom = atom<string>('')

const SHOW_RIGHT_PANEL = 'showRightPanel'

// Store panel atom
export const showLeftPanelAtom = atom<boolean>(true)
export const showRightPanelAtom = atom<boolean>(true)

export const showRightPanelAtom = atomWithStorage<boolean>(
SHOW_RIGHT_PANEL,
false,
undefined,
{ getOnInit: true }
)

export const showSystemMonitorPanelAtom = atom<boolean>(false)
export const appDownloadProgressAtom = atom<number>(-1)
export const updateVersionErrorAtom = atom<string | undefined>(undefined)
2 changes: 1 addition & 1 deletion web/helpers/atoms/Thread.atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@
* Get the active thread state
*/
export const activeThreadStateAtom = atom<ThreadState | undefined>((get) => {
const threadId = get(activeThreadIdAtom)
if (!threadId) {
console.debug('Active thread id is undefined')
return undefined

Check warning on line 93 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

90-93 lines are not covered with tests
}

return get(threadStatesAtom)[threadId]

Check warning on line 96 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

96 line is not covered with tests
})

/**
Expand All @@ -107,7 +107,7 @@
return undefined
}

return get(threadModelParamsAtom)[threadId]

Check warning on line 110 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

110 line is not covered with tests
}
)
/// End Active Thread Atom
Expand Down Expand Up @@ -143,13 +143,13 @@
export const updateThreadWaitingForResponseAtom = atom(
null,
(get, set, threadId: string, waitingForResponse: boolean) => {
const currentState = { ...get(threadStatesAtom) }
currentState[threadId] = {

Check warning on line 147 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

146-147 lines are not covered with tests
...currentState[threadId],
waitingForResponse,
error: undefined,
}
set(threadStatesAtom, currentState)

Check warning on line 152 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

152 line is not covered with tests
}
)

Expand All @@ -159,13 +159,13 @@
export const updateThreadStateLastMessageAtom = atom(
null,
(get, set, threadId: string, lastContent?: ThreadContent[]) => {
const currentState = { ...get(threadStatesAtom) }
const lastMessage = lastContent?.[0]?.text?.value ?? ''
currentState[threadId] = {

Check warning on line 164 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

162-164 lines are not covered with tests
...currentState[threadId],
lastMessage,
}
set(threadStatesAtom, currentState)

Check warning on line 168 in web/helpers/atoms/Thread.atom.ts

View workflow job for this annotation

GitHub Actions / coverage-check

168 line is not covered with tests
}
)

Expand Down Expand Up @@ -207,7 +207,7 @@
*/
export const activeSettingInputBoxAtom = atomWithStorage<boolean>(
ACTIVE_SETTING_INPUT_BOX,
false,
true,
undefined,
{ getOnInit: true }
)
Expand Down
Loading