-
+
+
+
+
+
-
+
@@ -15,13 +19,6 @@
Usage: Highlight your text, press keyboard shortcut then choose an Al command
-
@@ -42,27 +39,27 @@ import { ref } from 'vue'
import { store } from '../services/store'
import InputShortcut from '../components/InputShortcut.vue'
+const prompt = ref(null)
const chat = ref(null)
const scratchpad = ref(null)
const command = ref(null)
-const anywhere = ref(null)
const readaloud = ref(null)
const transcribe = ref(null)
const load = () => {
+ prompt.value = store.config.shortcuts.prompt
chat.value = store.config.shortcuts.chat
scratchpad.value = store.config.shortcuts.scratchpad
command.value = store.config.shortcuts.command
- anywhere.value = store.config.shortcuts.anywhere
readaloud.value = store.config.shortcuts.readaloud
transcribe.value = store.config.shortcuts.transcribe
}
const save = () => {
+ store.config.shortcuts.prompt = prompt.value
store.config.shortcuts.chat = chat.value
store.config.shortcuts.scratchpad = scratchpad.value
store.config.shortcuts.command = command.value
- store.config.shortcuts.anywhere = anywhere.value
store.config.shortcuts.readaloud = readaloud.value
store.config.shortcuts.transcribe = transcribe.value
store.saveSettings()
diff --git a/src/types/automation.d.ts b/src/types/automation.d.ts
index cec6d6a8..4d21b787 100644
--- a/src/types/automation.d.ts
+++ b/src/types/automation.d.ts
@@ -2,9 +2,9 @@
declare module 'applescript'
export interface ShortcutCallbacks {
+ prompt: () => void
chat: () => void
command: () => void
- anywhere: () => void
readaloud: () => void
transcribe: () => void
scratchpad: () => void
diff --git a/src/types/config.d.ts b/src/types/config.d.ts
index 1334b21d..4d022aa2 100644
--- a/src/types/config.d.ts
+++ b/src/types/config.d.ts
@@ -56,7 +56,7 @@ interface ChatAppearance {
interface ShortcutsConfig {
chat: Shortcut
command: Shortcut
- anywhere: Shortcut
+ prompt: Shortcut
readaloud: Shortcut
transcribe: Shortcut
scratchpad: Shortcut
diff --git a/src/types/index.d.ts b/src/types/index.d.ts
index f7fcc17f..d29be885 100644
--- a/src/types/index.d.ts
+++ b/src/types/index.d.ts
@@ -179,13 +179,9 @@ declare global {
isPromptEditable?(id: string): boolean
}
anywhere?: {
- prompt?(text: string): void
- resize?(width: number, height: number): void
- showExperts?(): void
- closeExperts?(): void
- toggleExperts?(): void
- isExpertsOpen?(): boolean
- onExpert?(prompt: string): void
+ prompt?(): void
+ insert?(prompt: string): void
+ continue?(chatId: string): void
cancel?(): void
}
experts?: {
diff --git a/tests/screens/prompt.test.ts b/tests/screens/prompt.test.ts
index d9ea6727..c9ff06ac 100644
--- a/tests/screens/prompt.test.ts
+++ b/tests/screens/prompt.test.ts
@@ -6,9 +6,6 @@ import PromptAnywhere from '../../src/screens/PromptAnywhere.vue'
import Experts from '../../src/screens/Experts.vue'
import defaultSettings from '../../defaults/settings.json'
-import useEventBus from '../../src/composables/event_bus'
-const { emitEvent } = useEventBus()
-
enableAutoUnmount(afterAll)
beforeAll(() => {
@@ -64,17 +61,11 @@ test('Renders correctly', () => {
// expect(window.api.anywhere.cancel).toHaveBeenCalled()
// })
-test('Prompts on Enter', async () => {
- /*const wrapper = */mount(PromptAnywhere)
- emitEvent('send-prompt', 'prompt')
- expect(window.api.anywhere.prompt).toHaveBeenCalled()
-})
-
test('Show experts', async () => {
const wrapper = mount(PromptAnywhere)
const trigger = wrapper.find('.icon.experts')
await trigger.trigger('click')
- expect(window.api.anywhere.showExperts).toHaveBeenCalled()
+ expect(wrapper.find('.experts').exists()).toBe(true)
})
test('Experts renders', async () => {
diff --git a/tests/unit/anywhere.test.ts b/tests/unit/anywhere.test.ts
index bf25ad59..ada352df 100644
--- a/tests/unit/anywhere.test.ts
+++ b/tests/unit/anywhere.test.ts
@@ -5,7 +5,6 @@ import defaults from '../../defaults/settings.json'
import * as window from '../../src/main/window'
import PromptAnywhere from '../../src/automations/anywhere'
import Automator from '../../src/automations/automator'
-import LlmMock from '../mocks/llm'
// mock config
vi.mock('../../src/main/config.ts', async () => {
@@ -18,11 +17,11 @@ vi.mock('../../src/main/config.ts', async () => {
vi.mock('../../src/main/window.ts', async () => {
return {
openPromptAnywhere: vi.fn(),
- openWaitingPanel: vi.fn(),
- closeWaitingPanel: vi.fn(),
+ closePromptAnywhere: vi.fn(),
hideWindows: vi.fn(),
restoreWindows: vi.fn(),
- releaseFocus: vi.fn()
+ releaseFocus: vi.fn(),
+ openMainWindow: vi.fn(),
}
})
@@ -65,28 +64,25 @@ test('Prepare prompt', async () => {
test('Execute Prompt', async () => {
- const anywhere = new PromptAnywhere(new LlmMock(store.config))
- await anywhere.execPrompt(null, 'Explain this')
+ await PromptAnywhere.insert(null, 'Explain this')
- expect(window.openWaitingPanel).toHaveBeenCalledOnce()
- expect(window.closeWaitingPanel).toHaveBeenCalledOnce()
+ expect(window.closePromptAnywhere).toHaveBeenCalledOnce()
expect(window.restoreWindows).toHaveBeenCalledOnce()
- expect(Automator.prototype.pasteText).toHaveBeenCalledWith('[{"role":"user","content":"Explain this"},{"role":"assistant","content":"Be kind. Don\'t mock me"}]')
+ expect(Automator.prototype.pasteText).toHaveBeenCalledWith('Explain this')
})
-test('Cancel Prompt', async () => {
+test('Continue as Chat Prompt', async () => {
- const anywhere = new PromptAnywhere(new LlmMock(store.config))
- await anywhere.cancel()
+ await PromptAnywhere.continueAsChat(null, '123')
- expect(window.closeWaitingPanel).toHaveBeenCalledOnce()
+ expect(window.closePromptAnywhere).toHaveBeenCalledOnce()
expect(window.restoreWindows).toHaveBeenCalledOnce()
expect(window.releaseFocus).toHaveBeenCalledOnce()
- await anywhere.execPrompt(null, 'Explain this')
-
- expect(Automator.prototype.pasteText).not.toHaveBeenCalled()
+ expect(window.openMainWindow).toHaveBeenCalledWith({
+ queryParams: { chatId: '123' }
+ })
})
diff --git a/tests/unit/window.test.ts b/tests/unit/window.test.ts
index abbc0b3a..e12c58f3 100644
--- a/tests/unit/window.test.ts
+++ b/tests/unit/window.test.ts
@@ -170,12 +170,6 @@ test('Create prompt anywhere window', async () => {
expectCreateWebPreferences(callParams)
})
-test('Resize prompt anywhere window', async () => {
- await window.openPromptAnywhere()
- await window.resizePromptAnywhere(100)
- expect(BrowserWindow.prototype.setSize).toHaveBeenCalledWith(0, 100)
-})
-
test('Close prompt anywhere window', async () => {
await window.openPromptAnywhere()
await window.closePromptAnywhere()