mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
Cmd click open finder (#3807)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
@@ -13,13 +13,26 @@ export const DirSwitcher: React.FC<DirSwitcherProps> = ({ className = '' }) => {
|
||||
window.electron.directoryChooser(true);
|
||||
};
|
||||
|
||||
const handleDirectoryClick = async (event: React.MouseEvent) => {
|
||||
const isCmdOrCtrlClick = event.metaKey || event.ctrlKey;
|
||||
|
||||
if (isCmdOrCtrlClick) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const workingDir = window.appConfig.get('GOOSE_WORKING_DIR') as string;
|
||||
await window.electron.openDirectoryInExplorer(workingDir);
|
||||
} else {
|
||||
await handleDirectoryChange();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip open={isTooltipOpen} onOpenChange={setIsTooltipOpen}>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
className={`z-[100] hover:cursor-pointer text-text-default/70 hover:text-text-default text-xs flex items-center transition-colors pl-1 [&>svg]:size-4 ${className}`}
|
||||
onClick={handleDirectoryChange}
|
||||
onClick={handleDirectoryClick}
|
||||
>
|
||||
<FolderDot className="mr-1" size={16} />
|
||||
<div className="max-w-[200px] truncate [direction:rtl]">
|
||||
|
||||
@@ -2212,6 +2212,15 @@ app.whenReady().then(async () => {
|
||||
ipcMain.on('get-app-version', (event) => {
|
||||
event.returnValue = app.getVersion();
|
||||
});
|
||||
|
||||
ipcMain.handle('open-directory-in-explorer', async (_event, path: string) => {
|
||||
try {
|
||||
return !!(await shell.openPath(path));
|
||||
} catch (error) {
|
||||
console.error('Error opening directory in explorer:', error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function getAllowList(): Promise<string[]> {
|
||||
|
||||
@@ -112,6 +112,7 @@ type ElectronAPI = {
|
||||
closeWindow: () => void;
|
||||
hasAcceptedRecipeBefore: (recipeConfig: Recipe) => Promise<boolean>;
|
||||
recordRecipeHash: (recipeConfig: Recipe) => Promise<boolean>;
|
||||
openDirectoryInExplorer: (directoryPath: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
type AppConfigAPI = {
|
||||
@@ -240,6 +241,8 @@ const electronAPI: ElectronAPI = {
|
||||
ipcRenderer.invoke('has-accepted-recipe-before', recipeConfig),
|
||||
recordRecipeHash: (recipeConfig: Recipe) =>
|
||||
ipcRenderer.invoke('record-recipe-hash', recipeConfig),
|
||||
openDirectoryInExplorer: (directoryPath: string) =>
|
||||
ipcRenderer.invoke('open-directory-in-explorer', directoryPath),
|
||||
};
|
||||
|
||||
const appConfigAPI: AppConfigAPI = {
|
||||
|
||||
Reference in New Issue
Block a user