CAMEL-24287: Add plain text edit mode to TUI source viewer - #25204
CAMEL-24287: Add plain text edit mode to TUI source viewer#25204atiaomar1978-hub wants to merge 4 commits into
Conversation
Review follow-up (Grok + Bugbot)Independent Grok review of the diff was run; Bugbot was also requested. Grok findings addressed in
|
| Severity | Issue | Fix |
|---|---|---|
| Critical | Esc left the Source tab instead of canceling edit (CamelMonitor routes Esc to handleEscape before tab keys) |
SourceTab.handleEscape() now calls sourceViewer.cancelEdit() and returns true |
| Major | Tab toggled focus mid-edit → silent discard risk | Tab is swallowed while isEditMode() |
| Major | Canceling edit on .md left markdown render off |
Remember/restore markdownModeBeforeEdit |
| Minor | Stale “Saved” message after opening another file | Clear saveMessage in loadFile |
Extra tests added for markdown restore, cancel API, and Tab-while-editing.
Remaining (accepted / follow-up)
- Line-ending normalization (
readAllLines→\n) — acceptable for v1 prototyping editor - Soft size/binary guard — future ticket
- Unused
isSourceViewerEditMode/ paste-active alias cleanup — can tidy in a follow-up
bugbot run
AI-generated by Cursor Agent on behalf of Omar Atie
|
AI-generated comment on behalf of atiaomar1978-hub Follow-up commit (
Tests: |
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 2 tested, 1 compile-only — current: 2 all testedMaveniverse Scalpel detected 3 affected modules (current approach: 2).
|
gnodet
left a comment
There was a problem hiding this comment.
Good implementation of plain-text edit mode for the TUI source viewer with comprehensive tests (22 tests covering enter/cancel/save, Esc discard, paste, read-only files, markdown restore, and footer hints) and proper key isolation. CI passes.
A few cleanup items:
-
Dead code:
isSourceViewerPasteActive()inFilesBrowser.java(line 63) has zero callers — it's functionally identical to the newisSourceViewerTextInputActive(). Similarly,isSourceViewerSearchActive()inSourceTab.java(line 110) has zero callers afterCamelMonitorwas updated. Both should be removed. -
FQCNs in test:
SourceViewerEditTest.javauses fully qualifiedjava.util.concurrent.atomic.AtomicReferenceandjava.util.Listat 8 locations (lines 165, 166, 181, 182, 302, 303, 318, 319) despite already importing both types at lines 23-24. Per project convention, simple class names should be used. -
Redundant assignments: In
saveEdit(),saveMessage = "Saved"andsaveError = falseat lines 497-498 are immediately overwritten byloadFile(path)which resets them. Only the post-reload assignments at lines 509-510 have effect.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
| @Test | ||
| void remoteLoadSourceIsNotEditable() { | ||
| MonitorContext ctx = new MonitorContext( | ||
| new java.util.concurrent.atomic.AtomicReference<>(java.util.List.of()), |
There was a problem hiding this comment.
Fully qualified class names used here (and at lines 166, 181, 182, 302, 303, 318, 319) despite AtomicReference and List already being imported at lines 23-24. Per project convention: "Do NOT use fully qualified class names in Java code. Always add an import statement and use the simple class name."
| new java.util.concurrent.atomic.AtomicReference<>(java.util.List.of()), | |
| new AtomicReference<>(List.of()), |
There was a problem hiding this comment.
Fixed in 40febda5f24 — AtomicReference and List now use imported simple names throughout the test file.
|
AI-generated comment on behalf of atiaomar1978-hub Addressed @gnodet review in
|
Allow toggling the source viewer into a TextArea-based edit mode for local/writable files (dev mode or local folder). Press e to edit, Esc to cancel, F5 to save. Process-sourced views remain read-only. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Route Esc cancel through SourceTab.handleEscape (CamelMonitor handles Esc before tab keys). Block Tab focus-toggle while editing, restore markdown mode on cancel, and clear stale save feedback on reload. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Forward keyboard input to the source viewer while editing even when file-list focus is active, and restore raw markdown view after save when the user had toggled preview off. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove unused paste/search helper methods, drop redundant saveEdit assignments before reload, and use simple names in SourceViewerEditTest. Co-authored-by: Cursor <cursoragent@cursor.com>
186d59b to
40febda
Compare
|
AI-generated comment on behalf of atiaomar1978-hub Follow-up for @gnodet review:
Branch rebased on latest Ready for re-review. |
gnodet
left a comment
There was a problem hiding this comment.
Re-review after latest commits. All three previous review items are properly addressed:
- Dead code removal —
isSourceViewerPasteActive()andisSourceViewerSearchActive()removed and consolidated intoisSourceViewerTextInputActive()✅ - FQCN cleanup — all FQCNs in
SourceViewerEditTest.javareplaced with imported simple names ✅ - Redundant assignments — pre-
loadFile()save-message assignments removed fromsaveEdit(); save feedback now correctly set after reload ✅
Good test coverage with 22 tests covering enter/cancel/save, Esc discard, paste into editor, read-only guard, markdown mode restore, footer hints, Tab handling, and cross-tab key forwarding.
Minor suggestions for follow-up (non-blocking):
dev.tamboui.tui.event.KeyCode.ESCAPEat line 231 ofSourceTab.javauses FQCN (matches pre-existing pattern at line 142 forKeyCode.TABon main). Both could be cleaned up by addingimport dev.tamboui.tui.event.KeyCode;.exitEditMode(boolean reloadFromDisk)has an unused parameter — all call sites passfalse. Could be simplified to parameterlessexitEditMode().
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Description
Adds a plain-text edit mode to the Camel JBang TUI source viewer for quick prototyping of local files (YAML routes,
application.properties, Java, etc.) without leaving the terminal.Behavior
ein the source viewer to enter edit mode (only when the loaded file is a local writable path fromloadFile)Escto cancel and return to read-only view (syntax highlighting restored; markdown mode restored for.mdfiles)F5to save; Camel dev mode then auto-reloads the changed fileTextAreawith line numbers and no syntax highlightingTabdoes not steal focus while editingloadSource/ remote attach) remain read-onlyTests
SourceViewerEditTest(20 tests): enter/cancel/save, Esc discard, paste, read-only, markdown restore, footer hints, save-message clearing, Tab swallowed in edit modeJIRA: https://issues.apache.org/jira/browse/CAMEL-24287
AI-generated by Cursor Agent on behalf of Omar Atie
Target
mainbranch)Tracking
Apache Camel coding standards and style
formatter:format/impsort:sort) and tests for the touched module.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.