# Native Kotlin Editor Roadmap ## Current State - Odin editor core with piece-table storage. - File-backed editor buffers. - Cursor movement and line/column mapping. - SDL3 native window mode. - SDL3 GPU command-buffer renderer path when a GPU backend is available. - Basic text input, Enter with auto-indent, Backspace, Delete, Tab indent, arrows, Ctrl+Left/Ctrl+Right, selection, mouse click/drag cursor placement, and Ctrl+S save. - JVM daemon over TCP JSON-lines. - Gradle workspace import via Tooling API. - Kotlin diagnostics using compiler embeddable. - Async `diagnostics/publish` events rendered in the SDL gutter/status area and stored by file path for open buffers. ## Phase 1: Usable Editor - Open arbitrary files in SDL mode. - Add project file tree. Done. - Support multiple open buffers. - Add proper viewport scrolling independent of cursor. - Add PageUp/PageDown/Home/End. - Add Ctrl+Left/Ctrl+Right word movement. Done. - Add mouse wheel scrolling. - Add click-to-move-cursor. Done. - Add mouse drag selection. Done. - Add undo/redo. - Add selection. Done. - Add copy/cut/paste. Done. - Add Delete key. Done. - Add Tab/indent/outdent. Done: Tab inserts four spaces and Shift+Tab outdents the current or selected lines. - Add auto-indent on Enter. Done. - Add search in file. Started: Ctrl+F find panel with next/previous navigation and visible match highlights. - Add Save All. Done. - Replace SDL debug text with proper font rendering. Started: direct GPU path uses an `stb_truetype` baked Noto Sans Mono atlas. - Replace renderer-backed drawing with a direct SDL3 GPU command-buffer quad/text pipeline. Started: rectangles, lines, panels, selection, cursor, and temporary text render through SDL3 GPU with SDL renderer fallback. - Add shader compilation pipeline. Started: GLSL sources plus `scripts/compile-shaders.sh` using `glslc` to emit SPIR-V. - Add syntax highlighting. Started: lightweight visible-line Kotlin/Java tokenizer in the GPU renderer. ## Phase 2: Daemon Integration - Start JVM daemon automatically from Odin. Done. - Read daemon `PORT` from stdout. Done. - Stop daemon on editor exit. Done. - Restart daemon if it crashes. Done for auto-started SDL daemons; explicit external-port mode reports disconnects without spawning a replacement. - Replace ad-hoc JSON parsing in Odin. Done. - Track request IDs and pending responses. Done. - Distinguish responses and events cleanly. Done. - Store diagnostics per file, not only active file. Done: diagnostics events are queued and applied to the matching open buffer path. - Clear stale diagnostics on workspace reload. - Render diagnostic underlines/squiggles. Started: GPU renderer draws red dashed underlines on diagnostic lines. - Add next/previous diagnostic navigation. Done: F8 and Shift+F8 navigate active-file diagnostics. - Add diagnostics panel. Done: Ctrl+Shift+M opens active-file diagnostics with keyboard navigation. - Show Gradle tasks in UI. Started: Ctrl+Shift+T requests and displays tasks in a docked GPU right sidebar; responses are matched by request id. - Run selected Gradle task. Started: Enter in the Gradle tasks panel runs the selected task and reports success/failure. - Stream Gradle task output. Started: Gradle run lifecycle and stdout/stderr line events are surfaced in the tasks sidebar with recent output retained. - Add workspace reload/import action. Started: command palette Reload Workspace refreshes the file tree, sends `workspace/open`, clears stale diagnostics, and resyncs the active buffer. ## Phase 3: Kotlin And Java Intelligence - Implement `kotlin/completion` in the daemon. Started: prefix-filtered Kotlin keywords plus heuristic current-buffer/workspace identifiers and declarations. - Add completion popup in SDL UI. Done: popup renders returned items and applies the selected completion with Enter or row click, using a single undoable replace edit. - Add keyboard navigation in completion popup. Done. - Implement `kotlin/hover`. Started: Kotlin Analysis API symbol resolution with heuristic declaration fallback. - Render hover tooltip. Done. - Implement `kotlin/definition`. Started: Kotlin Analysis API symbol resolution with heuristic declaration fallback. - Open target file and jump to line/column. Done. - Add back/forward navigation stack. Done. - Add find references. Started: Kotlin Analysis API symbol matching with heuristic source-scan fallback and SDL references popup. - Add rename/refactor support. Started: daemon preview-only rename edits with SDL preview panel. - Add Java diagnostics/completion/navigation. Started: `.java` diagnostics use the JDK compiler with Gradle module classpath/sourcepath; completion/hover/definition/references scan Java source declarations heuristically. ## Phase 4: Backend Quality - Replace compiler-per-request diagnostics with long-lived analysis state. - Cache Gradle module classpaths and source roots. - Move toward Kotlin Analysis API where feasible. Started: definition, hover, and references use standalone Kotlin Analysis API before heuristic fallback. - Correctly model multi-module projects. Started: diagnostics choose the module with the most specific matching source root. - Separate main/test source-set analysis. Started: diagnostics use main roots for main files and main+test roots for test files. - Include generated sources. Started: common existing `build/generated/` Kotlin/Java roots, including KSP/Kotlin Multiplatform source-set layouts, are added to Gradle module source roots. - Improve classpath and project dependency handling. Started: diagnostics include existing module output directories from `build/classes/` and `build/resources/`, including common JVM/KMP layouts; Kotlin diagnostics include Java sources from the matching Gradle source roots. ## Phase 5: Product Shape - Add sidebar file tree. - Add editor tabs. Done: GPU tab strip shows open buffers and supports click-to-switch, close buttons, and drag reorder. - Add bottom panel for diagnostics/tasks/output. - Add command palette. Started: Ctrl+Shift+P opens a filterable GPU command palette for existing editor actions. - Add configurable keybindings. - Add theme settings. - Add font settings. - Persist last workspace, open files, cursor positions, and window layout. Started: window size, sidebars, open files, active tab, and cursor offsets are cached per workspace. ## Performance Work - Incrementally update line index. - Compact piece table after many edits. - Cache rendered text/glyphs. - Avoid full-buffer `text/change` sync on every edit. Started: edit-triggered sync is debounced. - Debounce native-to-daemon text sync. Done: text edits schedule a delayed sync; file open/switch/navigation and daemon-backed commands still flush immediately. ## Next Work Queue 1. Open arbitrary file from SDL mode. Done. 2. Add scrolling/PageUp/PageDown/Home/End. Done. 3. Add undo/redo. Done. 4. Add daemon auto-start. Done. 5. Add robust protocol parser. Done. 6. Add project file tree. Done. 7. Add completion popup skeleton. Done. 8. Wire completion responses into popup. Done. 9. Implement real `kotlin/completion` in the daemon. Started: prefix-filtered Kotlin keywords plus heuristic current-buffer/workspace identifiers and declarations. 10. Implement `kotlin/hover` and render hover tooltip. Started: Kotlin Analysis API symbol resolution with heuristic declaration fallback. 11. Implement `kotlin/definition` and Ctrl+B navigation. Started: Kotlin Analysis API symbol resolution with heuristic declaration fallback. 12. Add back/forward navigation stack. Done. 13. Add find references. Started: Kotlin Analysis API symbol matching with heuristic source-scan fallback and SDL references popup. 14. Add rename/refactor support. Started: daemon preview-only rename edits with SDL preview panel. 15. Add Ctrl+Left/Ctrl+Right word movement. Done. 16. Add click-to-move-cursor. Done. 17. Add Delete key. Done. 18. Add Tab indentation and auto-indent. Done: Tab inserts four spaces, Shift+Tab outdents, and Enter preserves leading whitespace. 19. Improve mouse support. Done: sidebar/editor wheel routing, sidebar scrolling, click-to-place-cursor, drag selection. 20. Add selection. Done: mouse drag and Shift+movement selection with replacement on edit. ## Immediate Stabilization Goals 1. Text metrics correctness. In progress: GPU text uses explicit fixed-cell atlas placement, widened cell advance, GPU-aware hit-testing, and `Ctrl+M` metrics overlay. 2. Font portability. Done for the prototype: bundled Noto Sans Mono is loaded from `client/odin/assets/fonts/` with system fallback paths. 3. Proper font shaping baseline. Replace baked ASCII-only atlas with a more deliberate atlas/SDF pipeline. 4. Renderer abstraction cleanup. Split UI drawing from SDL fallback/GPU backend details. 5. Input consistency. Started: cursor, hit-testing, syntax spans, and selection use shared metrics in the GPU path; command palette, completion, references, diagnostics, and Gradle panels now keep keyboard selection visible, support row clicks, route wheel events when hovered, and handle PageUp/PageDown plus Home/End. 6. Syntax quality. Started: visible-line tokenizer now carries `/* ... */` block comment and Kotlin triple-quoted string state across rendered lines, with Kotlin/Java keywords and character literals. Still needs semantic tokens. 7. Editor essentials. Done for the current prototype: clipboard copy/cut/paste, Save All, richer Ctrl+F search, clickable GPU tabs, safe Ctrl+W tab close, tab close buttons, drag reorder, stale overlay cleanup after edits, dirty tracking by saved buffer version, robust open-buffer diagnostic matching, and single-step/no-op-aware undo for selection/full-buffer replacement are implemented.