-
Notifications
You must be signed in to change notification settings - Fork 24
feat(ui): add dynamic input window toggle #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aweis89
wants to merge
36
commits into
sudo-tee:main
Choose a base branch
from
aweis89:dynamic-input-window
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+197
−22
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- allow 'current' as a valid position option for UI placement - update position handling in dimensions and window closing logic - ensure compatibility with existing configurations
- introduce a new configurable system prompt to customize assistant behavior - include guidance for file referencing to assist users with integration - modifies message sending logic to incorporate the system prompt if set - changes to reference detection streamline navigation for file-related responses
- Remove dead code referencing non-existent ref.context field - Only show line number in display when present (avoid 'path:?')
…icons - Parse file references when session becomes idle (AI done responding) - Cache parsed references per-message for faster picker opening - Handle session load from previous sessions - Display reference icon before recognized file paths in output - Subscribe to 'messages' state changes to parse loaded sessions - Update test expected data files with new icon rendering
Remove legacy path:line and path-only pattern detection in favor of exclusively parsing file:// URIs. This simplifies the code significantly and avoids false positives from ambiguous path patterns. The system prompt instructs the LLM to use file:// URIs, making the legacy patterns unnecessary.
- refine explanation for system prompt usage in assistant responses - emphasize file URI scheme for better navigation and tooling integration
- remove old system prompt setting in configuration - replace it with a hardcoded prompt including URI format examples - modifies behavior to improve navigation and tooling integration
- add support for line range format: file://path:start-end - modify regex pattern to accommodate optional end line numbers - update reference structure to include optional end_pos for highlighting
- enhance clarity in the instructions for referencing files - emphasize the use of the file:// URI scheme as critical - provide examples to illustrate correct and incorrect formats - ensure compatibility with the existing reference picker for navigation
- improve reference location display by including line and column info - handle cases where end position is available for better accuracy - simplify display logic to ensure consistent output for references
- populate entry path, lnum, and col in telescope entries to support previewers - enable file previewer configuration when options request file preview - ensures code references can be previewed directly in the telescope picker UI
- update system prompt to explicitly require backticks around file:// URIs - add examples distinguishing correct backticked format from incorrect ones - ensures file references are consistently formatted for UI and parsing
- add key binding for timeline picker with `<leader>oT` - include new key binding for browsing code references with `gr` - clarify command usage for creating and selecting sessions - touches(config): update default keyboard shortcuts for new features
Resolves conflicts in: - lua/opencode/ui/highlight.lua: Added both OpencodeReference and OpencodeReasoningText highlights - lua/opencode/ui/icons.lua: Added both reference and reasoning icons to nerdfonts preset, added reference to text preset
Icon characters changed in upstream, requiring test snapshot updates
Telescope supports highlighting line ranges in the file previewer using the lnend field. Map end_pos[1] to lnend so that references with line ranges (file://path:start-end) get highlighted in Telescope previewer.
The default file_previewer uses the 'cat' previewer which doesn't call jump_to_line, so lnend field is ignored. Switch to vim_buffer_vimgrep which properly highlights line ranges using the lnend field.
Add builtin previewer support to fzf-lua picker backend with automatic line/column positioning for code references. Changes: - Enable 'builtin' previewer when preview='file' - Append file:line:col: format to entries for fzf-lua parsing - Update fn_fzf_index to strip position info before matching - Supports navigation to specific lines (range highlighting shows start line only) Implementation details: - Uses tab separator between display text and file position - fzf-lua's entry_to_file() automatically parses path:line:col: format - Cursorline highlights the target line in preview - Gracefully degrades when preview is disabled Comparison with other pickers: - Telescope: Full range highlighting (start-end lines) - Snacks: Full range highlighting (start-end lines) - fzf-lua: Single line highlighting (cursorline at start) - Mini.pick: No file preview support
fzf-lua uses nbsp (U+2002 EN SPACE) as the standard separator between
display text and file path info, not tab. The builtin previewer parses
entries by splitting on utils.nbsp and extracting the path:line:col:
portion.
From fzf-lua/path.lua entry_to_file():
local parts = utils.strsplit(entry, utils.nbsp)
for i = 1, #parts - 1 do
if s:match(".-:%d+:") then break end
idx0 = idx0 + #s + #utils.nbsp
end
return entry:sub(idx0), idx0
Changes:
- Use nbsp (\xe2\x80\x82) instead of \t as separator
- Update fn_fzf_index to split by nbsp
- Use file_path (relative) before file (absolute) for correct resolution
This fixes 'Unable to stat file' errors in preview.
Feat/picker ai code referenes
- implement toggle_input function to show/hide input window - update key mappings for input window toggle: <leader>oa and <M-i> - modify autocmd to prevent closing all windows during input toggle - enhance input_window module to manage visibility and state tracking
- show input window if hidden in open_input and focus_input functions - add submit_and_hide_input to handle submission and hide input window - ensures smoother user experience by managing input window visibility
- implement dynamic input behavior, focusing on input when enabled - auto-hide input window when navigating away if dynamic input is active - revision of input displaying logic for cleaner state management - update config to include dynamic input setting Closes sudo-tee#123
- remove unnecessary promise handling in toggle_pane method - directly call ui.toggle_pane for improved clarity and performance
- auto-hide input window when prompt is submitted or focus switches - enhances user experience by reducing screen clutter
- change input toggle from `<leader>oa` to `<M-i>` - improves ease of access by using a different key combination
- make input_window.handle_submit return true if a message was sent - conditionally hide input window only if a message was sent and dynamic input is enabled - prevent hiding the input window when viewing slash command outputs like /help - adjusts behavior of input window in various contextual situations
- restrict toggle pane key mapping for output and input windows to 'n' - improves input handling by focusing on normal mode usage only
- add checks to track if the output window was at the bottom - if previously at bottom, scroll to bottom after showing the input window
- change test messages for better clarity - modify date format checks to include year where necessary - enhance tests to handle different date outputs based on the year context
Contributor
Author
|
@sudo-tee curious to hear if you had any thoughts on this if you had a chance to try it out.
|
Owner
|
I didn't had time to look at it yet. Been busy with the holidays and family. But I will look at it pretty soon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
ui.input.dynamicconfig option that automatically hides the input window when focus moves to the output window or when a prompt is submittedMotivation
When working with AI responses, the output window benefits from maximum screen real estate. The input window (especially when configured larger) takes up space that isn't needed while waiting for or reading responses. This feature allows the input window to stay out of the way until you're ready to type the next prompt.
Features
Toggle Input Window
toggle_inputAPI function and command (:Opencode toggle_input)<M-i>(Alt+i) in both input and output windowsDynamic Input Mode (
ui.input.dynamic = trueby default)<cr>)<C-w>commands, etc.)focus_input,open_input, ortoggle_paneBug Fixes
Auto-scroll preservation during dynamic input resize
When the input window hides/shows with
dynamic = true, the output window resizes. This could incorrectly updateviewport_at_bottomvia theWinScrolledautocmd, breaking auto-scroll. Fixed by:was_at_bottomstate before hide/showscroll_to_bottom()after resize if previously at bottomTab keymap conflicts with completion plugins
<Tab>toggle focus mapping to only trigger in normal mode, preventing conflicts with auto-complete mappings that use<Tab>in insert modeTest Fixes
Date formatting tests fail on year boundaries (CI)
Tests for
util.format_timefailed when run on year boundaries (e.g., Jan 1, 2026):31 Dec 09:46 PMbut got31 Dec 2025 09:46 PM(year included because Dec 31 is a different year than Jan 1)Fix: Made tests year-boundary-aware by checking if test dates fall in the same year as today before asserting the expected format pattern.
Files Changed
lua/opencode/api.lua- Addtoggle_input, updatesubmit_input_prompt,togglelua/opencode/config.lua- Addui.input.dynamicoption and keymapslua/opencode/ui/autocmds.lua- Prevent closing all windows during togglelua/opencode/ui/input_window.lua- Addtoggle,_hide,_show,is_hiddenfunctions; preserve scroll positionlua/opencode/ui/output_window.lua- Auto-hide input on focus when dynamic enabledlua/opencode/ui/ui.lua- Handle hidden state infocus_input, simplifytoggle_panetests/unit/util_spec.lua- Fix year-boundary-aware date formatting tests