mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
* loop: worktree-tabs-2 completed after 4 iterations * loop: server-env-vars completed after 7 iterations * feat(worktree): add worktree tabs and server env vars settings * refactor(worktree): multi-directory SSE support and workspace chip row * feat(workspace): collapsible workspace manager and sibling filtering * feat(workspace): workspace creation endpoint, refactored workspace manager, and tests * refactor(frontend): unify workspace label and remove dead code - extract shared workspaceLabel helper into api/repos and reuse in WorkspaceManager and RepoDetail directoryLabels - remove unused useSessions hook and subscribeToDirectory subscription - drop redundant frontend workspace dedup now guaranteed by backend - align WorktreeTabs empty-state test with create-workspace button
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
export function getAssistantPath(): string {
|
|
return '/assistant';
|
|
}
|
|
|
|
export function getAssistantSessionListPath(): string {
|
|
return '/assistant?view=sessions';
|
|
}
|
|
|
|
export function isAssistantPath(pathname: string): boolean {
|
|
return pathname === '/assistant' || /^\/repos\/[^/]+\/assistant$/.test(pathname);
|
|
}
|
|
|
|
export function getSessionListPath(repoId: string | number, isAssistantSession: boolean, tab?: string): string {
|
|
if (isAssistantSession) {
|
|
return getAssistantSessionListPath();
|
|
}
|
|
const base = `/repos/${String(repoId)}`;
|
|
if (tab && tab !== 'repo') {
|
|
return `${base}?tab=${tab}`;
|
|
}
|
|
return base;
|
|
}
|
|
|
|
export function getSwipeBackTarget(pathname: string, search = ''): string | null {
|
|
const sessionDetailRegex = /^\/repos\/([^/]+)\/sessions\/[^/]+$/;
|
|
const match = pathname.match(sessionDetailRegex);
|
|
|
|
if (match) {
|
|
const repoId = match[1];
|
|
const params = new URLSearchParams(search);
|
|
const isAssistant = params.get('assistant') === '1';
|
|
const tab = params.get('tab') ?? undefined;
|
|
return getSessionListPath(repoId, isAssistant, tab);
|
|
}
|
|
|
|
if (isAssistantPath(pathname)) {
|
|
const params = new URLSearchParams(search);
|
|
if (params.get('view') !== 'sessions') {
|
|
return getAssistantSessionListPath();
|
|
}
|
|
return '/';
|
|
}
|
|
|
|
if (/^\/repos\/[^/]+$/.test(pathname)) {
|
|
return '/';
|
|
}
|
|
|
|
if (/^\/repos\/[^/]+\/schedules$/.test(pathname)) {
|
|
const repoId = pathname.split('/')[2];
|
|
if (repoId === '0') {
|
|
return getAssistantPath();
|
|
}
|
|
return `/repos/${repoId}`;
|
|
}
|
|
|
|
if (pathname === '/schedules') {
|
|
return '/';
|
|
}
|
|
|
|
if (pathname === '/' || pathname === '/login' || pathname === '/setup' || pathname === '/register') {
|
|
return null;
|
|
}
|
|
|
|
return null;
|
|
}
|