mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
feat(frontend): consolidate session picker navigation and remote project loading
This commit is contained in:
1 parent
81fb2d4033
commit
52aeb7780f
42 files changed
+1486
-769
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { openCodeLocation, parseOpenCodeModelRef } from '@opencode-manager/shared/opencode'
|
||||
import { MANAGER_PROMPT_CLIENT_METADATA_KEY } from '@opencode-manager/shared/schemas'
|
||||
import { isMobileViewport } from '@/hooks/useMobile'
|
||||
import { getDirectoryName } from '@/lib/utils'
|
||||
import { callOpenCode } from './opencodeApi'
|
||||
import type {
|
||||
AgentInfo,
|
||||
@@ -37,10 +38,36 @@ export type OpenCodeLocationInfo = Awaited<ReturnType<OpenCodeApi['location']['g
|
||||
|
||||
export type OpenCodeProject = Awaited<ReturnType<OpenCodeApi['project']['list']>>[number]
|
||||
|
||||
/**
|
||||
* Returns the timestamp that represents a project's most recent activity.
|
||||
*
|
||||
* @param project Project whose activity time is read.
|
||||
* @returns The activity time, falling back to the last update when the project was never active.
|
||||
*/
|
||||
export function projectActivityTimestamp(project: OpenCodeProject): number {
|
||||
return project.time.active || project.time.updated
|
||||
}
|
||||
|
||||
/**
|
||||
* Orders projects from the most to the least recently active.
|
||||
*
|
||||
* @param projects Projects to order.
|
||||
* @returns A new array with the projects sorted by activity; the input is left untouched.
|
||||
*/
|
||||
export function sortProjectsByActivity(projects: OpenCodeProject[]): OpenCodeProject[] {
|
||||
return [...projects].sort((a, b) => projectActivityTimestamp(b) - projectActivityTimestamp(a))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of a project, falling back to the name of its directory.
|
||||
*
|
||||
* @param project Project whose name is resolved.
|
||||
* @returns The trimmed project name, or the last segment of its canonical directory.
|
||||
*/
|
||||
export function remoteProjectName(project: OpenCodeProject): string {
|
||||
return project.name?.trim() || getDirectoryName(project.canonical)
|
||||
}
|
||||
|
||||
export type VcsInfo = Awaited<ReturnType<OpenCodeApi['vcs']['get']>>['data']
|
||||
|
||||
export type VcsFileStatus = Awaited<ReturnType<OpenCodeApi['vcs']['status']>>['data'][number]
|
||||
|
||||
Reference in new issue
Block a user