Compare commits

...

154 Commits

Author SHA1 Message Date
4749dd078a Update iOS app icon asset 2026-05-08 04:21:46 +02:00
94bf310540 Update iOS app icon asset 2026-05-08 04:21:46 +02:00
a3250c54a8 auto-git:
[change] src-tauri/icons/icon.icns
 [change] src-tauri/icons/icon.png
2026-05-08 04:21:46 +02:00
41f123c355 auto-git:
[change] concept_api.py
2026-05-08 04:21:46 +02:00
5913bc4832 Refactor: Standardize command resolution and subprocess environment in concept_api.py 2026-05-08 04:20:29 +02:00
fa8a19a020 Update iOS app icon asset 2026-05-08 04:18:01 +02:00
41e6b8e20f Update iOS app icon asset 2026-05-08 04:18:01 +02:00
f64947ef79 Update application icon assets 2026-05-08 04:18:01 +02:00
8f9d8472de Remove session persistence logic from src-tauri/src/lib.rs 2026-05-08 04:16:36 +02:00
003ec21c42 Update backend process working directory based on backend type 2026-05-08 04:16:03 +02:00
bbf5844e0e Refactor action handling to use backend communication and update process command usage 2026-05-08 04:14:49 +02:00
5b80b22b60 Refactor backend execution to support bundled sidecar binaries and improve environment handling 2026-05-08 04:14:36 +02:00
f2bbabc25e chore: Update gitignore and path handling imports 2026-05-08 04:14:07 +02:00
27e51424b0 config: Include Python sidecar as external binary in Tauri config 2026-05-08 04:14:07 +02:00
6ec917b3cc ci: Integrate Python sidecar build into package scripts 2026-05-08 04:14:07 +02:00
978919b410 feat: Add script to build Python sidecar executable 2026-05-08 04:14:07 +02:00
e4028f58a8 auto-git:
[change] concept_api.py
2026-05-08 04:12:54 +02:00
603f9389b7 Update iOS app icon asset 2026-05-08 03:42:01 +02:00
187522518f Update iOS app icon asset 2026-05-08 03:42:01 +02:00
6a4e57ccff Update application icons (ICNS and PNG) 2026-05-08 03:42:01 +02:00
05d6a536b5 Fix placement of Export PDF button in App component 2026-05-08 03:42:01 +02:00
f8549fd6f3 Update iOS app icon asset 2026-05-08 03:31:53 +02:00
02b8bc8a3f Update iOS app icon asset 2026-05-08 03:31:53 +02:00
2a1a3e3b30 Update application icons (ICNS and PNG) 2026-05-08 03:31:53 +02:00
ebb845516e Refactor build scripts and configuration for icons and web build steps 2026-05-08 03:30:29 +02:00
099ef92187 auto-git:
[change] src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png
 [change] src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png
 [change] src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png
 [change] src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png
2026-05-08 03:21:47 +02:00
9a378b1fda auto-git:
[change] src-tauri/icons/android/mipmap-hdpi/ic_launcher.png
 [change] src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png
 [change] src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png
 [change] src-tauri/icons/android/mipmap-mdpi/ic_launcher.png
 [change] src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png
 [change] src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png
 [change] src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png
 [change] src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png
 [change] src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png
 [change] src-tauri/icons/ios/AppIcon-512@2x.png
2026-05-08 03:21:47 +02:00
444ca83955 auto-git:
[change] src-tauri/icons/ios/AppIcon-20x20@1x.png
 [change] src-tauri/icons/ios/AppIcon-20x20@2x-1.png
 [change] src-tauri/icons/ios/AppIcon-20x20@2x.png
 [change] src-tauri/icons/ios/AppIcon-20x20@3x.png
 [change] src-tauri/icons/ios/AppIcon-29x29@1x.png
 [change] src-tauri/icons/ios/AppIcon-29x29@2x-1.png
 [change] src-tauri/icons/ios/AppIcon-29x29@2x.png
 [change] src-tauri/icons/ios/AppIcon-29x29@3x.png
 [change] src-tauri/icons/ios/AppIcon-40x40@1x.png
 [change] src-tauri/icons/ios/AppIcon-40x40@2x-1.png
 [change] src-tauri/icons/ios/AppIcon-40x40@2x.png
 [change] src-tauri/icons/ios/AppIcon-40x40@3x.png
 [change] src-tauri/icons/ios/AppIcon-512@2x.png
 [change] src-tauri/icons/ios/AppIcon-60x60@2x.png
 [change] src-tauri/icons/ios/AppIcon-60x60@3x.png
 [change] src-tauri/icons/ios/AppIcon-76x76@1x.png
 [change] src-tauri/icons/ios/AppIcon-76x76@2x.png
 [change] src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png
2026-05-08 03:21:47 +02:00
f88545f689 auto-git:
[change] src-tauri/icons/128x128.png
 [change] src-tauri/icons/128x128@2x.png
 [change] src-tauri/icons/32x32.png
 [change] src-tauri/icons/64x64.png
 [change] src-tauri/icons/icon.icns
 [change] src-tauri/icons/icon.ico
 [change] src-tauri/icons/icon.png
2026-05-08 03:21:46 +02:00
ac4855a70e auto-git:
[change] src-tauri/icons/Square107x107Logo.png
 [change] src-tauri/icons/Square142x142Logo.png
 [change] src-tauri/icons/Square150x150Logo.png
 [change] src-tauri/icons/Square284x284Logo.png
 [change] src-tauri/icons/Square30x30Logo.png
 [change] src-tauri/icons/Square310x310Logo.png
 [change] src-tauri/icons/Square44x44Logo.png
 [change] src-tauri/icons/Square71x71Logo.png
 [change] src-tauri/icons/Square89x89Logo.png
 [change] src-tauri/icons/StoreLogo.png
2026-05-08 03:21:46 +02:00
45513692d3 auto-git:
[change] icon.png
2026-05-08 03:21:46 +02:00
9fe466a144 Standardize input text handling using currentIdeaText across rephrase, extend, and prior art features 2026-05-08 03:17:07 +02:00
7aa91f7c59 Ignore compiled application files (*.app) 2026-05-08 03:16:50 +02:00
88cb9ef487 Refactor settings menu initialization formatting 2026-05-08 03:16:50 +02:00
a80fdf5529 Update menu structure to use a submenu for settings 2026-05-08 03:16:50 +02:00
227f82a718 Format notes using title, description, and concept fields in prior_art 2026-05-08 03:15:05 +02:00
f3d028b85d Use structured idea fields for prior art notes 2026-05-08 03:14:43 +02:00
51d77b2f7a Update tauri config with multiple icon assets 2026-05-08 03:14:43 +02:00
8c4b3eeadc auto-git:
[add] src-tauri/icons/128x128.png
 [add] src-tauri/icons/128x128@2x.png
 [add] src-tauri/icons/32x32.png
 [add] src-tauri/icons/64x64.png
 [add] src-tauri/icons/android/
 [add] src-tauri/icons/icon.icns
 [add] src-tauri/icons/icon.ico
 [add] src-tauri/icons/ios/
 [change] src-tauri/icons/icon.png
 [change] src-tauri/src/lib.rs
 [change] src/App.tsx
2026-05-08 03:13:35 +02:00
23fb120bb2 Style the panel title actions container for button alignment 2026-05-08 03:12:25 +02:00
a6033a523e Add various platform icon assets for the application 2026-05-08 03:12:25 +02:00
298433ed30 Refactor files/websites panel to use interactive buttons for adding files and URLs 2026-05-08 03:12:25 +02:00
407064158b Support custom output path for PDF previews and add styling for concept actions 2026-05-08 03:11:47 +02:00
520891c50d Refactor PDF handling to support exporting the concept text instead of just previewing it 2026-05-08 03:11:21 +02:00
0317a2d577 Remove image prompt generation and storage functionality 2026-05-08 03:07:47 +02:00
52a8bb8222 Remove image prompt generation logic and related styles 2026-05-08 03:07:13 +02:00
3691151bd4 Remove image prompt generation functionality 2026-05-08 03:06:48 +02:00
69438bd976 Update icon image 2026-05-08 02:42:33 +02:00
0efab8e254 Remove diffusers dependency from requirements.txt 2026-05-08 01:37:20 +02:00
b20cacee25 Remove image generation functionality from API 2026-05-08 01:36:11 +02:00
4356630fc6 Remove image generation functionality from App component 2026-05-08 01:36:00 +02:00
6edb3208aa Style session list components 2026-05-08 01:27:12 +02:00
28c56b6e62 Refactor: Update session modal structure and improve accessibility 2026-05-08 01:27:06 +02:00
0fadba71e6 Update session field parsing to handle generic JSON values for titles, descriptions, and saved_at. 2026-05-08 01:23:32 +02:00
17ebfd99dd auto-git:
[change] src-tauri/build.rs
 [change] src-tauri/src/lib.rs
 [change] src-tauri/src/main.rs
 [change] src/App.tsx
