Skip to content

Commit 88adf88

Browse files
committed
feat: remove AI deep link handler
Removed onyx://ai deep link support since users can ask OpenCode to process content after clipping. This simplifies the integration and avoids clipboard timing issues.
1 parent 49baab4 commit 88adf88

1 file changed

Lines changed: 1 addition & 98 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import { listen } from '@tauri-apps/api/event';
2424
import { onBackButtonPress } from '@tauri-apps/api/app';
2525
import { writeTextFile, mkdir, exists } from '@tauri-apps/plugin-fs';
2626
import { onOpenUrl, getCurrent as getDeepLinkCurrent } from '@tauri-apps/plugin-deep-link';
27-
import { readText, writeText } from '@tauri-apps/plugin-clipboard-manager';
27+
import { readText } from '@tauri-apps/plugin-clipboard-manager';
2828
import { getSyncEngine, getCurrentLogin } from './lib/nostr';
29-
import { isServerRunning, createSession, sendPrompt } from './lib/opencode/client';
3029
import { getSignerFromStoredLogin } from './lib/nostr/signer';
3130
import { buildNoteIndex, resolveWikilink, NoteIndex, FileEntry, NoteGraph, buildNoteGraph } from './lib/editor/note-index';
3231
import { HeadingInfo } from './lib/editor/heading-plugin';
@@ -558,9 +557,6 @@ const App: Component = () => {
558557
case 'clip':
559558
await handleClipDeepLink(params, cachedClipboard);
560559
break;
561-
case 'ai':
562-
await handleAiDeepLink(params);
563-
break;
564560
case 'open':
565561
await handleOpenDeepLink(params);
566562
break;
@@ -643,99 +639,6 @@ const App: Component = () => {
643639
}
644640
};
645641

646-
// Handle onyx://ai - Process AI prompt using OpenCode
647-
const handleAiDeepLink = async (params: URLSearchParams) => {
648-
const callbackId = params.get('callback_id');
649-
const useClipboard = params.has('clipboard');
650-
651-
if (!callbackId) {
652-
console.error('[DeepLink] No callback_id provided');
653-
return;
654-
}
655-
656-
let requestData: { prompt?: string; context?: string; callbackId?: string } = {};
657-
658-
if (useClipboard) {
659-
try {
660-
const clipboardText = await readText();
661-
console.log('[DeepLink] Clipboard text length:', clipboardText?.length || 0);
662-
console.log('[DeepLink] Clipboard preview:', clipboardText?.substring(0, 200));
663-
if (clipboardText) {
664-
requestData = JSON.parse(clipboardText);
665-
console.log('[DeepLink] Parsed request data:', {
666-
hasPrompt: !!requestData.prompt,
667-
promptLength: requestData.prompt?.length,
668-
hasContext: !!requestData.context,
669-
callbackId: requestData.callbackId
670-
});
671-
}
672-
} catch (err) {
673-
console.error('[DeepLink] Failed to parse clipboard data:', err);
674-
await writeAiResponse(callbackId, '', 'Failed to parse AI request from clipboard');
675-
return;
676-
}
677-
}
678-
679-
const prompt = params.get('prompt') || requestData.prompt;
680-
const context = requestData.context || '';
681-
682-
if (!prompt) {
683-
console.error('[DeepLink] No prompt provided');
684-
await writeAiResponse(callbackId, '', 'No prompt provided');
685-
return;
686-
}
687-
688-
console.log('[DeepLink] AI prompt:', prompt);
689-
console.log('[DeepLink] Context length:', context.length);
690-
691-
// Check if OpenCode server is running
692-
const serverRunning = await isServerRunning(3000);
693-
if (!serverRunning) {
694-
console.error('[DeepLink] OpenCode server is not running');
695-
await writeAiResponse(callbackId, '', 'OpenCode is not running. Open the OpenCode panel in Onyx first.');
696-
return;
697-
}
698-
699-
try {
700-
// Create a temporary session for this request
701-
const session = await createSession('Clipper AI Request');
702-
703-
// Build the full prompt with context
704-
const fullPrompt = context
705-
? `${prompt}\n\nContext:\n${context}`
706-
: prompt;
707-
708-
// Send the prompt and wait for response
709-
const response = await sendPrompt(session.id, fullPrompt);
710-
711-
// Extract text from response parts
712-
const resultText = response.parts
713-
.filter((part): part is { type: 'text'; text: string } => part.type === 'text')
714-
.map(part => part.text)
715-
.join('\n');
716-
717-
if (resultText) {
718-
await writeAiResponse(callbackId, resultText);
719-
} else {
720-
await writeAiResponse(callbackId, '', 'No response generated');
721-
}
722-
} catch (err) {
723-
console.error('[DeepLink] Failed to process AI prompt:', err);
724-
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
725-
await writeAiResponse(callbackId, '', `Failed to process: ${errorMessage}`);
726-
}
727-
};
728-
729-
const writeAiResponse = async (callbackId: string, result: string, error?: string) => {
730-
const response = { callbackId, result, error };
731-
try {
732-
await writeText(JSON.stringify(response));
733-
console.log('[DeepLink] AI response written to clipboard');
734-
} catch (err) {
735-
console.error('[DeepLink] Failed to write AI response:', err);
736-
}
737-
};
738-
739642
// Handle onyx://open - Open a file in the vault
740643
const handleOpenDeepLink = async (params: URLSearchParams) => {
741644
const vault = vaultPath();

0 commit comments

Comments
 (0)