Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(chat): a link in the user's message leads the workflow search (C60-S5)

purple13cd57c6bc60
diff --git a/src/api/mcp/__tests__/workflow-tools.test.ts b/src/api/mcp/__tests__/workflow-tools.test.ts
index 6b1d47fb..d4d35205 100644
--- a/src/api/mcp/__tests__/workflow-tools.test.ts
+++ b/src/api/mcp/__tests__/workflow-tools.test.ts
@@ -112,6 +112,11 @@ describe('workflow_find', () => {
expect(await executeWorkflowFind({ url: 'https://evil.example/wf.json' }, run())).toMatch(/^Refused: LU only opens a workflow link the user wrote/)
})
+ it('a link in the user\'s message leads, whatever the model searched for', async () => {
+ userSays('Bau mir diesen Workflow ein: https://github.com/a/b/blob/main/wf.png, für Realistic Vision.')
+ expect(await executeWorkflowFind({ query: 'hires fix' }, run())).toMatch(/^The user sent a workflow link, id url\d+\. Next: workflow_inspect/)
+ })
+
it('asks for a query', async () => {
userSays('find a workflow')
expect(await executeWorkflowFind({}, run())).toMatch(/^Error: query is missing/)
diff --git a/src/api/mcp/workflow-tools.ts b/src/api/mcp/workflow-tools.ts
index 35046674..c7b3e04e 100644
--- a/src/api/mcp/workflow-tools.ts
+++ b/src/api/mcp/workflow-tools.ts
@@ -72,6 +72,11 @@ const STRONG_INSTALL = /\b(install|installier|einbau|einbauen|bau(?:e|t)?\b[^.?!
const installNames = (text: string, strict: boolean) => (strict ? STRONG_INSTALL.test(text) : userAskedToInstall(text))
const assignNames = (text: string, strict: boolean) => (strict ? STRONG_INSTALL.test(text) || /\b(assign|zuweis|zuweisen)/i.test(text) : userAskedToAssign(text))
+/** The https links the user wrote, in order. */
+export function linksInUserText(text: string): string[] {
+ return [...text.matchAll(/https:\/\/[^\s<>"'\])]+/g)].map((m) => m[0].replace(/[.,;:!?]+$/, '')).filter((u) => linkIsFromUser(u, text)).slice(0, 3)
+}
+
/** A failure in words. A Tauri command rejects with a plain string, not an Error. */
function errText(e: unknown, max: number): string {
const t = e instanceof Error ? e.message : typeof e === 'string' ? e : ''
@@ -110,6 +115,15 @@ export async function executeWorkflowFind(args: ToolArgs, run?: AgentRunContext)
const c = userLinkCandidate(url)
return `Workflow link from the user, id ${c.id}. Next: workflow_inspect with id ${c.id}.`
}
+ // The user's own message holds a link: that is the workflow they mean. A
+ // small model tends to search for its name instead, so the link leads the
+ // list whatever the query was.
+ const sent = linksInUserText(lastUserText(run?.conversationId))
+ if (sent.length) {
+ const c = userLinkCandidate(sent[0])
+ return `The user sent a workflow link, id ${c.id}. Next: workflow_inspect with id ${c.id}. `
+ + 'Do not search the web for it; workflow_inspect reads JSON and PNG workflow files from the link.'
+ }
if (!query) return 'Error: query is missing. Say what the workflow should do, e.g. "flux upscale".'
const lines: string[] = []