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: 0 additions & 3 deletions apps/desktop/src/lib/trpc/routers/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ export const createAuthRouter = () => {
emit.next(state);
};

// Send initial state
emit.next(authService.getState());

// Listen for changes
authService.on("state-changed", handler);

return () => {
Expand Down
5 changes: 0 additions & 5 deletions apps/desktop/src/main/lib/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { authService } from "./auth";
/**
* tRPC client for calling the Superset API
* Automatically includes the access token in requests
* Handles auth errors vs network errors:
* - 401/403: Token invalid/revoked, clears session
* - Network errors: Preserves session for offline work
*/
export const apiClient = createTRPCClient<AppRouter>({
links: [
Expand All @@ -29,15 +26,13 @@ export const apiClient = createTRPCClient<AppRouter>({
try {
const response = await globalThis.fetch(url, options);

// Handle auth errors - token was revoked/invalid on server
if (response.status === 401 || response.status === 403) {
console.log("[api-client] Auth error, clearing session");
await authService.signOut();
}

return response;
} catch (error) {
// Network errors - preserve session for offline work
console.log("[api-client] Network error, preserving session", error);
throw error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function OrganizationSwitcher() {

const initials = activeOrganization.name
?.split(" ")
.map((n: string) => n[0])
.map((n) => n[0])
.join("")
.toUpperCase()
.slice(0, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,61 @@ import { ChangesView } from "./ChangesView";
export function Sidebar() {
const { data: activeWorkspace } = trpc.workspaces.getActive.useQuery();
const workspaceId = activeWorkspace?.id;
const worktreePath = activeWorkspace?.worktreePath;

const addFileViewerPane = useTabsStore((s) => s.addFileViewerPane);
const trpcUtils = trpc.useUtils();

// Invalidate file content queries to ensure fresh data when clicking a file
const invalidateFileContent = (filePath: string) => {
if (!worktreePath) return;

Promise.all([
trpcUtils.changes.readWorkingFile.invalidate({
worktreePath,
filePath,
}),
trpcUtils.changes.getFileContents.invalidate({
worktreePath,
filePath,
}),
]).catch((error) => {
console.error(
"[Sidebar/invalidateFileContent] Failed to invalidate file content queries:",
{ worktreePath, filePath, error },
);
});
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Single click - opens in preview mode (can be replaced by next single click)
const handleFileOpen = workspaceId
? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => {
addFileViewerPane(workspaceId, {
filePath: file.path,
diffCategory: category,
commitHash,
oldPath: file.oldPath,
isPinned: false,
});
}
: undefined;
const handleFileOpen =
workspaceId && worktreePath
? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => {
addFileViewerPane(workspaceId, {
filePath: file.path,
diffCategory: category,
commitHash,
oldPath: file.oldPath,
isPinned: false,
});
invalidateFileContent(file.path);
}
: undefined;

// Double click - opens pinned (permanent, won't be replaced)
const handleFileOpenPinned = workspaceId
? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => {
addFileViewerPane(workspaceId, {
filePath: file.path,
diffCategory: category,
commitHash,
oldPath: file.oldPath,
isPinned: true,
});
}
: undefined;
const handleFileOpenPinned =
workspaceId && worktreePath
? (file: ChangedFile, category: ChangeCategory, commitHash?: string) => {
addFileViewerPane(workspaceId, {
filePath: file.path,
diffCategory: category,
commitHash,
oldPath: file.oldPath,
isPinned: true,
});
invalidateFileContent(file.path);
}
: undefined;

return (
<aside className="h-full flex flex-col overflow-hidden">
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/renderer/stores/tabs/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export const useTabsStore = create<TabsStore>()(
existingFileViewer.commitHash === options.commitHash;

if (isSameFile) {
// Pin the preview pane
set({
panes: {
...state.panes,
Expand Down
Loading