Skip to content

Commit

Permalink
fix(clone): clone examples/sponsors with invoke. Fix choice truncate.…
Browse files Browse the repository at this point in the history
… Detach dev tools
  • Loading branch information
johnlindquist committed Dec 18, 2024
1 parent 1316c5f commit 8d880ba
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 19 deletions.
17 changes: 15 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ const isNewVersion = async () => {

const setupScript = (...args: string[]) => {
if (process.env.MAIN_SKIP_SETUP) {
log.info('⏭️ Skipping setupScript', args);
log.info(`⏭️ 'process.env.MAIN_SKIP_SETUP' Skipping setupScript`, args);
return;
}
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -1026,8 +1026,21 @@ const checkKit = async () => {
if (!isKenvInstalled) {
log.info('Cloning examples...');
optionalSetupScript(kitPath('setup', 'clone-examples.js'));
invoke('git clone git://github.com/johnlindquist/kit-examples-ts.git examples', kenvPath('kenvs'))
.then((result) => {
log.info('👍 Examples Cloned', result);
})
.catch((error) => {
log.warn('👎 Examples Cloning Failed', error);
});
log.info('Cloning sponsors...');
optionalSetupScript(kitPath('setup', 'clone-sponsors.js'));
invoke('git clone git://github.com/johnlindquist/kit-sponsors.git sponsors', kenvPath('kenvs'))
.then((result) => {
log.info('👍 Sponsors Cloned', result);
})
.catch((error) => {
log.warn('👎 Sponsors Cloning Failed', error);
});
}

// await installLoaderTools();
Expand Down
2 changes: 1 addition & 1 deletion src/main/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ export const requiredSpawnSetup = (command: string, args: string[], options: Spa

export const optionalSpawnSetup = (...args: string[]) => {
if (process.env.MAIN_SKIP_SETUP) {
log.info(`⏭️ Skipping setup script: ${args.join(' ')}`);
log.info(`⏭️ 'process.env.MAIN_SKIP_SETUP' Skipping setup script: ${args.join(' ')}`);
return Promise.resolve('done');
}
return new Promise((resolve, reject) => {
Expand Down
4 changes: 0 additions & 4 deletions src/main/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ log.info(`
���🟢 🟢 !!!SCRIPT KIT TIME!!! 🟢 🟢 🟢 `);

log.info('Skipping Setup?', {
MAIN_SKIP_SETUP: process.env.MAIN_SKIP_SETUP,
});

export interface Logger {
info: (...args: string[]) => void;
warn: (...args: string[]) => void;
Expand Down
4 changes: 3 additions & 1 deletion src/main/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,9 @@ export const createMessageMap = (processInfo: ProcessAndPrompt) => {
}),
OPEN_DEV_TOOLS: onChildChannel(({ child }, { channel, value }) => {
if (prompt.window) {
prompt.window.webContents.openDevTools();
prompt.window.webContents.openDevTools({
mode: 'detach',
});
}
}),
START_DRAG: onChildChannel(({ child }, { channel, value }) => {
Expand Down
17 changes: 16 additions & 1 deletion src/main/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ contextMenu({
showSearchWithGoogle: false,
showLookUpSelection: false,
append: (defaultActions, params, browserWindow) => [
{
label: 'Detach Dev Tools',
click: async () => {
if ((browserWindow as BrowserWindow)?.id) {
log.info(`Inspect prompt: ${browserWindow?.id}`, {
browserWindow,
});
prompts
.find((prompt) => prompt?.window?.id === browserWindow?.id)
?.window?.webContents?.openDevTools({
mode: 'detach',
});
}
},
},
{
label: 'Close',
click: async () => {
Expand Down Expand Up @@ -1885,7 +1900,7 @@ export class KitPrompt {
env: promptData.env || {},
};

log.info(`termConfig`, termConfig);
// log.info(`termConfig`, termConfig);
this.sendToPrompt(AppChannel.SET_TERM_CONFIG, termConfig);
createPty(this);
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ export const showWidget = async (
center: options?.center,
options: JSON.stringify(options),
});

const position = options?.center
? getCenterOnCurrentScreen(options as BrowserWindowConstructorOptions)
: getTopRightCurrentScreen(options as BrowserWindowConstructorOptions);

log.info(`📍 Calculated position`, { position });

const bwOptions: BrowserWindowConstructorOptions = {
Expand Down Expand Up @@ -479,7 +479,9 @@ export const showWidget = async (
log.info(`🛠️ Opening DevTools`, {
windowId: widgetWindow.id,
});
widgetWindow?.webContents.openDevTools();
widgetWindow?.webContents.openDevTools({
mode: 'detach',
});
}

resolve(widgetWindow);
Expand Down Expand Up @@ -511,7 +513,9 @@ export const showWidget = async (
log.info(`🛠️ Opening DevTools from context menu`, {
windowId: widgetWindow.id,
});
widgetWindow.webContents.openDevTools();
widgetWindow.webContents.openDevTools({
mode: 'detach',
});
},
},
{
Expand Down
47 changes: 41 additions & 6 deletions src/renderer/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PROMPT } from '@johnlindquist/kit/core/enum';
import type { Script } from '@johnlindquist/kit/types/core';
import type { Choice, Script } from '@johnlindquist/kit/types/core';
import type { ScoredChoice } from '../../../shared/types';
import log from 'electron-log';
import parse from 'html-react-parser';
import { useAtom, useAtomValue } from 'jotai';
Expand Down Expand Up @@ -50,7 +51,14 @@ const isValidUrl = (url) => {
}
};

const ChoiceName = React.memo(({ scoredChoice, input, base, buttonNameFontSize, choice }) => {
type ChoiceNameProps = {
scoredChoice: ScoredChoice;
input: string;
base: string;
buttonNameFontSize: string;
choice: Choice;
};
const ChoiceName = React.memo(({ scoredChoice, input, base, buttonNameFontSize, choice }: ChoiceNameProps) => {
const memoizedChoiceName = useMemo(() => {
if (!choice?.name) {
return '';
Expand All @@ -65,6 +73,15 @@ const ChoiceName = React.memo(({ scoredChoice, input, base, buttonNameFontSize,
);
});

type ChoiceDescriptionProps = {
scoredChoice: ScoredChoice;
index: number;
buttonIndex: number;
buttonDescriptionFontSize: string;
choice: Choice;
modifierDescription: string;
shouldHighlightDescription: boolean;
};
const ChoiceDescription = React.memo(
({
scoredChoice,
Expand All @@ -74,7 +91,7 @@ const ChoiceDescription = React.memo(
choice,
modifierDescription,
shouldHighlightDescription,
}) => {
}: ChoiceDescriptionProps) => {
return (
<>
{(choice?.focused || choice?.description || modifierDescription) && (
Expand All @@ -99,6 +116,23 @@ const ChoiceDescription = React.memo(
},
);

type ChoiceButtonContentProps = {
choice: Choice;
index: number;
buttonIndex: number;
promptData: Script;
selectedChoices: Choice[];
scale: string;
scoredChoice: ScoredChoice;
imageFail: boolean;
input: string;
base: string;
buttonNameFontSize: string;
buttonDescriptionFontSize: string;
modifierDescription: string;
shouldHighlightDescription: boolean;
setImageFail: (imageFail: boolean) => void;
};
const ChoiceButtonContent = React.memo(
({
choice,
Expand All @@ -116,9 +150,9 @@ const ChoiceButtonContent = React.memo(
modifierDescription,
shouldHighlightDescription,
setImageFail,
}) => {
}: ChoiceButtonContentProps) => {
return (
<div className="flex h-full w-full flex-row items-center justify-between">
<div className="flex h-full w-full flex-row items-center justify-between overflow-x-hidden">
<div className="flex h-full flex-row items-center overflow-x-hidden">
{/* Checkbox */}
{promptData?.multiple && (
Expand Down Expand Up @@ -165,7 +199,7 @@ const ChoiceButtonContent = React.memo(
`}
/>
)}
<div className="flex max-h-full max-w-full flex-col overflow-x-hidden">
<div className="flex max-h-full max-w-full flex-col overflow-x-hidden min-w-0">
<ChoiceName
scoredChoice={scoredChoice}
input={input}
Expand Down Expand Up @@ -351,6 +385,7 @@ function ChoiceButton({ index: buttonIndex, style, data: { choices } }: ChoiceBu
flex
h-16
w-full
max-w-full
flex-shrink-0
flex-row
items-center
Expand Down

0 comments on commit 8d880ba

Please sign in to comment.