mirror of
https://github.com/BloopAI/vibe-kanban.git
synced 2026-11-20 22:40:25 +00:00
* Keep project layout when opening issue workspaces * Render conversation history in project workspace sidebar * Add project sidebar conversation header and controls * Cleanup script changes for workspace 9f10df59-6778-459f-aa62-422c442e9d0b * Make project sidebar breadcrumbs clickable and consistent * I’m starting the code edits now: adding the new route, extending `useKanbanNavigation` with `workspaceId` support, and removing local `workspace-session` mode so sidebar session rendering is URL-driven. * Route project workspace sidebar via issue workspace URL * Cleanup script changes for workspace 9f10df59-6778-459f-aa62-422c442e9d0b * Fix project sidebar close action and align issue header breadcrumb styling * Cleanup script changes for workspace 9f10df59-6778-459f-aa62-422c442e9d0b * Use ArrowsOut icon in project conversation header * Fix container prop lint in create chat workspace flow * Show Open Workspace button in project session chat header * Cleanup script changes for workspace 9f10df59-6778-459f-aa62-422c442e9d0b * Add closable header for project sidebar workspace create flow * Cleanup script changes for workspace 9f10df59-6778-459f-aa62-422c442e9d0b * Fix create sidebar issue breadcrumb to exit create mode * Fix project sidebar create header i18n literal
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { tasksApi, attemptsApi } from '@/lib/api';
|
|
import { taskKeys } from './useTask';
|
|
import { taskRelationshipsKeys } from './useTaskRelationships';
|
|
import { workspaceSummaryKeys } from '@/components/ui-new/hooks/useWorkspaces';
|
|
import type { CreateAndStartTaskRequest } from 'shared/types';
|
|
|
|
interface CreateWorkspaceParams {
|
|
data: CreateAndStartTaskRequest;
|
|
linkToIssue?: {
|
|
remoteProjectId: string;
|
|
issueId: string;
|
|
};
|
|
}
|
|
|
|
interface UseCreateWorkspaceOptions {
|
|
onWorkspaceCreated?: (workspaceId: string) => void;
|
|
}
|
|
|
|
export function useCreateWorkspace(options: UseCreateWorkspaceOptions = {}) {
|
|
const { onWorkspaceCreated } = options;
|
|
const queryClient = useQueryClient();
|
|
const navigate = useNavigate();
|
|
|
|
const createWorkspace = useMutation({
|
|
mutationFn: async ({ data, linkToIssue }: CreateWorkspaceParams) => {
|
|
const task = await tasksApi.createAndStart(data);
|
|
const workspaces = await attemptsApi.getAll(task.id);
|
|
const workspaceId = workspaces[0]?.id;
|
|
|
|
// Link to issue if requested
|
|
if (linkToIssue && workspaceId) {
|
|
await attemptsApi.linkToIssue(
|
|
workspaceId,
|
|
linkToIssue.remoteProjectId,
|
|
linkToIssue.issueId
|
|
);
|
|
}
|
|
|
|
return { task, workspaceId };
|
|
},
|
|
onSuccess: ({ task, workspaceId }) => {
|
|
// Invalidate task queries
|
|
queryClient.invalidateQueries({ queryKey: taskKeys.all });
|
|
|
|
// Invalidate workspace summaries so they refresh with the new workspace included
|
|
queryClient.invalidateQueries({ queryKey: workspaceSummaryKeys.all });
|
|
|
|
// Invalidate parent's relationships cache if this is a subtask
|
|
if (task.parent_workspace_id) {
|
|
queryClient.invalidateQueries({
|
|
queryKey: taskRelationshipsKeys.byAttempt(task.parent_workspace_id),
|
|
});
|
|
}
|
|
|
|
// Navigate to the new workspace (or let caller handle in project sidebar)
|
|
if (workspaceId) {
|
|
if (onWorkspaceCreated) {
|
|
onWorkspaceCreated(workspaceId);
|
|
} else {
|
|
navigate(`/workspaces/${workspaceId}`);
|
|
}
|
|
}
|
|
},
|
|
onError: (err) => {
|
|
console.error('Failed to create workspace:', err);
|
|
},
|
|
});
|
|
|
|
return { createWorkspace };
|
|
}
|