2026-05-08 01:22:38 +02:00
fe2a15afca Feature: Implement session management for listing and loading saved sessions 2026-05-08 01:22:15 +02:00
56f6613537 Add styling for form components and website containers 2026-05-07 23:58:30 +02:00
85ecda1a24 Feat: Implement URL adding modal and update button text 2026-05-07 23:58:23 +02:00
287c94b4e0 Refactor website addition logic to use modal and form validation 2026-05-07 23:57:56 +02:00
f33cec7658 Remove styles for source picker components 2026-05-07 23:56:42 +02:00
392f3c3540 Remove source picker modal and simplify source addition logic 2026-05-07 23:56:33 +02:00
959d68a864 Style source picker window and action buttons 2026-05-07 23:54:51 +02:00
56e8f38cde Add source picker modal UI 2026-05-07 23:54:46 +02:00
859ae4bc66 Consolidate source addition buttons into a picker 2026-05-07 23:54:46 +02:00
d88d9df957 Implement source picker selection logic 2026-05-07 23:54:46 +02:00
ca2a71b82a Add state for source picker modal 2026-05-07 23:54:46 +02:00
95944b5b0d Remove styles for secondary button class 2026-05-07 23:52:33 +02:00
e1e49d776e Update Find Prior Art button structure 2026-05-07 23:52:33 +02:00
1d639e61ce Improve layout stability for file panel 2026-05-07 23:48:56 +02:00
4c7755dfcf Implement layout for notes and files panels and refine remove row button styling 2026-05-07 23:47:44 +02:00
99a2bf64ea Refactor: Update Notes/Thoughts panel structure and controls 2026-05-07 23:47:25 +02:00
ffc8bc129a Remove initial state setting for selected rows 2026-05-07 23:42:59 +02:00
c42dd79dfe Update table layout for fifth column and style remove row button 2026-05-07 23:41:25 +02:00
11e31ce6fa Feature: Add row-level removal button and update action buttons 2026-05-07 23:41:13 +02:00
040650e1c3 auto-git:
[change] src/App.tsx
2026-05-07 23:40:12 +02:00
a39b043f1b Update README with new features (image generation, session saving) and clarify data storage 2026-05-07 23:30:20 +02:00
622df54436 Adjust table grid columns and remove custom checkbox styles 2026-05-07 23:29:10 +02:00
50f9c79445 Remove unused include map attribute from ConceptEngine 2026-05-07 23:29:10 +02:00
d0d79150e7 Remove include map state and refactor file/website data structures; remove 'Add to Repo' column 2026-05-07 23:28:55 +02:00
8e6d868954 Remove inclusion status tracking and toggle functionality for files and URLs 2026-05-07 23:28:40 +02:00
6e7daafb83 Simplify asset handling by removing the dependency on include_map filter across concept generation functions. 2026-05-07 23:28:25 +02:00
dcf03fbf2a Remove repository push functionality 2026-05-07 23:28:06 +02:00
d398dcb8ea Remove git utilities and concept index generation from concept_api 2026-05-07 23:27:50 +02:00
302adba66c Remove concept directory path and git remote settings/push functionality 2026-05-07 23:27:21 +02:00
7f68bb47cf Remove functionality for pushing concepts to repository 2026-05-07 23:27:03 +02:00
fe0621fb53 Remove git remote state and handling 2026-05-07 23:27:03 +02:00
e0c26518c3 Refactor layout: Updates status notification component and adjusts global body styling. 2026-05-07 23:00:26 +02:00
b1f8fb2338 auto-git:
[change] src/App.tsx
2026-05-07 22:59:35 +02:00
78879d7c14 Refactor settings UI components and modal styling 2026-05-07 22:56:22 +02:00
9d61ffc3d3 Refactor settings into a dedicated modal and integrate application menu actions 2026-05-07 22:56:01 +02:00
889908a240 Implement main application menu structure (File and Settings) 2026-05-07 22:55:32 +02:00
31048654b6 Update devUrl in tauri.conf.json to use 127.0.0.1 2026-05-07 20:20:20 +02:00
2fab5e6d1d Update development scripts and configuration for web UI/desktop app separation 2026-05-07 20:19:06 +02:00
c544538bc1 Refine docstring: Update description to use 'desktop toolkit imports' instead of 'desktop GUI imports' 2026-05-07 20:13:19 +02:00
df5dfcbf30 auto-git:
[change] README.md
 [change] concept_api.py
 [change] requirements.txt
 [change] websearch.py
 [unlink] concept-maker_gui.py
 [unlink] run.sh
2026-05-07 20:11:48 +02:00
a97927a29a Enhance code block rendering with language classes and refine link validation 2026-05-07 19:46:00 +02:00
39fb777ae6 Add styles for concept editor and markdown preview components 2026-05-07 19:43:35 +02:00
23bc477319 auto-git:
[change] src/App.tsx
2026-05-07 19:43:28 +02:00
c59f7ab429 auto-git:
[add] src/markdown/
 [add] src/types/
2026-05-07 19:43:28 +02:00
b520f53ae5 Update markdown-it version specifier 2026-05-07 19:41:38 +02:00
1fdd3194ab Add markdown-it dependency 2026-05-07 19:41:38 +02:00
b30e07282e Remove Google Font imports from index.html 2026-05-07 19:24:35 +02:00
11f507fe13 Refactor: Update UI styling across components using CSS variables and standardize visual appearance 2026-05-07 19:23:15 +02:00
43cb2b6cd7 auto-git:
[change] src/styles.css
2026-05-07 19:20:33 +02:00
52e229bc6f Update run-python-action permission to allow open_path command 2026-05-07 19:16:22 +02:00
37333b5b27 Improve PDF preview handling by automatically opening the generated file and enhancing error reporting. 2026-05-07 19:11:34 +02:00
1e6993b03f auto-git:
[change] src-tauri/src/lib.rs
2026-05-07 19:11:23 +02:00
d4f51f013b Ignore temporary files in .gitignore 2026-05-07 18:40:44 +02:00
0d39215a1c Add build directory to .gitignore 2026-05-07 18:40:44 +02:00
598a1ebc51 Update .gitignore to exclude build artifacts 2026-05-07 18:40:44 +02:00
d3ce23d9b0 Add label to main window in tauri.conf.json 2026-02-04 07:25:40 +01:00
e346d6df7e Add windows configuration to default capabilities 2026-02-04 07:25:40 +01:00
1fac38dbe0 Update file drop event handling in App.tsx 2026-02-04 07:20:07 +01:00
9695382070 Update application icon 2026-02-04 07:18:54 +01:00
35d1d97856 Add Cargo.lock and *.lock to .gitignore 2026-02-04 07:14:05 +01:00
c922f8cd93 Update Cargo.toml with explicit features for tauri-build 2026-02-04 07:14:05 +01:00
53de314cf6 Update tauri configuration with identifier 2026-02-04 07:11:59 +01:00
3fe1e5247e Update .gitignore to ignore package-lock.json 2026-02-04 07:03:16 +01:00
3aac36b116 Add vite-env.d.ts for Vite client types 2026-02-04 07:01:49 +01:00
b07c989af2 Update concept_api.py with minor corrections and improvements 2026-02-04 07:00:39 +01:00
6c86a717ff Fix title in index.html 2026-02-04 07:00:15 +01:00
58fafc677e Add Tauri project files and update .gitignore 2026-02-04 07:00:15 +01:00
dc93adf52a auto-git:
[add] src-tauri/build.rs
2026-02-04 06:59:17 +01:00
b109203f4f auto-git:
[add] src-tauri/Cargo.toml
2026-02-04 06:59:17 +01:00
5340bf9844 auto-git:
[add] src/App.tsx
2026-02-04 06:59:17 +01:00
0bd23bdfec auto-git:
[add] concept_api.py
2026-02-04 06:56:15 +01:00
1a65e7943d Add styles.css for UI components 2026-02-04 06:49:55 +01:00
fa55771fff Add src/main.tsx 2026-02-04 06:48:09 +01:00
a53ff29dba Add index.html 2026-02-04 06:48:09 +01:00
904e6b253a Add vite.config.ts 2026-02-04 06:48:09 +01:00
399e4efdad Add tsconfig.node.json 2026-02-04 06:48:09 +01:00
e2210f8b66 Add tsconfig.json 2026-02-04 06:48:09 +01:00
66ae5397de Add package.json 2026-02-04 06:48:09 +01:00
Victor Giers
5c47ff6fad Reduce inference steps in concept-maker_gui.py 2025-11-30 23:29:01 +01:00
Victor Giers
d756489a5c Adjust device context and add generator for non-CPU devices 2025-11-30 23:27:31 +01:00
Victor Giers
ae88eade67 Improve MPS handling and add VAE slicing/tiling 2025-11-30 23:27:31 +01:00
Victor Giers
c015795c01 Update concept-maker_gui.py to support MPS and disable progress bar 2025-11-30 23:21:56 +01:00
Victor Giers
51502a1e9f Add transformers to requirements.txt 2025-11-30 23:12:47 +01:00
Victor Giers
6f422f2085 Add diffusers to requirements.txt 2025-11-30 23:10:59 +01:00
Victor Giers
1e5d543480 Include timestamp in image filename 2025-11-30 23:08:09 +01:00
Victor Giers
becbe8ef4d auto-git:
[change] concept-maker_gui.py
2025-11-30 23:05:52 +01:00
Victor Giers
c510f7985a auto-git:
[change] concept-maker_gui.py
2025-11-30 23:05:36 +01:00
Victor Giers
30ad6dcc03 auto-git:
[change] concept-maker_gui.py
2025-11-30 23:05:18 +01:00
Victor Giers
bd1220281a auto-git:
[change] concept-maker_gui.py
2025-11-30 23:05:13 +01:00
Victor Giers
acbf889b96 Include image prompt in dirty check 2025-11-30 17:51:21 +01:00
Victor Giers
e5714a8581 Restore image prompt from saved session 2025-11-30 17:51:21 +01:00
Victor Giers
1d3c919214 Add image prompt to session state 2025-11-30 17:51:21 +01:00
Victor Giers
e17f47cefe Ensure image prompt is cleared if it matches the placeholder 2025-11-30 17:50:18 +01:00
Victor Giers
6ba208852e Include image prompt in session data if not placeholder 2025-11-30 17:50:18 +01:00
Victor Giers
2a0b4da479 Update image prompt placeholder handling 2025-11-30 17:50:17 +01:00
Victor Giers
fcebf043cc auto-git:
[change] concept-maker_gui.py
2025-11-30 17:49:17 +01:00
Victor Giers
93086ed32e auto-git:
[change] concept-maker_gui.py
2025-11-30 17:49:08 +01:00
Victor Giers
e098e69977 auto-git:
[change] concept-maker_gui.py
2025-11-30 17:49:02 +01:00
Victor Giers
b69d23d57f auto-git:
[change] concept-maker_gui.py
2025-11-30 17:48:53 +01:00
80 changed files with 4058 additions and 3279 deletions

16
.gitignore vendored
View File

@@ -5,3 +5,19 @@ __pycache__
.zipignore .zipignore
.gitignore .gitignore
.DS_Store .DS_Store
node_modules
dist
src-tauri/target
src-tauri/binaries
scripts/.sidecar-build
.sidecar-build
src-tauri/gen
package-lock.json
Cargo.lock
*.lock
*.o
*.dylib
out
build
*.tmp
*.app

153
README.md
View File

