Add AI & MCP support (in-memory RAG index), preferences UI, CI and UI simplifications#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d25dd9c8c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| '/embedding/test', | ||
| async ({ body, status }) => { | ||
| try { | ||
| const response = await fetch(body.endpoint, { |
There was a problem hiding this comment.
Restrict embedding test endpoint to trusted targets
This handler issues fetch(body.endpoint) to an arbitrary user-provided URL; combined with the API-wide cors({ origin: '*' }) configuration in src/main/api/index.ts, any website can call the local app API and coerce it into making outbound requests to localhost/private-network targets (SSRF) while observing response status. That creates a network-proxy primitive and should be constrained (e.g., auth, same-origin protection, or strict host allowlisting).
Useful? React with 👍 / 👎.
| const snippet = storage.snippets.getSnippetById(snippetId) | ||
| if (snippet) { | ||
| upsertSnippetInRagIndex(snippet) |
There was a problem hiding this comment.
Keep RAG index synchronized with snippet mutations
The index is updated on ingest here, but in this commit the only RAG mutations are ingest/rebuild paths; normal snippet edit/delete endpoints (src/main/api/routes/snippets.ts) do not update or remove indexed chunks. Once an indexed snippet is edited or deleted, /ai/rag/query can return stale text until someone manually triggers rebuild, which degrades retrieval accuracy in real use.
Useful? React with 👍 / 👎.
Motivation
Description
src/main/ai/rag/index.tswithupsertSnippetInRagIndex,removeSnippetFromRagIndex,clearRagIndex, andqueryRagIndexhelpers.src/main/api/mcp.tsexposingingest_snippetandrag_querytools and wired it up insrc/main/index.tsviainitMcpApi.src/main/api/dto/ai.tsandsrc/main/api/routes/ai.ts, including endpoints for MCP ingestion, RAG rebuild/query, and embedding endpoint testing.api.mcpPortdefaults and sanitizers insrc/main/store/*and added a new AI preferences UI component atsrc/renderer/components/preferences/AI.vueplusAPI.vueupdate to controlmcpPort.codespace by removing/redirecting notes/math/devtools routes and related UI/IPC logic, updating many components (spaceDefinitions.ts, router, main-menu, system listeners, space rail, App shell, etc.) and adjusting styles and small UI details.src/renderer/__tests__/*and other test files)..github/workflows/ci.ymlthat runspnpm install,pnpm test,pnpm run build:main, andpnpm exec vite build.tsconfig.main.jsonto exclude test files frominclude/excludefor the main compilation output.Testing
pnpm test(Vitest) after the changes and they completed successfully.pnpm run build:mainandpnpm exec vite buildand they completed successfully..github/workflows/ci.ymlto run the same install, test and build steps on push and pull requests.Codex Task