mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-02 22:40:22 +00:00
fix(app): navigate to last session on project nav
This commit is contained in:
parent
08a2d002b8
commit
6b8902e8b9
3 changed files with 69 additions and 3 deletions
|
|
@ -61,6 +61,7 @@ import {
|
|||
displayName,
|
||||
errorMessage,
|
||||
getDraggableId,
|
||||
projectSessionTarget,
|
||||
sortedRootSessions,
|
||||
syncWorkspaceOrder,
|
||||
workspaceKey,
|
||||
|
|
@ -82,6 +83,7 @@ export default function Layout(props: ParentProps) {
|
|||
Persist.global("layout.page", ["layout.page.v1"]),
|
||||
createStore({
|
||||
lastSession: {} as { [directory: string]: string },
|
||||
lastSessionAt: {} as { [directory: string]: number },
|
||||
activeProject: undefined as string | undefined,
|
||||
activeWorkspace: undefined as string | undefined,
|
||||
workspaceOrder: {} as Record<string, string[]>,
|
||||
|
|
@ -1077,8 +1079,16 @@ export default function Layout(props: ParentProps) {
|
|||
function navigateToProject(directory: string | undefined) {
|
||||
if (!directory) return
|
||||
server.projects.touch(directory)
|
||||
const lastSession = store.lastSession[directory]
|
||||
navigateWithSidebarReset(`/${base64Encode(directory)}${lastSession ? `/session/${lastSession}` : ""}`)
|
||||
const project = layout.projects
|
||||
.list()
|
||||
.find((item) => item.worktree === directory || item.sandboxes?.includes(directory))
|
||||
const target = projectSessionTarget({
|
||||
directory,
|
||||
project,
|
||||
lastSession: store.lastSession,
|
||||
lastSessionAt: store.lastSessionAt,
|
||||
})
|
||||
navigateWithSidebarReset(`/${base64Encode(target.directory)}${target.id ? `/session/${target.id}` : ""}`)
|
||||
}
|
||||
|
||||
function navigateToSession(session: Session | undefined) {
|
||||
|
|
@ -1433,6 +1443,7 @@ export default function Layout(props: ParentProps) {
|
|||
const directory = decode64(dir)
|
||||
if (!directory) return
|
||||
setStore("lastSession", directory, id)
|
||||
setStore("lastSessionAt", directory, Date.now())
|
||||
notification.session.markViewed(id)
|
||||
const expanded = untrack(() => store.workspaceExpanded[directory])
|
||||
if (expanded === false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue