Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/code-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ jobs:
- name: Publish GitHub release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: gh release edit "v${{ steps.version.outputs.version }}" --repo PostHog/code --draft=false
APP_VERSION: ${{ steps.version.outputs.version }}
run: gh release edit "v$APP_VERSION" --repo PostHog/code --draft=false
8 changes: 7 additions & 1 deletion apps/code/src/renderer/components/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useTaskDeepLink } from "../hooks/useTaskDeepLink";
import { GlobalEventHandlers } from "./GlobalEventHandlers";

export function MainLayout() {
const { view, hydrateTask } = useNavigationStore();
const { view, hydrateTask, navigateToTaskInput } = useNavigationStore();
const {
isOpen: commandMenuOpen,
setOpen: setCommandMenuOpen,
Expand All @@ -47,6 +47,12 @@ export function MainLayout() {
}
}, [tasks, hydrateTask]);

useEffect(() => {
if (view.type === "task-detail" && !view.data && !view.taskId) {
navigateToTaskInput();
}
}, [view, navigateToTaskInput]);

const handleToggleCommandMenu = useCallback(() => {
toggleCommandMenu();
}, [toggleCommandMenu]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function CodePreview({
highlightChanges: false,
gutter: false,
mergeControls: false,
collapseUnchanged: { margin: 3, minSize: 4 },
}),
]
: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ export function TaskListView({
f.remoteUrl?.toLowerCase() === group.id.toLowerCase() ||
f.path === group.id,
);
const groupFolderId =
folder?.id ?? group.tasks.find((t) => t.folderId)?.folderId;
return (
<DraggableFolder key={group.id} id={group.id} index={index}>
<SidebarSection
Expand All @@ -335,8 +337,8 @@ export function TaskListView({
addSpacingBefore={false}
tooltipContent={folder?.path ?? group.id}
onNewTask={() => {
if (folder) {
navigateToTaskInput(folder.id);
if (groupFolderId) {
navigateToTaskInput(groupFolderId);
} else {
navigateToTaskInput();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TaskData {
isPinned: boolean;
needsPermission: boolean;
repository: TaskRepositoryInfo | null;
folderId?: string;
taskRunStatus?:
| "started"
| "in_progress"
Expand Down Expand Up @@ -203,6 +204,7 @@ export function useSidebarData({
isPinned: pinnedTaskIds.has(task.id),
needsPermission: (session?.pendingPermissions?.size ?? 0) > 0,
repository: getRepositoryInfo(task, workspace?.folderPath),
folderId: workspace?.folderId || undefined,
taskRunStatus: task.latest_run?.status,
taskRunEnvironment: task.latest_run?.environment,
};
Expand Down
12 changes: 12 additions & 0 deletions apps/code/src/renderer/features/task-detail/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useAuthStore } from "@features/auth/stores/authStore";
import { useDraftStore } from "@features/message-editor/stores/draftStore";
import { useSettingsStore } from "@features/settings/stores/settingsStore";
import { workspaceApi } from "@features/workspace/hooks/useWorkspace";
import type { Workspace } from "@main/services/workspace/schemas";
import type { SagaResult } from "@posthog/shared";
import {
type TaskCreationInput,
Expand Down Expand Up @@ -60,6 +61,7 @@ export class TaskService {
const result = await saga.run(input);

if (result.success) {
this.optimisticallyUpdateWorkspaceCache(result.data);
this.updateStoresOnSuccess(result.data, input);
void queryClient.invalidateQueries({
queryKey: [["workspace", "getAll"]],
Expand Down Expand Up @@ -124,6 +126,7 @@ export class TaskService {
const result = await saga.run({ taskId });

if (result.success) {
this.optimisticallyUpdateWorkspaceCache(result.data);
this.updateStoresOnSuccess(result.data);
void queryClient.invalidateQueries({
queryKey: [["workspace", "getAll"]],
Expand Down Expand Up @@ -151,6 +154,15 @@ export class TaskService {
return result;
}

private optimisticallyUpdateWorkspaceCache(output: TaskCreationOutput): void {
if (!output.workspace) return;
const workspace = output.workspace;
queryClient.setQueriesData<Record<string, Workspace>>(
{ queryKey: [["workspace", "getAll"]] },
(old) => ({ ...old, [output.task.id]: workspace }),
);
}

/**
* Batch update stores after successful task creation/open.
*/
Expand Down
Loading