@@ -1,94 +1,95 @@
# Concept Maker GUI # Concept Maker
A desktop tool to turn raw ideas, notes, and files into a clear, actionable project concept. Drag in files, jot notes, use automated websearch to find prior art, build a compact knowledge base, generate an editable Markdown concept using a local LLM, convert it to pdf and push your concept to a Git repo. A Tauri desktop app that turns raw ideas, notes, URLs, and files into a clear project concept. The UI is React/Vite, the desktop shell is Tauri, and the Python backend is exposed through `concept_api.py`.
## Features ## Features
- Drag and drop files/folders into a table (falls back to add buttons).
- Freeform notes area for thoughts and fragments. - Add files, folders, and URLs as source material.
- Builds a JSONL knowledge base from your files (uses `corpus_builder.py` when present; includes a simple fallback). - Write freeform notes and ask a local Ollama model to rephrase, extend, or generate a concept.
- Generates a polished Concept (Markdown) via a local Ollama model. - Build a JSONL knowledge base from selected files using `corpus_builder.py` when available, with a lightweight fallback in the backend.
- Prior-art search via SearXNG: generates smart queries, fetches pages, embeds + reranks, and shows a results window. - Search for prior art through SearXNG and Ollama embeddings.
- Edit the result in‑app, then save it into a local Git repo and optionally push to a remote. - Preview concepts as Markdown/PDF.
- Remembers sessions; re‑open and continue later. - Generate an image prompt and optional image asset for a concept.
- Uses `icon.png` for the window/taskbar/dock icon. - Save and reopen local sessions.
## Requirements ## Requirements
- Node.js and npm
- Rust toolchain
- Python 3.9+ - Python 3.9+
- Ollama running locally (default `http://localhost:11434`) - Ollama running locally, defaulting to `http://localhost:11434`
- Suggested default model: `mistral3.2-small:24b` (configurable in the UI) - Optional local SearXNG instance for prior-art search, defaulting to `http://localhost:8888`
- OS packages as needed for Tk:
- macOS: included with the official Python.org installer
- Ubuntu/Debian: `sudo apt-get install python3-tk`
- Windows: included with the official Python.org installer
Optional Python packages improve file ingestion: Python packages are listed in `requirements.txt`. Some features also depend on external command-line tools:
- `tkinterdnd2` (native drag & drop)
- `pymupdf` (PDF text extraction)
- `beautifulsoup4` (better HTML text extraction)
Prior‑art search requires API access to a SearXNG instance: - `pandoc` or `wkhtmltopdf` for higher-quality Markdown to PDF export
- Recommended: run SearXNG locally via Docker (installation/compose details are out of scope for this repo). - `tesseract` and `ocrmypdf` for OCR-heavy ingestion
- Project site: https://searxng.org - `ffmpeg`/`ffprobe` for media handling
Note: `requirements.txt` also lists some optional extras and system tools. If installation fails on entries that are not Python packages (e.g., system binaries), install them via your OS package manager or comment those lines out. ## Setup
## Quick Start Install JavaScript dependencies:
- With the convenience script:
- `bash run.sh`
- Manual steps:
- `python3 -m venv .venv`
- `source .venv/bin/activate` (Windows: `.\\.venv\\Scripts\\activate`)
- `python -m pip install --upgrade pip`
- `pip install -r requirements.txt`
- `python concept-maker_gui.py`
Ensure Ollama is running before generating concepts: ```bash
- Install: https://ollama.com npm install
- Pull a model: `ollama pull mistral3.2-small:24b` ```
- Start service (if not auto-started): `ollama serve`
## Usage Install Python backend dependencies:
- Add files/folders via drag & drop or the Add buttons.
- Write or paste notes in the Notes panel.
- Choose the Ollama model (or keep your default).
- Click to generate the Concept; edit as needed.
- Save: the app can save to a local repo and push to a remote.
### Prior‑Art Search (SearXNG) ```bash
- In the Notes section, click "Find Prior Art". python3 -m venv .venv
- Configure the SearXNG endpoint in the bottom bar (default `http://localhost:8888`). source .venv/bin/activate
- The app will: python -m pip install --upgrade pip
- Use the selected Ollama model to generate exactly three search queries (based on your Notes, Knowledge Base, and asset filenames). pip install -r requirements.txt
- Query SearXNG, fetch promising pages, embed them with Ollama embeddings (`bge-m3:latest` by default), and rerank by relevance. ```
- Open a results window showing URLs, scores, and content snippets; double‑click a row to open in your browser.
## Configuration Ensure Ollama is running before using model-backed actions:
Environment variables (optional):
- `OLLAMA_HOST`: override Ollama URL (default `http://localhost:11434`).
- `IDEA_HOLE_MODEL`: default model name shown in the UI.
- `IDEA_HOLE_REMOTE`: default Git remote URL.
- `SEARX_URL`: default SearXNG base URL for prior‑art search (default `http://localhost:8888`).
## Data & Storage ```bash
- Working data lives under `./.idea-hole/`: ollama serve
- `files/`: symlinks/copies of added files ```
- `corpus.jsonl`: unified knowledge base
- `sessions.jsonl`: saved sessions metadata
## Platform Notes
- macOS dock icon: if you install PyObjC (`pip install pyobjc`), the app also sets the dock icon from `icon.png`.
- Drag & drop requires `tkinterdnd2`; otherwise, the app uses the add buttons.
- PDF extraction works best with `pymupdf` installed.
## Troubleshooting
- Tk import errors on Linux: install `python3-tk` via your package manager.
- Ollama connection errors: ensure `ollama serve` is running and the model is pulled.
- Prior‑art search returns nothing: ensure your SearXNG instance is reachable at the configured URL and supports `/search?format=json`.
- Pip fails on non-Python entries in `requirements.txt`: install those tools via your OS, or comment out the offending lines and rerun the install.
## Development ## Development
- Code entry point: `concept-maker_gui.py`
- Launcher script: `run.sh`
- Optional corpus builder: `corpus_builder.py` (if present) is invoked for richer ingestion; otherwise, a simple built‑in fallback is used.
Prior‑art module: `websearch.py` Run the desktop app:
```bash
npm run dev
```
Run the web UI in a browser:
```bash
npm run dev:web
```
Build the frontend:
```bash
npm run build
```
Build the desktop bundle:
```bash
npm run tauri build
```
## Project Layout
- `src/`: React frontend
- `src-tauri/`: Tauri desktop shell and Rust commands
- `concept_api.py`: JSON action backend invoked by Tauri
- `corpus_builder.py`: optional richer file ingestion pipeline
- `websearch.py`: prior-art search helpers
- `requirements.txt`: Python backend dependencies
## Configuration
Environment variables:
- `OLLAMA_HOST`: override the Ollama URL
- `IDEA_HOLE_MODEL`: default model name
- `SEARX_URL`: default SearXNG base URL
Runtime data is stored in `.idea-hole/`.

File diff suppressed because it is too large Load Diff

1436
concept_api.py Normal file

File diff suppressed because it is too large Load Diff

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 946 KiB

12
index.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Idea -> Concept</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

34
package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "concept-maker-tauri",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "tauri dev",
"icons": "tauri icon icon.png",
"prepare:tauri-dev": "npm run icons && npm run build:backend && npm run dev:vite",
"prepare:tauri-build": "npm run icons && npm run build:backend && npm run build:web",
"build:backend": "node scripts/build-python-sidecar.mjs",
"dev:vite": "vite --host 127.0.0.1",
"dev:web": "vite --host 127.0.0.1 --open",
"build": "npm run build:web",
"build:web": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"markdown-it": "14.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@tauri-apps/cli": "^2.0.0",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.6.3",
"vite": "^5.4.8"
}
}

View File

@@ -1,4 +1,4 @@
# Core libraries used by the GUI (concept_gui.py) and corpus builder # Core libraries used by the Tauri Python backend and corpus builder
pymupdf pymupdf
beautifulsoup4 beautifulsoup4
requests requests
@@ -8,7 +8,6 @@ numpy
tqdm tqdm
ebooklib ebooklib
markdown markdown
tkinterdnd2
pdflatex pdflatex
# Optional: language detection and image text-likeness improvements # Optional: language detection and image text-likeness improvements
@@ -18,6 +17,7 @@ opencv-python-headless
# Optional (ASR for audio/video in corpus_builder.py) # Optional (ASR for audio/video in corpus_builder.py)
openai-whisper openai-whisper
torch torch
transformers
# Notes (external binaries, install via system package manager): # Notes (external binaries, install via system package manager):
# - pandoc (for high‑quality Markdown→PDF) # - pandoc (for high‑quality Markdown→PDF)

32
run.sh
View File

@@ -1,32 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Resolve to repo root (directory of this script)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Pick a Python executable
if command -v python3 >/dev/null 2>&1; then
PY=python3
else
PY=python
fi
echo "[setup] Creating virtual environment in .venv"
"$PY" -m venv .venv
# Activate venv
echo "[setup] Activating virtual environment"
source .venv/bin/activate
# Upgrade pip (optional but helpful)
python -m pip install --upgrade pip >/dev/null 2>&1 || true
# Install requirements
echo "[deps] Installing requirements from requirements.txt"
python -m pip install -r requirements.txt
# Launch the app
echo "[run] Starting Concept Maker GUI"
exec python concept-maker_gui.py

View File

@@ -0,0 +1,110 @@
import { existsSync, mkdirSync, statSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { execFileSync, spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const python = existsSync(join(root, ".venv", "bin", "python"))
? join(root, ".venv", "bin", "python")
: "python3";
function run(command, args, options = {}) {
const result = spawnSync(command, args, {
cwd: root,
stdio: "inherit",
env: process.env,
...options,
});
if (result.status !== 0) {
process.exit(result.status ?? 1);
}
}
function read(command, args) {
return execFileSync(command, args, { cwd: root, encoding: "utf8" }).trim();
}
function targetTriple() {
const explicit =
process.env.TAURI_ENV_TARGET_TRIPLE ||
process.env.CARGO_BUILD_TARGET ||
process.env.TARGET;
if (explicit) return explicit;
const rustc = read("rustc", ["-vV"]);
const host = rustc
.split(/\r?\n/)
.find((line) => line.startsWith("host:"))
?.replace("host:", "")
.trim();
if (!host) {
throw new Error("Could not determine Rust target triple.");
}
return host;
}
function newestMtime(paths) {
return Math.max(...paths.map((path) => statSync(path).mtimeMs));
}
const target = targetTriple();
const binariesDir = join(root, "src-tauri", "binaries");
const sidecar = join(binariesDir, `concept-api-${target}${target.includes("windows") ? ".exe" : ""}`);
const sources = [
join(root, "concept_api.py"),
join(root, "websearch.py"),
];
mkdirSync(binariesDir, { recursive: true });
if (
existsSync(sidecar) &&
statSync(sidecar).mtimeMs >= newestMtime(sources) &&
process.argv.includes("--force") === false
) {
console.log(`Python sidecar is up to date: ${sidecar}`);
process.exit(0);
}
const pyinstallerCheck = spawnSync(python, ["-m", "PyInstaller", "--version"], {
cwd: root,
stdio: "ignore",
});
if (pyinstallerCheck.status !== 0) {
run(python, ["-m", "pip", "install", "pyinstaller"]);
}
run(python, [
"-m",
"PyInstaller",
"--noconfirm",
"--clean",
"--onefile",
"--name",
`concept-api-${target}`,
"--distpath",
binariesDir,
"--workpath",
join(root, ".sidecar-build", "work"),
"--specpath",
join(root, ".sidecar-build"),
"--paths",
root,
"--hidden-import",
"fitz",
"--hidden-import",
"bs4",
"--hidden-import",
"PIL",
"--hidden-import",
"PIL.Image",
"--exclude-module",
"torch",
"--exclude-module",
"transformers",
"--exclude-module",
"whisper",
"--exclude-module",
"cv2",
join(root, "concept_api.py"),
]);

14
src-tauri/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "concept-maker"
version = "0.1.0"
edition = "2021"
build = "build.rs"
[dependencies]
tauri = { version = "2", features = [] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-dialog = "2"
[build-dependencies]
tauri-build = { version = "2", features = [] }

16
src-tauri/build.rs Normal file
View File

@@ -0,0 +1,16 @@
fn main() {
for path in [
"../icon.png",
"icons/icon.png",
"icons/32x32.png",
"icons/64x64.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico",
] {
println!("cargo:rerun-if-changed={path}");
}
tauri_build::build()
}

View File

@@ -0,0 +1,10 @@
{
"identifier": "default",
"description": "Default capabilities",
"windows": ["main"],
"permissions": [
"core:default",
"dialog:default",
"run-python-action"
]
}

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src-tauri/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,4 @@
[[permission]]
identifier = "run-python-action"
description = "Allow the UI to invoke the Python backend"
commands.allow = ["run_python_action", "open_path"]

250
src-tauri/src/lib.rs Normal file
View File

@@ -0,0 +1,250 @@
use serde_json::Value;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command as ProcessCommand, Stdio};
use tauri::{
menu::{Menu, MenuItem, Submenu},
AppHandle, Emitter, Manager,
};
fn repo_root() -> PathBuf {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
manifest_dir.parent().unwrap_or(&manifest_dir).to_path_buf()
}
enum Backend {
Sidecar(PathBuf),
Source { python: String, script: PathBuf },
}
fn sidecar_names() -> Vec<&'static str> {
if cfg!(target_os = "windows") {
vec![
"concept-api.exe",
"concept-api-x86_64-pc-windows-msvc.exe",
"concept-api-aarch64-pc-windows-msvc.exe",
]
} else if cfg!(target_os = "macos") {
vec![
"concept-api",
"concept-api-aarch64-apple-darwin",
"concept-api-x86_64-apple-darwin",
]
} else {
vec![
"concept-api",
"concept-api-x86_64-unknown-linux-gnu",
"concept-api-aarch64-unknown-linux-gnu",
]
}
}
fn push_sidecar_candidates(candidates: &mut Vec<PathBuf>, dir: &Path) {
for name in sidecar_names() {
candidates.push(dir.join(name));
}
}
fn sidecar_candidates(app: &AppHandle) -> Vec<PathBuf> {
let mut candidates = Vec::new();
let root = repo_root();
push_sidecar_candidates(&mut candidates, &root.join("src-tauri").join("binaries"));
if let Ok(exe) = std::env::current_exe() {
if let Some(exe_dir) = exe.parent() {
push_sidecar_candidates(&mut candidates, exe_dir);
if let Some(contents_dir) = exe_dir.parent() {
push_sidecar_candidates(&mut candidates, &contents_dir.join("Resources"));
}
}
}
if let Ok(resource_dir) = app.path().resource_dir() {
push_sidecar_candidates(&mut candidates, &resource_dir);
push_sidecar_candidates(&mut candidates, &resource_dir.join("binaries"));
}
candidates
}
fn bundled_sidecar(app: &AppHandle) -> Option<PathBuf> {
sidecar_candidates(app)
.into_iter()
.find(|candidate| candidate.is_file())
}
fn source_backend_script() -> PathBuf {
repo_root().join("concept_api.py")
}
fn backend(app: &AppHandle) -> Result<Backend, String> {
let script = source_backend_script();
if cfg!(debug_assertions) && script.exists() {
return Ok(Backend::Source {
python: "python3".to_string(),
script,
});
}
if let Some(sidecar) = bundled_sidecar(app) {
return Ok(Backend::Sidecar(sidecar));
}
if script.exists() {
return Ok(Backend::Source {
python: "python3".to_string(),
script,
});
}
Err("Python backend not found. Rebuild the app to package the backend sidecar.".to_string())
}
fn backend_data_dir(app: &AppHandle, backend: &Backend) -> PathBuf {
match backend {
Backend::Source { .. } => repo_root().join(".idea-hole"),
Backend::Sidecar(_) => app
.path()
.app_data_dir()
.unwrap_or_else(|_| repo_root().join(".idea-hole")),
}
}
fn command_for_backend(backend: &Backend) -> ProcessCommand {
match backend {
Backend::Sidecar(path) => ProcessCommand::new(path),
Backend::Source { python, script } => {
let mut command = ProcessCommand::new(python);
command.arg(script);
command
}
}
}
fn run_backend(app: &AppHandle, backend: &Backend, input: &str) -> Result<Vec<u8>, String> {
let data_dir = backend_data_dir(app, backend);
if let Err(err) = std::fs::create_dir_all(&data_dir) {
return Err(format!("Failed to create backend data directory: {err}"));
}
let cwd = match backend {
Backend::Source { .. } => repo_root(),
Backend::Sidecar(_) => data_dir.clone(),
};
let mut child = match command_for_backend(backend)
.current_dir(cwd)
.env("CONCEPT_MAKER_DATA_DIR", &data_dir)
.env(
"PATH",
"/opt/homebrew/bin:/usr/local/bin:/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
Ok(child) => child,
Err(err) => {
return Err(format!("Failed to start Python backend: {err}"));
}
};
if let Some(mut stdin) = child.stdin.take() {
if let Err(err) = stdin.write_all(input.as_bytes()) {
return Err(format!("Failed to write to Python stdin: {err}"));
}
}
let output = child
.wait_with_output()
.map_err(|err| format!("Python backend failed to finish: {err}"))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
return Err(format!("Python backend failed: {stderr}"));
}
Ok(output.stdout)
}
#[tauri::command]
fn run_python_action(app: AppHandle, action: String, payload: Value) -> Result<Value, String> {
let req = serde_json::json!({
"action": action,
"payload": payload,
});
let input = serde_json::to_string(&req).map_err(|e| e.to_string())?;
let backend = backend(&app)?;
let stdout = run_backend(&app, &backend, &input)?;
let resp: Value = serde_json::from_slice(&stdout).map_err(|e| e.to_string())?;
if resp.get("ok") == Some(&Value::Bool(true)) {
Ok(resp.get("data").cloned().unwrap_or(Value::Null))
} else {
let error = resp
.get("error")
.and_then(|v| v.as_str())
.unwrap_or("Unknown backend error");
Err(error.to_string())
}
}
#[tauri::command]
fn open_path(path: String) -> Result<(), String> {
let path = PathBuf::from(path);
if !path.exists() {
return Err(format!("Path does not exist: {}", path.display()));
}
let mut command = if cfg!(target_os = "macos") {
let mut command = ProcessCommand::new("open");
command.arg(&path);
command
} else if cfg!(target_os = "windows") {
let mut command = ProcessCommand::new("cmd");
command.arg("/C").arg("start").arg("").arg(&path);
command
} else {
let mut command = ProcessCommand::new("xdg-open");
command.arg(&path);
command
};
command
.spawn()
.map(|_| ())
.map_err(|err| format!("Failed to open {}: {err}", path.display()))
}
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.menu(|handle| {
let quit_item =
MenuItem::with_id(handle, "app-quit", "Quit", true, Some("CmdOrCtrl+Q"))?;
let app_menu = Submenu::with_items(handle, "Concept Maker", true, &[&quit_item])?;
let new_item = MenuItem::with_id(handle, "file-new", "New", true, None::<&str>)?;
let open_item = MenuItem::with_id(handle, "file-open", "Open", true, None::<&str>)?;
let save_item = MenuItem::with_id(handle, "file-save", "Save", true, None::<&str>)?;
let file_menu =
Submenu::with_items(handle, "File", true, &[&new_item, &open_item, &save_item])?;
let settings_item =
MenuItem::with_id(handle, "settings-open", "Settings", true, None::<&str>)?;
let settings_menu = Submenu::with_items(handle, "Settings", true, &[&settings_item])?;
Menu::with_items(handle, &[&app_menu, &file_menu, &settings_menu])
})
.on_menu_event(|app, event| match event.id().as_ref() {
"app-quit" => {
app.exit(0);
}
"file-new" | "file-open" | "file-save" | "settings-open" => {
let _ = app.emit("app-menu-action", event.id().as_ref());
}
_ => {}
})
.invoke_handler(tauri::generate_handler![run_python_action, open_path])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

3
src-tauri/src/main.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
concept_maker::run();
}

39
src-tauri/tauri.conf.json Normal file
View File

@@ -0,0 +1,39 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
"productName": "Concept Maker",
"version": "0.1.0",
"identifier": "com.giers.conceptmaker",
"build": {
"beforeDevCommand": "npm run prepare:tauri-dev",
"beforeBuildCommand": "npm run prepare:tauri-build",
"devUrl": "http://127.0.0.1:5173",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"label": "main",
"title": "Idea -> Concept",
"width": 1200,
"height": 820,
"minWidth": 900,
"minHeight": 640
}
]
},
"bundle": {
"active": true,
"targets": "all",
"externalBin": [
"binaries/concept-api"
],
"icon": [
"icons/icon.png",
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}

966
src/App.tsx Normal file
View File

@@ -0,0 +1,966 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { open, save } from "@tauri-apps/plugin-dialog";
import { invoke } from "@tauri-apps/api/core";
import { getCurrentWebview } from "@tauri-apps/api/webview";
import { markdownToHTML } from "./markdown/markdown";
import "./markdown/markdown-render.css";
type FileEntry = {
kind: "file";
path: string;
name: string;
type: string;
size: string;
};
type UrlEntry = {
kind: "url";
url: string;
name: string;
type: "url";
size: string;
};
type RowEntry = FileEntry | UrlEntry;
type RephraseVariant = {
key: string;
label: string;
text: string;
};
type SessionSummary = {
title: string;
description: string;
saved_at: number;
};
type PriorArtResult = {
url: string;
title?: string;
score?: number;
snippet?: string;
};
type PriorArtResponse = {
queries: string[];
lang?: string;
results: PriorArtResult[];
};
async function runBackend<T>(action: string, payload: Record<string, unknown>): Promise<T> {
return (await invoke("run_python_action", { action, payload })) as T;
}
async function openPath(path: string): Promise<void> {
await invoke("open_path", { path });
}
function formatTime(ts: number): string {
if (!ts) return "";
const d = new Date(ts * 1000);
return d.toLocaleString();
}
function rowId(row: RowEntry): string {
return row.kind === "file" ? `file:${row.path}` : `url:${row.url}`;
}
function pdfFileNameFromTitle(title: string, conceptText: string): string {
const heading = conceptText.match(/^#\s+(.+)$/m)?.[1] ?? "";
const rawName = (title || heading || "concept").trim();
const safeName = rawName
.replace(/\s+/g, "-")
.replace(/[^a-zA-Z0-9._-]/g, "-")
.replace(/-+/g, "-")
.replace(/^[-_.]+|[-_.]+$/g, "");
return `${safeName || "concept"}.pdf`;
}
function ensurePdfExtension(path: string): string {
return /\.pdf$/i.test(path) ? path : `${path}.pdf`;
}
function fallbackIdeaText(title: string, description: string, concept: string): string {
return [
title.trim() ? `Title: ${title.trim()}` : "",
description.trim() ? `Description: ${description.trim()}` : "",
concept.trim(),
]
.filter(Boolean)
.join("\n\n");
}
function currentIdeaText(notes: string, title: string, description: string, concept: string): string {
return notes.trim() ? notes : fallbackIdeaText(title, description, concept);
}
export default function App() {
const [status, setStatusMessage] = useState("");
const [statusVersion, setStatusVersion] = useState(0);
const [statusVisible, setStatusVisible] = useState(false);
const [files, setFiles] = useState<FileEntry[]>([]);
const [websites, setWebsites] = useState<UrlEntry[]>([]);
const [notes, setNotes] = useState("");
const [rephraseVariants, setRephraseVariants] = useState<RephraseVariant[]>([]);
const [rephraseSelected, setRephraseSelected] = useState<string | null>(null);
const [concept, setConcept] = useState("");
const [markdownPreview, setMarkdownPreview] = useState(false);
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [ollamaHost, setOllamaHost] = useState("http://localhost:11434");
const [ollamaModel, setOllamaModel] = useState("Select model...");
const [searxUrl, setSearxUrl] = useState("http://localhost:8888");
const [models, setModels] = useState<string[]>([]);
const [busy, setBusy] = useState<Record<string, boolean>>({});
const [sessionModalOpen, setSessionModalOpen] = useState(false);
const [sessions, setSessions] = useState<SessionSummary[]>([]);
const [sessionsLoading, setSessionsLoading] = useState(false);
const [priorModalOpen, setPriorModalOpen] = useState(false);
const [priorData, setPriorData] = useState<PriorArtResponse | null>(null);
const [websiteModalOpen, setWebsiteModalOpen] = useState(false);
const [websiteInput, setWebsiteInput] = useState("");
const [websiteError, setWebsiteError] = useState("");
const [settingsModalOpen, setSettingsModalOpen] = useState(false);
const menuActionRef = useRef<(action: string) => void>(() => undefined);
const rows = useMemo<RowEntry[]>(() => [...files, ...websites], [files, websites]);
const markdownPreviewHtml = useMemo(
() => (markdownPreview ? markdownToHTML(concept) : ""),
[concept, markdownPreview]
);
const setStatus = (message: string) => {
setStatusMessage(message);
setStatusVersion((value) => value + 1);
};
useEffect(() => {
if (!status) {
setStatusVisible(false);
return;
}
setStatusVisible(true);
const timer = window.setTimeout(() => {
setStatusVisible(false);
}, 5000);
return () => window.clearTimeout(timer);
}, [status, statusVersion]);
useEffect(() => {
let mounted = true;
const bootstrap = async () => {
try {
const settings = await runBackend<Record<string, string>>("load_settings", {});
if (!mounted) return;
if (settings.ollama_host) setOllamaHost(settings.ollama_host);
if (settings.ollama_model) setOllamaModel(settings.ollama_model);
if (settings.searx_url) setSearxUrl(settings.searx_url);
} catch {
// ignore
}
try {
const list = await runBackend<string[]>("list_models", {});
if (!mounted) return;
setModels(list);
} catch {
// ignore
}
};
void bootstrap();
return () => {
mounted = false;
};
}, []);
useEffect(() => {
const timer = setTimeout(() => {
runBackend("save_settings", {
settings: {
ollama_host: ollamaHost,
ollama_model: ollamaModel,
searx_url: searxUrl,
},
}).catch(() => undefined);
}, 400);
return () => clearTimeout(timer);
}, [ollamaHost, ollamaModel, searxUrl]);
useEffect(() => {
let unlisten: (() => void) | undefined;
const attach = async () => {
try {
const current = getCurrentWebview() as any;
unlisten = await current.onDragDropEvent((event: any) => {
if (event.payload?.type === "drop") {
const paths = event.payload.paths ?? [];
if (paths.length) {
void addFilesByPath(paths, true);
}
}
});
} catch {
// optional
}
};
void attach();
return () => {
if (unlisten) unlisten();
};
}, [files]);
const addFilesByPath = async (paths: string[], expandDirs: boolean) => {
if (!paths.length) return;
setStatus("Indexing files...");
try {
const stats = await runBackend<{ name: string; path: string; type: string; size: string }[]>(
"stat_paths",
{ paths, expand_dirs: expandDirs }
);
setFiles((prev) => {
const existing = new Map(prev.map((f) => [f.path, f]));
stats.forEach((item) => {
if (!existing.has(item.path)) {
existing.set(item.path, {
kind: "file",
path: item.path,
name: item.name,
type: item.type,
size: item.size,
});
}
});
return Array.from(existing.values());
});
setStatus(`Added ${stats.length} item(s)`);
} catch (err) {
setStatus("Failed to add files");
console.error(err);
}
};
const onAddFiles = async () => {
const selection = await open({ multiple: true, title: "Select files" });
if (!selection) return;
const paths = Array.isArray(selection) ? selection : [selection];
await addFilesByPath(paths as string[], false);
};
const onAddWebsite = () => {
setWebsiteInput("");
setWebsiteError("");
setWebsiteModalOpen(true);
};
const onSubmitWebsite = () => {
const trimmed = websiteInput.trim();
if (!/^https?:\/\//i.test(trimmed)) {
setWebsiteError("Enter a valid http(s) URL.");
return;
}
if (websites.some((w) => w.url === trimmed)) {
setWebsiteError("This website is already in the table.");
return;
}
const name = trimmed.replace(/^https?:\/\//, "").slice(0, 60);
setWebsites((prev) => [
...prev,
{
kind: "url",
url: trimmed,
name,
type: "url",
size: "web",
},
]);
setWebsiteModalOpen(false);
setWebsiteInput("");
setWebsiteError("");
setStatus(`Added ${name}`);
};
const closeWebsiteModal = () => {
setWebsiteModalOpen(false);
setWebsiteInput("");
setWebsiteError("");
};
const onRemoveRow = (row: RowEntry) => {
const label = row.kind === "file" ? row.path : row.url;
if (!window.confirm(`Remove "${row.name}" from Files & Websites?\n\n${label}`)) return;
if (row.kind === "file") {
setFiles((prev) => prev.filter((file) => file.path !== row.path));
} else {
setWebsites((prev) => prev.filter((website) => website.url !== row.url));
}
setStatus(`Removed ${row.name}`);
};
const onRephrase = async () => {
if (!ollamaModel || ollamaModel === "Select model...") {
window.alert("Please select a model first.");
return;
}
const ideaText = currentIdeaText(notes, title, description, concept);
if (!ideaText.trim()) {
window.alert("Add notes or a concept to rephrase.");
return;
}
setBusy((prev) => ({ ...prev, rephrase: true }));
setStatus("Rephrasing...");
try {
const variants = await runBackend<RephraseVariant[]>("rephrase", {
note: ideaText,
ollama_host: ollamaHost,
model: ollamaModel,
});
setRephraseVariants(variants);
setRephraseSelected(variants[0]?.key ?? null);
setStatus("Rephrase complete");
} catch (err) {
setStatus("Rephrase failed");
console.error(err);
window.alert("Rephrase failed. Check console for details.");
} finally {
setBusy((prev) => ({ ...prev, rephrase: false }));
}
};
const onExtend = async () => {
if (!ollamaModel || ollamaModel === "Select model...") {
window.alert("Please select a model first.");
return;
}
const ideaText = currentIdeaText(notes, title, description, concept);
if (!ideaText.trim()) {
window.alert("Add notes or a concept to extend.");
return;
}
setBusy((prev) => ({ ...prev, extend: true }));
setStatus("Extending...");
try {
const extension = await runBackend<string>("extend", {
note: ideaText,
ollama_host: ollamaHost,
model: ollamaModel,
});
setNotes((prev) => (prev.trim() ? `${prev}\n${extension}` : extension));
setStatus("Extension ready");
} catch (err) {
setStatus("Extend failed");
console.error(err);
window.alert("Extend failed. Check console for details.");
} finally {
setBusy((prev) => ({ ...prev, extend: false }));
}
};
const onGenerateConcept = async () => {
if (!ollamaModel || ollamaModel === "Select model...") {
window.alert("Please select a model first.");
return;
}
if (!notes.trim() && !files.length && !websites.length) {
window.alert("Add files, websites, or notes first.");
return;
}
setBusy((prev) => ({ ...prev, generate: true }));
setStatus("Generating concept...");
try {
const result = await runBackend<{ concept: string; title: string; description: string }>(
"generate_concept",
{
notes,
files: files.map((f) => f.path),
websites: websites.map((w) => w.url),
ollama_host: ollamaHost,
model: ollamaModel,
}
);
setConcept(result.concept);
setTitle(result.title);
setDescription(result.description);
setStatus("Concept generated");
} catch (err) {
setStatus("Generation failed");
console.error(err);
window.alert("Generation failed. Check console for details.");
} finally {
setBusy((prev) => ({ ...prev, generate: false }));
}
};
const onPriorArt = async () => {
if (!ollamaModel || ollamaModel === "Select model...") {
window.alert("Please select a model first.");
return;
}
const priorArtNotes = currentIdeaText(notes, title, description, concept);
setBusy((prev) => ({ ...prev, prior: true }));
setStatus("Searching prior art...");
try {
const data = await runBackend<PriorArtResponse>("prior_art", {
notes: priorArtNotes,
concept,
title,
description,
files: files.map((f) => f.path),
websites: websites.map((w) => w.url),
ollama_host: ollamaHost,
model: ollamaModel,
searx_url: searxUrl,
});
setPriorData(data);
setPriorModalOpen(true);
setStatus("Prior art ready");
} catch (err) {
setStatus("Prior art failed");
console.error(err);
window.alert("Prior art search failed. Check console for details.");
} finally {
setBusy((prev) => ({ ...prev, prior: false }));
}
};
const onExportPdf = async () => {
if (!concept.trim()) {
window.alert("Generate or paste concept text first.");
return;
}
setBusy((prev) => ({ ...prev, preview: true }));
setStatus("Choose where to save the PDF...");
try {
const selectedPath = await save({
title: "Export PDF",
defaultPath: pdfFileNameFromTitle(title, concept),
filters: [{ name: "PDF", extensions: ["pdf"] }],
canCreateDirectories: true,
});
if (!selectedPath) {
setStatus("PDF export cancelled");
return;
}
setStatus("Exporting PDF...");
const result = await runBackend<{ ok: boolean; pdf_path: string; log_path: string }>("preview_pdf", {
concept,
title,
files: files.map((f) => f.path),
output_path: ensurePdfExtension(selectedPath),
});
if (result.ok) {
setStatus("Opening exported PDF...");
try {
await openPath(result.pdf_path);
setStatus("PDF exported and opened");
} catch (openErr) {
setStatus("PDF exported");
console.error(openErr);
window.alert(`PDF exported to:\n${result.pdf_path}\n\nCould not open it automatically.`);
}
} else {
setStatus("Export failed");
window.alert(`Export failed. Log: ${result.log_path}`);
}
} catch (err) {
setStatus("Export failed");
console.error(err);
window.alert("Export failed. Check console for details.");
} finally {
setBusy((prev) => ({ ...prev, preview: false }));
}
};
const onNewSession = () => {
if (notes || concept || files.length || websites.length) {
const ok = window.confirm("Clear the current session?");
if (!ok) return;
}
setFiles([]);
setWebsites([]);
setNotes("");
setRephraseVariants([]);
setRephraseSelected(null);
setConcept("");
setTitle("");
setDescription("");
};
const onSaveSession = async () => {
if (!title.trim()) {
window.alert("Please enter a Title before saving.");
return;
}
try {
const existing = await runBackend<SessionSummary[]>("list_sessions", {});
const exists = existing.some((s) => s.title === title.trim());
if (exists) {
const ok = window.confirm(`A session titled "${title}" exists. Overwrite it?`);
if (!ok) return;
}
await runBackend("save_session", {
payload: {
title,
description,
notes,
concept,
files: files.map((f) => ({ path: f.path })),
websites: websites.map((w) => ({ url: w.url })),
rephrase_variants: rephraseVariants,
rephrase_selected_key: rephraseSelected,
},
allow_overwrite: true,
});
setStatus("Session saved");
} catch (err) {
console.error(err);
window.alert("Failed to save session.");
}
};
const onOpenSession = async () => {
setSessionModalOpen(true);
setSessionsLoading(true);
setSessions([]);
try {
const list = await runBackend<SessionSummary[]>("list_sessions", {});
setSessions(list.sort((a, b) => (b.saved_at || 0) - (a.saved_at || 0)));
} catch (err) {
console.error(err);
setSessionModalOpen(false);
window.alert("Failed to load sessions.");
} finally {
setSessionsLoading(false);
}
};
const applySession = async (sessionTitle: string) => {
try {
const data = await runBackend<any>("load_session", { title: sessionTitle });
if (!data) return;
setTitle(data.title || "");
setDescription(data.description || "");
setNotes(data.notes || "");
setConcept(data.concept || "");
setFiles(
(data.files || []).map((f: any) => ({
kind: "file",
path: f.path,
name: f.path.split(/[\\/]/).pop() || f.path,
type: (f.path.split(".").pop() || "file").toLowerCase(),
size: "?",
}))
);
setWebsites(
(data.websites || []).map((w: any) => ({
kind: "url",
url: w.url,
name: w.url.replace(/^https?:\/\//, "").slice(0, 60),
type: "url",
size: "web",
}))
);
setRephraseVariants(data.rephrase_variants || []);
setRephraseSelected(data.rephrase_selected_key || null);
setSessionModalOpen(false);
setStatus("Session loaded");
} catch (err) {
console.error(err);
window.alert("Failed to open session.");
}
};
useEffect(() => {
menuActionRef.current = (action: string) => {
switch (action) {
case "file-new":
onNewSession();
break;
case "file-open":
void onOpenSession();
break;
case "file-save":
void onSaveSession();
break;
case "settings-open":
setSettingsModalOpen(true);
break;
}
};
});
useEffect(() => {
let unlisten: (() => void) | undefined;
let disposed = false;
listen<string>("app-menu-action", (event) => {
menuActionRef.current(event.payload);
})
.then((cleanup) => {
if (disposed) {
cleanup();
} else {
unlisten = cleanup;
}
})
.catch(() => undefined);
return () => {
disposed = true;
if (unlisten) unlisten();
};
}, []);
return (
<div className="app">
<div className="panes">
<div className="column">
<section className="panel notes-panel">
<div className="panel-title">
<h2>Notes / Thoughts</h2>
<span>Scratchpad for raw ideas</span>
</div>
<textarea
className="notes-area"
value={notes}
onChange={(e) => setNotes(e.target.value)}
placeholder="Drop in fragments, problem statements, or constraints..."
/>
{rephraseVariants.length > 0 && (
<div className="rephrase-panel">
<strong style={{ fontSize: "12px", color: "var(--accent)" }}>Rephrase variants</strong>
<div className="rephrase-list">
{rephraseVariants.map((variant) => (
<div
key={variant.key}
className={`rephrase-item ${rephraseSelected === variant.key ? "active" : ""}`}
onClick={() => {
setRephraseSelected(variant.key);
setNotes(variant.text);
}}
>
<div style={{ fontWeight: 600 }}>{variant.label}</div>
<div style={{ fontSize: "11px", color: "var(--subtle)" }}>
{variant.text.slice(0, 120)}{variant.text.length > 120 ? "..." : ""}
</div>
</div>
))}
</div>
</div>
)}
<div className="controls">
<button onClick={onRephrase} disabled={busy.rephrase}>Rephrase</button>
<button onClick={onExtend} disabled={busy.extend}>Extend</button>
<button onClick={onPriorArt} disabled={busy.prior}>Find Prior Art</button>
<button className="primary" onClick={onGenerateConcept} disabled={busy.generate}>Generate Concept</button>
</div>
</section>
<section className="panel files-panel">
<div className="panel-title">
<h2>Files & Websites</h2>
<div className="panel-title-actions">
<button onClick={onAddFiles}>Add Files</button>
<button onClick={onAddWebsite}>Add URL</button>
</div>
</div>
<div className="table">
<div className="table-header">
<div>Name</div>
<div>Path</div>
<div>Type</div>
<div>Size</div>
<div>Remove</div>
</div>
<div className="table-body">
{rows.length === 0 && (
<div className="table-row" style={{ gridTemplateColumns: "1fr" }}>
<div style={{ color: "var(--muted)" }}>Drop files here or use Add Files / Add URL.</div>
</div>
)}
{rows.map((row) => (
<div key={rowId(row)} className="table-row">
<div>{row.name}</div>
<div>{row.kind === "file" ? row.path : row.url}</div>
<div>{row.type}</div>
<div>{row.size}</div>
<div>
<button
className="remove-row-button danger"
type="button"
onClick={() => onRemoveRow(row)}
aria-label={`Remove ${row.name}`}
title={`Remove ${row.name}`}
>
X
</button>
</div>
</div>
))}
</div>
</div>
</section>
</div>
<div className="column">
<section className="panel" style={{ flex: 1 }}>
<div className="panel-title">
<h2>{markdownPreview ? "Concept (Preview)" : "Concept (Editable)"}</h2>
<span>{markdownPreview ? "Rendered Markdown" : "Refine and publish"}</span>
</div>
{markdownPreview ? (
<div
className="markdown-preview md-root"
role="textbox"
aria-readonly="true"
tabIndex={0}
dangerouslySetInnerHTML={{
__html:
markdownPreviewHtml ||
'<p class="md-paragraph markdown-preview__empty">No concept markdown to preview.</p>',
}}
/>
) : (
<>
<div className="concept-meta">
<input value={title} onChange={(e) => setTitle(e.target.value)} placeholder="Title" />
<input value={description} onChange={(e) => setDescription(e.target.value)} placeholder="Description" />
</div>
<textarea
className="concept-editor"
value={concept}
onChange={(e) => setConcept(e.target.value)}
placeholder="Generated concept markdown appears here..."
/>
</>
)}
<div className="controls concept-actions">
<button onClick={() => setMarkdownPreview((value) => !value)}>
{markdownPreview ? "Edit Markdown" : "Preview Markdown"}
</button>
<button onClick={onExportPdf} disabled={busy.preview}>Export PDF</button>
</div>
</section>
</div>
</div>
{websiteModalOpen && (
<div
className="modal-backdrop"
role="presentation"
onMouseDown={(event) => {
if (event.target === event.currentTarget) {
closeWebsiteModal();
}
}}
>
<form
className="settings-window website-window"
role="dialog"
aria-modal="true"
aria-labelledby="website-title"
onSubmit={(event) => {
event.preventDefault();
onSubmitWebsite();
}}
>
<div className="settings-header">
<h3 id="website-title">Add URL</h3>
<button className="ghost" type="button" onClick={closeWebsiteModal}>
Close
</button>
</div>
<div className="website-form">
<label htmlFor="website-url">URL</label>
<input
id="website-url"
autoFocus
value={websiteInput}
onChange={(event) => {
setWebsiteInput(event.target.value);
if (websiteError) setWebsiteError("");
}}
placeholder="https://example.com"
type="url"
/>
{websiteError && <div className="form-error">{websiteError}</div>}
<div className="form-actions">
<button type="button" onClick={closeWebsiteModal}>Cancel</button>
<button className="primary" type="submit">Add URL</button>
</div>
</div>
</form>
</div>
)}
{sessionModalOpen && (
<div
className="modal-backdrop"
role="presentation"
onMouseDown={(event) => {
if (event.target === event.currentTarget) {
setSessionModalOpen(false);
}
}}
>
<div
className="settings-window session-window"
role="dialog"
aria-modal="true"
aria-labelledby="session-title"
>
<div className="settings-header">
<h3 id="session-title">Open Session</h3>
<button className="ghost" onClick={() => setSessionModalOpen(false)}>
Close
</button>
</div>
{sessionsLoading && <p>Loading sessions...</p>}
{!sessionsLoading && sessions.length === 0 && <p>No saved sessions yet.</p>}
<div className="session-list">
{!sessionsLoading &&
sessions.map((s) => (
<button
key={s.title}
className="ghost session-item"
onClick={() => applySession(s.title)}
>
<strong>{s.title}</strong>
<div className="session-description">{s.description}</div>
<div className="session-time">{formatTime(s.saved_at)}</div>
</button>
))}
</div>
</div>
</div>
)}
{settingsModalOpen && (
<div
className="modal-backdrop"
role="presentation"
onMouseDown={(event) => {
if (event.target === event.currentTarget) {
setSettingsModalOpen(false);
}
}}
>
<div
className="settings-window"
role="dialog"
aria-modal="true"
aria-labelledby="settings-title"
>
<div className="settings-header">
<h3 id="settings-title">Settings</h3>
<button className="ghost" onClick={() => setSettingsModalOpen(false)}>
Close
</button>
</div>
<div className="settings-grid">
<label htmlFor="settings-ollama-host">Ollama host</label>
<input
id="settings-ollama-host"
value={ollamaHost}
onChange={(e) => setOllamaHost(e.target.value)}
/>
<label htmlFor="settings-model">Model</label>
<select
id="settings-model"
value={ollamaModel}
onChange={(e) => setOllamaModel(e.target.value)}
>
<option value="Select model...">Select model...</option>
{models.map((m) => (
<option key={m} value={m}>
{m}
</option>
))}
</select>
<label htmlFor="settings-searx-url">SearXNG URL</label>
<input
id="settings-searx-url"
value={searxUrl}
onChange={(e) => setSearxUrl(e.target.value)}
/>
</div>
</div>
</div>
)}
{priorModalOpen && priorData && (
<div
style={{
position: "fixed",
inset: 0,
background: "rgba(69, 10, 10, 0.28)",
display: "grid",
placeItems: "center",
zIndex: 10,
}}
>
<div
style={{
background: "var(--panel)",
border: "1px solid var(--line)",
padding: "20px",
borderRadius: "6px",
width: "min(680px, 92vw)",
maxHeight: "85vh",
overflow: "auto",
boxShadow: "var(--dialog-shadow)",
}}
>
<h3 style={{ marginTop: 0 }}>Prior Art Results</h3>
<div style={{ marginBottom: "12px" }}>
<strong>Queries</strong>
<ul style={{ marginTop: "6px" }}>
{priorData.queries.map((q) => (
<li key={q} style={{ fontSize: "12px", color: "var(--ink)" }}>
{q}
</li>
))}
</ul>
</div>
{priorData.results.length === 0 && <p>No results found.</p>}
<div style={{ display: "flex", flexDirection: "column", gap: "12px" }}>
{priorData.results.map((r) => (
<div key={r.url} style={{ border: "1px solid var(--line)", padding: "12px", borderRadius: "4px", background: "var(--surface)" }}>
<div style={{ fontWeight: 600, marginBottom: "4px" }}>{r.title || r.url}</div>
<div style={{ fontSize: "12px", color: "var(--muted)" }}>{r.url}</div>
{r.snippet && (
<div style={{ marginTop: "6px", fontSize: "12px", color: "var(--ink)" }}>{r.snippet}</div>
)}
{typeof r.score === "number" && (
<div style={{ marginTop: "4px", fontSize: "11px", color: "var(--subtle)" }}>Score: {r.score.toFixed(3)}</div>
)}
</div>
))}
</div>
<div style={{ marginTop: "16px", textAlign: "right" }}>
<button onClick={() => setPriorModalOpen(false)}>Close</button>
</div>
</div>
</div>
)}
{statusVisible && status && (
<div className="status-toast" role="status" aria-live="polite">
{status}
</div>
)}
</div>
);
}

10
src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./styles.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@@ -0,0 +1,169 @@
.md-root {
--md-border-color: var(--line);
--md-surface: rgba(255, 255, 255, 0.68);
--md-surface-strong: var(--surface);
--md-text-color: var(--ink);
--md-muted-color: var(--muted);
--md-link-color: var(--accent);
--md-link-hover-color: var(--accent-strong);
--md-code-bg: #fff7f8;
--md-code-inline-bg: rgba(159, 18, 57, 0.08);
--md-code-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace;
color: var(--md-text-color);
font-size: 14px;
line-height: 1.55;
}
.md-heading {
margin: 1.35rem 0 0.65rem;
font-weight: 650;
line-height: 1.25;
color: var(--accent);
}
.md-root > .md-heading:first-child {
margin-top: 0;
}
.md-heading--1 {
font-size: 1.7rem;
}
.md-heading--2 {
font-size: 1.35rem;
}
.md-heading--3 {
font-size: 1.15rem;
}
.md-heading--4,
.md-heading--5,
.md-heading--6 {
font-size: 1rem;
}
.md-paragraph {
margin: 0 0 0.85rem;
}
.md-paragraph:last-child {
margin-bottom: 0;
}
.md-hr {
border: 0;
border-top: 1px solid var(--md-border-color);
margin: 1.4rem 0;
}
.md-list {
margin: 0.45rem 0 0.95rem;
padding-left: 1.35rem;
}
.md-list--unordered {
list-style: disc;
}
.md-list--ordered {
list-style: decimal;
}
.md-list__item {
margin: 0.18rem 0;
}
.md-blockquote {
margin: 1rem 0;
padding: 0.7rem 0.9rem;
border-left: 3px solid var(--accent);
background: var(--md-surface);
color: var(--md-muted-color);
}
.md-table {
width: 100%;
margin: 1rem 0;
border-collapse: separate;
border-spacing: 0;
border: 1px solid var(--md-border-color);
border-radius: var(--radius);
overflow: hidden;
}
.md-table thead {
background: var(--bg-main);
}
.md-table__head-cell,
.md-table__cell {
padding: 0.58rem 0.7rem;
vertical-align: top;
text-align: left;
border-bottom: 1px solid var(--md-border-color);
}
.md-table__row:last-child .md-table__cell {
border-bottom: none;
}
.md-align-left {
text-align: left;
}
.md-align-center {
text-align: center;
}
.md-align-right {
text-align: right;
}
.md-codeblock {
margin: 1rem 0 0.35rem;
padding: 0.75rem;
overflow: auto;
max-width: 100%;
border: 1px solid var(--md-border-color);
border-radius: var(--radius);
background: var(--md-code-bg);
}
.md-codeblock code {
display: block;
max-width: 100%;
font-family: var(--md-code-font);
font-size: 0.94em;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.md-inline-code {
padding: 0.1em 0.24em;
border-radius: 4px;
background: var(--md-code-inline-bg);
font-family: var(--md-code-font);
font-size: 0.94em;
}
.md-link {
color: var(--md-link-color);
text-decoration: underline;
text-underline-offset: 2px;
}
.md-link:hover,
.md-link:focus-visible {
color: var(--md-link-hover-color);
}
.md-image {
display: block;
max-width: 100%;
height: auto;
margin: 1rem 0;
border-radius: var(--radius);
}

320
src/markdown/markdown.ts Normal file
View File

@@ -0,0 +1,320 @@
import MarkdownIt from "markdown-it";
const EXTRA_BLANK_LINE_MARKER = "\uE000CONCEPT_MAKER_EXTRA_BLANK_LINE\uE000";
const escapeHtml = (value = "") =>
value
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const appendClass = (token: any, className: string) => {
const existing = token.attrGet("class");
token.attrSet("class", existing ? `${existing} ${className}` : className);
};
const removeAttr = (token: any, attrName: string) => {
const index = token.attrIndex(attrName);
if (index >= 0) token.attrs.splice(index, 1);
};
const alignmentClassFromToken = (token: any) => {
const style = token.attrGet("style") || "";
const match = style.match(/text-align:\s*(left|right|center)/i);
return `md-align-${match?.[1]?.toLowerCase() || "left"}`;
};
const safeLink = (hrefRaw: string) => {
const href = (hrefRaw || "").trim();
if (!href) return "";
if (href.startsWith("//")) return "";
if (/^(https?|mailto|tel):/i.test(href)) return href;
if (/^[./#]/.test(href)) return href;
if (!/^[a-z][a-z0-9+.-]*:/i.test(href)) return href;
return "";
};
const preserveExtraBlankLines = (source: string) =>
source.replace(/([^\n])(\n{3,})([^\n])/g, (_match, before, newlines, after) => {
const markers = Array.from(
{ length: newlines.length - 2 },
() => EXTRA_BLANK_LINE_MARKER
).join("\n\n");
return `${before}\n\n${markers}\n\n${after}`;
});
const restoreExtraBlankLines = (html: string) => {
const markerParagraph = new RegExp(
`<p class="md-paragraph">${escapeRegExp(EXTRA_BLANK_LINE_MARKER)}</p>\\n?`,
"g"
);
return html.replace(markerParagraph, "<br />");
};
const cleanMarkdownForPreview = (source: string) =>
source
.replace(/<think(?:ing)?>[\s\S]*?(?:<\/think(?:ing)?>|$)/gi, "")
.replace(/[\u00a0\u202f\u2007]/g, " ");
function balanceStreamingCodeFence(markdownSource: string) {
const lines = markdownSource.split(/\r?\n/);
let open: { fenceChar: string; fenceLen: number } | null = null;
for (const line of lines) {
if (!open) {
const match = line.match(/^\s*([`~]{3,})([^\s]*)?.*$/);
if (match) {
open = { fenceChar: match[1][0], fenceLen: match[1].length };
}
continue;
}
const closeFence = new RegExp(`^\\s*(${open.fenceChar}{${open.fenceLen},})\\s*$`);
if (closeFence.test(line)) {
open = null;
}
}
if (!open) return markdownSource;
const virtualFence = open.fenceChar.repeat(open.fenceLen);
return markdownSource.endsWith("\n")
? markdownSource + virtualFence
: `${markdownSource}\n${virtualFence}`;
}
const markdown = new MarkdownIt({
html: false,
linkify: true,
breaks: true,
typographer: false
});
markdown.linkify.set({ fuzzyEmail: false, fuzzyIP: false });
markdown.validateLink = (href: string) => Boolean(safeLink(href));
markdown.renderer.rules.paragraph_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-paragraph");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.heading_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
const level = tokens[idx].tag.replace(/^h/i, "") || "1";
appendClass(tokens[idx], `md-heading md-heading--${level}`);
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.hr = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-hr");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.bullet_list_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-list md-list--unordered");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.ordered_list_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-list md-list--ordered");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.list_item_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-list__item");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.blockquote_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-blockquote");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.table_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], "md-table");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.thead_open = (
tokens: any[],
idx: number,
options: any,
env: any,
self: any
) => {
env.inTableHead = true;
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.thead_close = (
tokens: any[],
idx: number,
options: any,
env: any,
self: any
) => {
env.inTableHead = false;
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.tr_open = (
tokens: any[],
idx: number,
options: any,
env: any,
self: any
) => {
appendClass(
tokens[idx],
env.inTableHead ? "md-table__row md-table__row--head" : "md-table__row"
);
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.th_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], `md-table__head-cell ${alignmentClassFromToken(tokens[idx])}`);
removeAttr(tokens[idx], "style");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.td_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
appendClass(tokens[idx], `md-table__cell ${alignmentClassFromToken(tokens[idx])}`);
removeAttr(tokens[idx], "style");
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.strong_open = () => "<b>";
markdown.renderer.rules.strong_close = () => "</b>";
markdown.renderer.rules.em_open = () => "<i>";
markdown.renderer.rules.em_close = () => "</i>";
markdown.renderer.rules.softbreak = () => "<br />";
markdown.renderer.rules.hardbreak = () => "<br />";
markdown.renderer.rules.code_inline = (tokens: any[], idx: number) =>
`<code class="md-inline-code">${escapeHtml(tokens[idx].content)}</code>`;
markdown.renderer.rules.fence = (tokens: any[], idx: number) => {
const info = tokens[idx].info.trim();
const languageClass = info.toLowerCase().replace(/[^a-z0-9_-]/g, "") || "code";
return `<pre class="md-codeblock"><code class="language-${languageClass}">${escapeHtml(tokens[idx].content).replace(
/\n$/,
""
)}</code></pre>`;
};
markdown.renderer.rules.code_block = (tokens: any[], idx: number) =>
`<pre class="md-codeblock"><code>${escapeHtml(tokens[idx].content).replace(
/\n$/,
""
)}</code></pre>`;
markdown.renderer.rules.link_open = (
tokens: any[],
idx: number,
options: any,
_env: any,
self: any
) => {
const href = safeLink(tokens[idx].attrGet("href") || "");
if (!href) return "";
tokens[idx].attrSet("href", href);
tokens[idx].attrSet("class", "md-link");
if (/^https?:\/\//i.test(href)) {
tokens[idx].attrSet("target", "_blank");
tokens[idx].attrSet("rel", "noreferrer noopener");
}
return self.renderToken(tokens, idx, options);
};
markdown.renderer.rules.image = (
tokens: any[],
idx: number,
options: any,
env: any,
self: any
) => {
const token = tokens[idx];
const src = safeLink(token.attrGet("src") || "");
if (!src) return escapeHtml(token.content || "");
token.attrSet("src", src);
token.attrSet("alt", self.renderInlineAsText(token.children, options, env));
token.attrSet("loading", "lazy");
appendClass(token, "md-image");
return self.renderToken(tokens, idx, options);
};
export function markdownToHTML(text: string) {
let source = cleanMarkdownForPreview(String(text ?? ""));
source = balanceStreamingCodeFence(source);
source = preserveExtraBlankLines(source);
const html = markdown.render(source, {});
return restoreExtraBlankLines(html).replace(/\n+$/g, "");
}

497
src/styles.css Normal file
View File

@@ -0,0 +1,497 @@
:root {
color-scheme: light;
--bg-main: #ffe4e6;
--bg-sidebar: #fff1f2;
--accent: #9f1239;
--accent-strong: #7c0e2e;
--border: #fff;
--line: #fecdd3;
--field-border: #fda4af;
--ink: #7f1d1d;
--muted: #9f1239;
--subtle: #be5d75;
--danger: #e11d48;
--surface: #fff;
--shadow: 0 1px 3px rgba(159, 18, 57, 0.08);
--dialog-shadow: 0 16px 40px rgba(159, 18, 57, 0.18);
--radius: 5px;
--control-radius: 4px;
--bg: var(--bg-main);
--panel: var(--bg-sidebar);
--panel-edge: var(--border);
}
* {
box-sizing: border-box;
}
html,
body,
#root {
height: 100%;
}
body {
margin: 0;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-size: 14px;
color: var(--ink);
background: var(--bg);
}
.app {
position: relative;
display: flex;
flex-direction: column;
height: 100%;
padding: 20px 24px 16px;
gap: 14px;
}
.status-toast {
position: absolute;
right: 24px;
bottom: 18px;
z-index: 9;
display: inline-flex;
align-items: center;
gap: 8px;
max-width: min(420px, calc(100vw - 48px));
padding: 8px 14px;
border: 1px solid var(--panel-edge);
border-radius: var(--radius);
background: var(--panel);
color: var(--accent);
font-weight: 600;
font-size: 13px;
overflow-wrap: anywhere;
box-shadow: var(--dialog-shadow);
pointer-events: none;
}
.panes {
flex: 1;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
min-height: 0;
}
.column {
display: flex;
flex-direction: column;
gap: 14px;
min-height: 0;
}
.panel {
background: var(--panel);
border: 1px solid var(--panel-edge);
border-radius: var(--radius);
padding: 14px 16px 16px;
box-shadow: var(--shadow);
display: flex;
flex-direction: column;
gap: 12px;
min-height: 0;
}
.notes-panel {
flex: 1 1 67%;
}
.files-panel {
flex: 0 1 33%;
max-height: 33%;
overflow: hidden;
}
.files-panel .table {
flex: 1;
min-height: 0;
}
.files-panel .table-body {
min-height: 0;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.panel-title h2 {
margin: 0;
font-size: 20px;
font-weight: 600;
line-height: 1.2;
color: var(--accent);
}
.panel-title span {
font-size: 12px;
color: var(--muted);
}
.panel-title-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-left: auto;
}
.table {
display: grid;
grid-template-rows: auto 1fr;
gap: 6px;
border: 1px solid var(--panel-edge);
border-radius: var(--radius);
overflow: hidden;
background: var(--surface);
min-height: 180px;
}
.table-header,
.table-row {
display: grid;
grid-template-columns: 1.2fr 2fr 0.6fr 0.6fr 0.5fr;
align-items: center;
padding: 10px 12px;
gap: 8px;
font-size: 13px;
}
.table-header {
background: var(--bg-main);
color: var(--accent);
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0;
font-size: 11px;
}
.table-body {
overflow: auto;
}
.table-row {
border-top: 1px solid var(--bg-main);
color: var(--ink);
transition: background 0.15s ease;
}
.table-row > div {
min-width: 0;
overflow-wrap: anywhere;
}
.table-row:hover {
background: var(--bg-main);
}
button.remove-row-button {
width: 24px;
height: 24px;
min-width: 24px;
padding: 0;
border-radius: var(--control-radius);
font-size: 12px;
font-weight: 700;
line-height: 1;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.concept-actions {
justify-content: flex-end;
}
button {
border: 1px solid var(--accent);
border-radius: var(--control-radius);
padding: 8px 14px;
font-family: inherit;
font-size: 14px;
font-weight: 600;
cursor: pointer;
background: var(--panel);
color: var(--accent);
transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
-webkit-user-select: none;
user-select: none;
}
button:hover {
background: var(--accent);
color: white;
}
button.primary {
background: var(--accent);
color: white;
border-color: var(--accent);
}
button.primary:hover {
background: var(--accent-strong);
border-color: var(--accent-strong);
}
button.ghost {
background: transparent;
color: var(--accent);
border-color: var(--field-border);
}
button.ghost:hover {
background: var(--bg-main);
color: var(--accent-strong);
border-color: var(--accent);
}
button.danger {
background: var(--panel);
color: var(--danger);
border-color: var(--danger);
}
button.danger:hover {
background: var(--danger);
color: white;
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
textarea,
input,
select {
border-radius: var(--control-radius);
border: 1px solid var(--field-border);
padding: 10px 12px;
font-family: inherit;
font-size: 14px;
background: var(--surface);
color: var(--ink);
}
textarea::placeholder,
input::placeholder {
color: var(--subtle);
}
textarea {
resize: vertical;
min-height: 120px;
line-height: 1.45;
}
input:focus,
textarea:focus,
select:focus {
outline: 2px solid rgba(159, 18, 57, 0.2);
border-color: var(--accent);
}
select {
accent-color: var(--accent);
}
.notes-area {
flex: 1;
min-height: 180px;
}
.rephrase-panel {
border: 1px solid var(--line);
border-radius: var(--radius);
padding: 8px;
background: rgba(255, 255, 255, 0.7);
display: flex;
flex-direction: column;
gap: 6px;
max-height: 160px;
overflow: hidden;
}
.rephrase-list {
overflow: auto;
display: flex;
flex-direction: column;
gap: 6px;
}
.rephrase-item {
padding: 8px 10px;
border-radius: var(--control-radius);
border: 1px solid var(--line);
font-size: 12px;
cursor: pointer;
background: var(--surface);
}
.rephrase-item:hover,
.rephrase-item.active {
background: var(--bg-main);
border-color: var(--field-border);
}
.concept-meta {
display: grid;
gap: 8px;
}
.concept-editor {
flex: 1;
min-height: 240px;
}
.markdown-preview {
flex: 1;
min-height: 314px;
padding: 16px 18px;
overflow: auto;
border: 1px solid var(--field-border);
border-radius: var(--control-radius);
background: var(--surface);
box-shadow: inset 0 1px 2px rgba(159, 18, 57, 0.04);
}
.markdown-preview:focus {
outline: 2px solid rgba(159, 18, 57, 0.2);
border-color: var(--accent);
}
.markdown-preview__empty {
color: var(--subtle);
}
.modal-backdrop {
position: fixed;
inset: 0;
display: grid;
place-items: center;
background: rgba(69, 10, 10, 0.28);
z-index: 10;
}
.settings-window {
width: min(560px, 92vw);
padding: 20px;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 6px;
box-shadow: var(--dialog-shadow);
}
.settings-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 18px;
}
.settings-header h3 {
margin: 0;
font-size: 18px;
color: var(--accent);
}
.website-window {
width: min(460px, 92vw);
}
.session-window {
max-height: 80vh;
overflow: auto;
}
.session-list {
display: flex;
flex-direction: column;
gap: 10px;
}
.session-item {
display: block;
width: 100%;
text-align: left;
}
.session-description {
margin-top: 2px;
color: var(--muted);
font-size: 12px;
}
.session-time {
margin-top: 2px;
color: var(--subtle);
font-size: 11px;
}
.website-form {
display: grid;
gap: 10px;
}
.form-error {
color: var(--danger);
font-size: 12px;
font-weight: 600;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 4px;
}
.settings-grid {
display: grid;
grid-template-columns: 130px minmax(0, 1fr);
align-items: center;
gap: 12px 14px;
}
.settings-grid label {
font-size: 12px;
font-weight: 600;
color: var(--muted);
}
.settings-grid input,
.settings-grid select {
width: 100%;
min-width: 0;
}
@media (max-width: 1100px) {
.panes {
grid-template-columns: 1fr;
}
}
@media (max-width: 720px) {
.table-header,
.table-row {
grid-template-columns: 1.2fr 1.8fr 0.6fr 0.6fr 0.5fr;
}
.settings-grid {
grid-template-columns: 1fr;
}
}

4
src/types/markdown-it.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
declare module "markdown-it" {
const MarkdownIt: any;
export default MarkdownIt;
}

1
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

20
tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}

10
tsconfig.node.json Normal file
View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

27
vite.config.ts Normal file
View File

@@ -0,0 +1,27 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig(() => {
const host = process.env.TAURI_DEV_HOST;
return {
plugins: [react()],
clearScreen: false,
server: {
port: 5173,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 5173,
}
: undefined,
},
build: {
target: "esnext",
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
sourcemap: !!process.env.TAURI_DEBUG,
},
};
});

View File

@@ -2,13 +2,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Prior-art web search utilities for the Idea → Concept GUI. Prior-art web search utilities for the Concept Maker backend.
Design goals Design goals
- Pure stdlib networking (urllib) to avoid new dependencies. - Pure stdlib networking (urllib) to avoid new dependencies.
- Works with a local SearXNG instance. - Works with a local SearXNG instance.
- Uses Ollama for both query generation and embeddings. - Uses Ollama for both query generation and embeddings.
- Small, robust, and callable from the GUI with status callbacks. - Small, robust, and callable from the Python backend.
""" """
from __future__ import annotations from __future__ import annotations