{"record":{"id":"ece6f82829aacee5","repo":"slidevjs/slidev","slug":"no-active-slide-project-found","errorCode":null,"errorMessage":"No active slide project found.","messagePattern":"No active slide project found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vscode/src/lmTools.ts","lineNumber":15,"sourceCode":"import { slash } from '@antfu/utils'\nimport { stringifySlide } from '@slidev/parser/core'\nimport { defineService, useDisposable } from 'reactive-vscode'\nimport { LanguageModelTextPart, LanguageModelToolResult, lm } from 'vscode'\nimport { useFocusedSlide } from './composables/useFocusedSlide'\nimport { activeEntry, activeProject, projects } from './projects'\n\nexport const useLmTools = defineService(() => {\n  const { focusedMarkdown, focusedSourceSlide, focusedSlideNo } = useFocusedSlide()\n\n  registerSimpleTool('slidev_getActiveSlide', () => {\n    const project = activeProject.value\n\n    if (project == null) {\n      throw new Error(`No active slide project found.`)\n    }\n\n    return formatObject({\n      'Entry file': project.entry,\n      'Root directory': project.userRoot,\n      'Preview server port': project.port.value || 'Not running',\n      'Number of slides': project.data.slides.length,\n      'Focused slide no. in presentation (from 1)': focusedSlideNo.value || 'None',\n      'Editing file': focusedMarkdown.value?.filepath || 'Not editing',\n      'Editing slide index in file (from 0)': focusedSourceSlide.value ? focusedSourceSlide.value.index : 'N/A',\n    })\n  })\n\n  registerSimpleTool('slidev_getSlideContent', (input: {\n    entrySlidePath: string\n    slideNo: number\n  }) => {\n    const project = resolveProjectFromEntry(input.entrySlidePath)","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/vscode/src/lmTools.ts#L1-L33","documentation":"Thrown by the `slidev_getActiveSlide` VS Code language-model tool when the extension's `activeProject` ref is null/undefined. The tool exposes the currently focused deck to Copilot/Chat; it can only return data when at least one Slidev project has been detected and registered. The guard `if (project == null)` covers both the never-loaded case and the case where the active project was disposed.","triggerScenarios":"The model invokes `slidev_getActiveSlide` before any Slidev markdown entry is open/registered in the workspace, or after the active project's preview was closed and its entry removed from the `projects` map. `activeProject.value` is null because no entry is focused.","commonSituations":"Opening the chat participant in a workspace with no `slides.md`, before starting a Slidev preview, or after closing all deck files. The `activeProject` ref tracks the currently focused editor's project; with nothing focused it is empty.","solutions":["Open a Slidev entry file (e.g. `slides.md`) in the editor so the extension registers the project and populates `activeProject`.","Start the Slidev preview from a deck; the extension binds the active project on preview launch.","Call `slidev_chooseEntry` with an explicit entry path to set the active entry, then retry `slidev_getActiveSlide`.","If you expect a project but it is missing, run `slidev_listEntries` to confirm which decks the extension currently has loaded."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// The extension's activeProject ref — guard before calling the tool:\nimport { activeProject } from './projects'\nfunction hasActiveProject(): boolean {\n  return activeProject.value != null\n}","tryCatchPattern":"// registerSimpleTool already wraps invoke in try/catch and returns the message\n// as a LanguageModelTextPart, so the LM receives 'Error: No active slide project found.'\n// The caller (the model) should react by listing entries / choosing one.","preventionTips":["Before invoking `slidev_getActiveSlide`, ensure a Slidev deck is open and registered.","Have the model call `slidev_chooseEntry` first to establish an active project.","Use `slidev_listEntries` to verify a project is loaded before assuming `activeProject` is set.","Restart the preview / reopen the deck if the extension was reloaded and lost its project state."],"tags":["slidev","vscode","language-model-tools","copilot","active-project"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}