Skip to content

Add AI & MCP support (in-memory RAG index), preferences UI, CI and UI simplifications#2

Closed
sinksmell wants to merge 1 commit into
mainfrom
codex/refactor-codebase-for-ui-and-features-1seso8
Closed

Add AI & MCP support (in-memory RAG index), preferences UI, CI and UI simplifications#2
sinksmell wants to merge 1 commit into
mainfrom
codex/refactor-codebase-for-ui-and-features-1seso8

Conversation

@sinksmell

Copy link
Copy Markdown
Owner

Motivation

  • Introduce local AI integration surface (MCP tool endpoints and in-memory RAG index) to ingest and query snippet content.
  • Expose configurable embedding settings in preferences and add a small embedding endpoint connectivity tester.
  • Simplify/trim non-code spaces (notes, math, devtools) and related menu/IPC surface to focus the app on the code space.
  • Add a CI workflow and adjust TypeScript config to exclude test files from main build output.

Description

  • Added an in-memory RAG index implementation under src/main/ai/rag/index.ts with upsertSnippetInRagIndex, removeSnippetFromRagIndex, clearRagIndex, and queryRagIndex helpers.
  • Implemented MCP JSON-RPC server at src/main/api/mcp.ts exposing ingest_snippet and rag_query tools and wired it up in src/main/index.ts via initMcpApi.
  • Added Elysia DTOs and API routes for AI under src/main/api/dto/ai.ts and src/main/api/routes/ai.ts, including endpoints for MCP ingestion, RAG rebuild/query, and embedding endpoint testing.
  • Extended preferences/types/store to include AI embedding settings and api.mcpPort defaults and sanitizers in src/main/store/* and added a new AI preferences UI component at src/renderer/components/preferences/AI.vue plus API.vue update to control mcpPort.
  • Simplified frontend app to focus on the code space 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.
  • Updated and simplified tests to match the new app shape (examples in src/renderer/__tests__/* and other test files).
  • Added CI workflow file .github/workflows/ci.yml that runs pnpm install, pnpm test, pnpm run build:main, and pnpm exec vite build.
  • Updated tsconfig.main.json to exclude test files from include/exclude for the main compilation output.

Testing

  • Ran unit tests with pnpm test (Vitest) after the changes and they completed successfully.
  • Performed local builds using pnpm run build:main and pnpm exec vite build and they completed successfully.
  • Added CI configuration at .github/workflows/ci.yml to run the same install, test and build steps on push and pull requests.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/main/api/routes/ai.ts
'/embedding/test',
async ({ body, status }) => {
try {
const response = await fetch(body.endpoint, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread src/main/api/routes/ai.ts
Comment on lines +62 to +64
const snippet = storage.snippets.getSnippetById(snippetId)
if (snippet) {
upsertSnippetInRagIndex(snippet)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@sinksmell sinksmell closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant