Skip to content

Conversation

@cameronr
Copy link
Collaborator

@cameronr cameronr commented Oct 9, 2025

Fixes #58

Makes config access less error prone and more ergonomic

Fixes sudo-tee#58

Makes config access less error prone and more ergonomic
@cameronr cameronr force-pushed the fix/config-metatable branch from 081c822 to 0a39eac Compare October 9, 2025 20:43
@sudo-tee
Copy link
Owner

sudo-tee commented Oct 9, 2025

I love the solution and it fix a lot of potential issues

@sudo-tee sudo-tee merged commit 601cc82 into sudo-tee:main Oct 9, 2025
DanRioDev pushed a commit to DanRioDev/opencode.nvim that referenced this pull request Oct 20, 2025
commit 601cc82
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Thu Oct 9 15:52:47 2025 -0700

    fix(config): add config metatable (sudo-tee#59)

    Fixes sudo-tee#58

    Makes config access less error prone and more ergonomic

commit ca0ff90
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 09:50:28 2025 -0400

    chore: update .luarc.json for better support of emmylua_ls

commit a82b08c
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 09:49:28 2025 -0400

    fix: prefix replacement not working properly

commit 9d949e7
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 08:43:57 2025 -0400

    feat: add a keymap_prefix to configure the default `<leader>o`

commit 8c65d9b
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Thu Oct 9 03:29:02 2025 -0700

    feat(config)!: modern keymap format + mode support (sudo-tee#52)

    This is a complete overhaul of the keymaps,

    The old config should still work but with a warning for migration

    The new format shoud now be:
    ```lua
     keymap = {
        editor = {
          ['<leader>og'] = { 'toggle' }, -- I don't think we really need to support just string, it makes things more complex for nothing
          ['<leader>oi'] = { 'open_input' },
          ['<leader>oI'] = { 'open_input_new_session' },
          ['<leader>oo'] = { 'open_output' },
          ['<leader>ot'] = { 'toggle_focus' },
          ['<leader>oq'] = { 'close' },
          ['<leader>os'] = { 'select_session' },
          ['<leader>op'] = { 'configure_provider' },
          ['<leader>od'] = { 'diff_open' },
          ['<leader>o]'] = { 'diff_next' },
          ['<leader>o['] = { 'diff_prev' },
          ['<leader>oc'] = { 'diff_close' },
          ['<leader>ora'] = { 'diff_revert_all_last_prompt' },
          ['<leader>ort'] = { 'diff_revert_this_last_prompt' },
          ['<leader>orA'] = { 'diff_revert_all' },
          ['<leader>orT'] = { 'diff_revert_this' },
          ['<leader>orr'] = { 'diff_restore_snapshot_file' },
          ['<leader>orR'] = { 'diff_restore_snapshot_all' },
          ['<leader>oC'] = { 'open_configuration_file' },
          ['<leader>ox'] = { 'swap_position' },
          ['<leader>opa'] = { 'permission_accept' },
          ['<leader>opA'] = { 'permission_accept_all' },
          ['<leader>opd'] = { 'permission_deny' },
        },
        output_window = {
          ['<leader>something'] = {function ()
                       -- custom code
          end},
          ['<esc>'] = { 'close' },
          ['<C-c>'] = { 'stop' },
          [']]'] = { 'next_message' },
          ['[['] = { 'prev_message' },
          ['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } },
          ['<C-i>'] = { 'focus_input' },
          ['<leader>oS'] = { 'select_child_session' },
          ['<leader>oD'] = { 'debug_message' },
          ['<leader>oO'] = { 'debug_output' },
          ['<leader>ods'] = { 'debug_session' },
        },
        input_window = {
          ['<cr>'] = { 'submit_input_prompt', mode = { 'n', 'i' } },
          ['<esc>'] = { 'close' },
          ['<C-c>'] = { 'stop' },
          ['~'] = { 'mention_file', mode = 'i' },
          ['@'] = { 'mention', mode = 'i' },
          ['/'] = { 'slash_commands', mode = 'i' },
          ['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } },
          ['<up>'] = { 'prev_prompt_history', mode = { 'n', 'i' } },
          ['<down>'] = { 'next_prompt_history', mode = { 'n', 'i' } },
          ['<M-m>'] = { 'switch_mode' },
          ['<leader>oS'] = { 'select_child_session' },
          ['<leader>oD'] = { 'debug_message' },
          ['<leader>oO'] = { 'debug_output' },
          ['<leader>ods'] = { 'debug_session' },
        },
        permission = {
          accept = 'a',
          accept_all = 'A',
          deny = 'd',
        },
    ```

commit fb33ce6
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 10:22:36 2025 -0400

    refactor: simplify keymaps by having a corresponding api function

commit fa31457
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 13:23:32 2025 -0400

    feat: restore mentions when navigating history

commit 123d62b
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 12:53:11 2025 -0400

    fix: permission not displaying for subagents

commit 8a54af6
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 10:41:09 2025 -0400

    feat: display edit tool preview when asking for permission

commit a17400c
Author: Michael <osajehmichael@gmail.com>
Date:   Tue Oct 7 13:20:10 2025 +0100

    fix: use consistent window positioning commands for splits (sudo-tee#50)

commit 2357f86
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 08:06:14 2025 -0400

    feat: support arguments for commands after completion

commit 13b9e88
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 07:11:49 2025 -0400

    feat: allow arguments passing to user commands

commit 4eab392
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Fri Oct 3 15:57:45 2025 -0400

    chore: remove dead code

commit 42490ec
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 6 07:02:50 2025 -0400

    feat: implement basic permissions worflow
DanRioDev pushed a commit to DanRioDev/opencode.nvim that referenced this pull request Oct 28, 2025
commit 3f13fe8a10c6f02e7cbcbbaf0b3c0eff403f9c4d
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Tue Oct 28 12:14:28 2025 -0300

    Squashed commit of the following:

    commit 3dea370
    Author: Francis Belanger <francis.belanger@gmail.com>
    Date:   Tue Oct 28 08:49:27 2025 -0400

        chore(emmyrc): fix broken .emmyrc.json

    commit c07f293
    Author: Cameron Ring <cameron@cs.stanford.edu>
    Date:   Mon Oct 27 17:32:50 2025 -0700

        fix(renderer): render errors after last part

    commit bebe01c
    Author: Francis Belanger <francis.belanger@gmail.com>
    Date:   Mon Oct 27 15:56:57 2025 -0400

        feat(rendering): incremental rendering (sudo-tee#62)

        Introduces an incremental rendering that updates only the changed portion(s) of the buffer instead of re-rendering everything on every change. This reduces CPU usages for large sessions.

        This PR also incorporate a functional test suite in `tests/manual` where you can record a run snapshot tests.

        This is a major revision of the rendering system.

        Co-authored-by:  Cameron Ring <cameron@cs.stanford.edu>

commit a3e12fcf781471b2f2880118e94091183bd4cd85
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Tue Oct 28 10:57:59 2025 -0300

    feat(ui/context): enhance loading animation and context management

commit a8382b83f1a76ec1e1e9a362f5eaa67071b53c70
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Fri Oct 24 17:29:43 2025 -0300

    Squashed commit of the following:

    commit 25c099d
    Merge: 7874524 23f384e
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Tue Oct 7 16:10:20 2025 -0300

        Merge remote-tracking branch 'origin/main'

    commit 7874524
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Fri Oct 3 11:43:15 2025 -0300

        fix(git): missing files in context module

    commit 7d90008
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Fri Oct 3 10:44:45 2025 -0300

        feat(contex): better privacy and contextual awareness

    commit 9c65ef8
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 19:56:19 2025 -0300

        fix(hanging_close): clear all windows was hangin neovim

    commit ce8d473
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Tue Oct 7 16:03:37 2025 -0300

        fix(performace): proper detector and cleaner

    commit 3ab8e87
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 17:39:42 2025 -0300

        fix(autocmd): best to fetch context when user is idle

    commit d76b16c
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 20:42:41 2025 -0300

        fix(type): rollback for better reading

    commit 850bdca
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Tue Oct 7 15:37:28 2025 -0300

        refactor: clean up PR sudo-tee#42 based on maintainer feedback

        - Remove unnecessary inline type annotations in session_formatter.lua
        - Remove deprecated assistant_mode field from Message type
        - Simplify mode field documentation
        - Remove assistant_mode fallback logic in header formatting
        - Restore accidentally deleted keymap and context config fields
        - Fix indentation inconsistencies

        This addresses all review feedback from @sudo-tee while preserving
        the core feature: using CLI-persisted mode field to display agent
        names (BUILD, PLAN, etc.) in assistant message headers.

    commit 1573b3d
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:43:04 2025 -0300

        fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

        - Read message.mode field from CLI-persisted JSON (already stored by opencode)
        - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
        - Add message.mode to Message type definition, mark assistant_mode as deprecated
        - Update session_formatter to prefer message.mode over message.assistant_mode
        - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
        - Eliminates need for client-side mode persistence since CLI handles it

    commit 35eedbe
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:27:55 2025 -0300

        fix: show current mode for latest assistant message when assistant_mode is missing

        Display-time fallback for the most recent assistant message to show the current mode name when assistant_mode field hasn't been stamped yet. This fixes new messages showing generic 'ASSISTANT' instead of the active mode label (e.g., 'NEOAGENT').

        Historical messages remain unchanged, preserving their original mode labels or showing generic 'ASSISTANT' for old messages created before mode tracking was added.

    commit 9229b87
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Tue Oct 7 14:30:56 2025 -0300

        fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

        - Read message.mode field from CLI-persisted JSON (already stored by opencode)
        - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
        - Add message.mode to Message type definition, mark assistant_mode as deprecated
        - Update session_formatter to prefer message.mode over message.assistant_mode
        - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
        - Eliminates need for client-side mode persistence since CLI handles it

    commit b99d997
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:17:38 2025 -0300

        fix(ui): remove assistant_mode backfill to preserve historical mode labels

        The backfill loop was seeding from state.current_mode and stamping all
        historical assistant messages without assistant_mode, causing every
        message to show the current mode's name on restart rather than the mode
        used at that point in time.

        Removed lines 35-46 (backfill loop). Historical messages without
        assistant_mode now display as generic 'ASSISTANT' via existing fallback
        logic in _format_message_header (lines 299-304).

        This preserves immutability of stored assistant_mode values and prevents
        cross-session pollution.

    commit 008d290
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 15:39:47 2025 -0300

        feat(context): add recent_buffers synthetic context (MRU buffers with optional symbols)

    commit 2231aeb
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 15:35:51 2025 -0300

        feat(ui): stabilize assistant_mode labeling and improve session formatting robustness\n\n- Persist assistant_mode onto latest assistant message after run\n- Backfill assistant_mode for historical assistant messages for stable display names\n- Use assistant_mode (uppercase) in headers instead of generic ASSISTANT\n- Improve revert stats typing and snapshot action anchoring with display_line + range\n- Harden get_message_at_line nil checks to avoid indexing errors\n- Extend MessagePart.type to include patch and step-start; allow OutputExtmark function form\n- Add assistant_mode field to Message type\n- Fix synthetic user message check (part.synthetic ~= true)\n- Improve callout width handling when window invalid; fallback to config width or 80\n- Add type annotations for tool formatting inputs/metadata/output\n- Correct diff virt_text structure and highlight group names\n- General annotation cleanup and stability improvements

    commit 6f35278
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 13:27:13 2025 -0300

        fix: add caching to context.load(), debounce WinLeave autocmd, fix types for LSP

    commit 3047974
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 12:50:11 2025 -0300

        feat: enhance context with plugin versions and buffer symbols, update types and tests

    commit d7f1ead
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:17:10 2025 +0000

        Update README with enhanced context documentation

        Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

    commit 32819c0
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:14:30 2025 +0000

        Add enhanced context gathering functions and tests

        Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

    commit f9f4f16
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:06:57 2025 +0000

        Initial plan

    commit 23f384e
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Fri Oct 3 11:43:15 2025 -0300

        fix(git): missing files in context module

    commit df83776
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Fri Oct 3 10:44:45 2025 -0300

        feat(contex): better privacy and contextual awareness

    commit f30c47a
    Merge: 34edf5d 0d102c0
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 20:57:12 2025 -0300

        Merge branch 'enhanced-context'

    commit 34edf5d
    Merge: 3e7a8a8 55cc0db
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 20:53:32 2025 -0300

        Merge branch 'style-assistant-name-is-agent-name'

    commit 55cc0db
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 20:42:41 2025 -0300

        fix(type): rollback for better reading

    commit f26b069
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 20:28:51 2025 -0300

        refactor: clean up PR sudo-tee#42 based on maintainer feedback

        - Remove unnecessary inline type annotations in session_formatter.lua
        - Remove deprecated assistant_mode field from Message type
        - Simplify mode field documentation
        - Remove assistant_mode fallback logic in header formatting
        - Restore accidentally deleted keymap and context config fields
        - Fix indentation inconsistencies

        This addresses all review feedback from @sudo-tee while preserving
        the core feature: using CLI-persisted mode field to display agent
        names (BUILD, PLAN, etc.) in assistant message headers.

    commit 0d102c0
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 19:56:19 2025 -0300

        fix(hanging_close): clear all windows was hangin neovim

    commit 1f8da59
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 18:45:10 2025 -0300

        fix(performace): proper detector and cleaner

    commit 8fd42b9
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 17:39:42 2025 -0300

        fix(autocmd): best to fetch context when user is idle

    commit c3f6e17
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 17:35:21 2025 -0300

        fix(clean_up): remove unwanted specify file

    commit 1ef95f5
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:43:04 2025 -0300

        fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

        - Read message.mode field from CLI-persisted JSON (already stored by opencode)
        - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
        - Add message.mode to Message type definition, mark assistant_mode as deprecated
        - Update session_formatter to prefer message.mode over message.assistant_mode
        - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
        - Eliminates need for client-side mode persistence since CLI handles it

    commit c08f7e3
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:27:55 2025 -0300

        fix: show current mode for latest assistant message when assistant_mode is missing

        Display-time fallback for the most recent assistant message to show the current mode name when assistant_mode field hasn't been stamped yet. This fixes new messages showing generic 'ASSISTANT' instead of the active mode label (e.g., 'NEOAGENT').

        Historical messages remain unchanged, preserving their original mode labels or showing generic 'ASSISTANT' for old messages created before mode tracking was added.

    commit 80279eb
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:17:38 2025 -0300

        fix(ui): remove assistant_mode backfill to preserve historical mode labels

        The backfill loop was seeding from state.current_mode and stamping all
        historical assistant messages without assistant_mode, causing every
        message to show the current mode's name on restart rather than the mode
        used at that point in time.

        Removed lines 35-46 (backfill loop). Historical messages without
        assistant_mode now display as generic 'ASSISTANT' via existing fallback
        logic in _format_message_header (lines 299-304).

        This preserves immutability of stored assistant_mode values and prevents
        cross-session pollution.

    commit 3e7a8a8
    Merge: 2b691a6 be7c6a6
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 17:06:17 2025 -0300

        Merge branch 'style-assistant-name-is-agent-name'

    commit be7c6a6
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:43:04 2025 -0300

        fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

        - Read message.mode field from CLI-persisted JSON (already stored by opencode)
        - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
        - Add message.mode to Message type definition, mark assistant_mode as deprecated
        - Update session_formatter to prefer message.mode over message.assistant_mode
        - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
        - Eliminates need for client-side mode persistence since CLI handles it

    commit 82cf73e
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:27:55 2025 -0300

        fix: show current mode for latest assistant message when assistant_mode is missing

        Display-time fallback for the most recent assistant message to show the current mode name when assistant_mode field hasn't been stamped yet. This fixes new messages showing generic 'ASSISTANT' instead of the active mode label (e.g., 'NEOAGENT').

        Historical messages remain unchanged, preserving their original mode labels or showing generic 'ASSISTANT' for old messages created before mode tracking was added.

    commit db5ab7b
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 16:17:38 2025 -0300

        fix(ui): remove assistant_mode backfill to preserve historical mode labels

        The backfill loop was seeding from state.current_mode and stamping all
        historical assistant messages without assistant_mode, causing every
        message to show the current mode's name on restart rather than the mode
        used at that point in time.

        Removed lines 35-46 (backfill loop). Historical messages without
        assistant_mode now display as generic 'ASSISTANT' via existing fallback
        logic in _format_message_header (lines 299-304).

        This preserves immutability of stored assistant_mode values and prevents
        cross-session pollution.

    commit 9a59aaf
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 15:39:47 2025 -0300

        feat(context): add recent_buffers synthetic context (MRU buffers with optional symbols)

    commit cf1c5fd
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 15:35:51 2025 -0300

        feat(ui): stabilize assistant_mode labeling and improve session formatting robustness\n\n- Persist assistant_mode onto latest assistant message after run\n- Backfill assistant_mode for historical assistant messages for stable display names\n- Use assistant_mode (uppercase) in headers instead of generic ASSISTANT\n- Improve revert stats typing and snapshot action anchoring with display_line + range\n- Harden get_message_at_line nil checks to avoid indexing errors\n- Extend MessagePart.type to include patch and step-start; allow OutputExtmark function form\n- Add assistant_mode field to Message type\n- Fix synthetic user message check (part.synthetic ~= true)\n- Improve callout width handling when window invalid; fallback to config width or 80\n- Add type annotations for tool formatting inputs/metadata/output\n- Correct diff virt_text structure and highlight group names\n- General annotation cleanup and stability improvements

    commit 2b691a6
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 13:27:13 2025 -0300

        fix: add caching to context.load(), debounce WinLeave autocmd, fix types for LSP

    commit 9e8ebb5
    Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
    Date:   Thu Oct 2 12:50:11 2025 -0300

        feat: enhance context with plugin versions and buffer symbols, update types and tests

    commit 29cfaf2
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:17:10 2025 +0000

        Update README with enhanced context documentation

        Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

    commit 0e01ac7
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:14:30 2025 +0000

        Add enhanced context gathering functions and tests

        Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

    commit 8d28ff2
    Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
    Date:   Thu Oct 2 13:06:57 2025 +0000

        Initial plan

commit 75504e9
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 9 19:10:31 2025 -0300

    fix(base_url): race condition

commit e0506af
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 16:27:55 2025 -0300

    fix: show current mode for latest assistant message when assistant_mode is missing

    Display-time fallback for the most recent assistant message to show the current mode name when assistant_mode field hasn't been stamped yet. This fixes new messages showing generic 'ASSISTANT' instead of the active mode label (e.g., 'NEOAGENT').

    Historical messages remain unchanged, preserving their original mode labels or showing generic 'ASSISTANT' for old messages created before mode tracking was added.

commit 5cc8c74
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Thu Oct 2 13:06:57 2025 +0000

    Initial plan

commit 52c66e5
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 17:39:42 2025 -0300

    fix(autocmd): best to fetch context when user is idle

commit 3c04ded
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 20:42:41 2025 -0300

    fix(type): rollback for better reading

commit 93d880a
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Tue Oct 7 15:37:28 2025 -0300

    refactor: clean up PR sudo-tee#42 based on maintainer feedback

    - Remove unnecessary inline type annotations in session_formatter.lua
    - Remove deprecated assistant_mode field from Message type
    - Simplify mode field documentation
    - Remove assistant_mode fallback logic in header formatting
    - Restore accidentally deleted keymap and context config fields
    - Fix indentation inconsistencies

    This addresses all review feedback from @sudo-tee while preserving
    the core feature: using CLI-persisted mode field to display agent
    names (BUILD, PLAN, etc.) in assistant message headers.

commit f8c504f
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 16:43:04 2025 -0300

    fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

    - Read message.mode field from CLI-persisted JSON (already stored by opencode)
    - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
    - Add message.mode to Message type definition, mark assistant_mode as deprecated
    - Update session_formatter to prefer message.mode over message.assistant_mode
    - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
    - Eliminates need for client-side mode persistence since CLI handles it

commit 142f0ed
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 16:27:55 2025 -0300

    fix: show current mode for latest assistant message when assistant_mode is missing

    Display-time fallback for the most recent assistant message to show the current mode name when assistant_mode field hasn't been stamped yet. This fixes new messages showing generic 'ASSISTANT' instead of the active mode label (e.g., 'NEOAGENT').

    Historical messages remain unchanged, preserving their original mode labels or showing generic 'ASSISTANT' for old messages created before mode tracking was added.

commit 8251287
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Tue Oct 7 14:30:56 2025 -0300

    fix(ui): use CLI-persisted mode field instead of client-side assistant_mode mutation

    - Read message.mode field from CLI-persisted JSON (already stored by opencode)
    - Remove client-side assistant_mode mutation in core.lua (lines 145-154)
    - Add message.mode to Message type definition, mark assistant_mode as deprecated
    - Update session_formatter to prefer message.mode over message.assistant_mode
    - Maintain backward compatibility with fallback chain: mode → assistant_mode → current_mode → ASSISTANT
    - Eliminates need for client-side mode persistence since CLI handles it

commit fbb30fc
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 16:17:38 2025 -0300

    fix(ui): remove assistant_mode backfill to preserve historical mode labels

    The backfill loop was seeding from state.current_mode and stamping all
    historical assistant messages without assistant_mode, causing every
    message to show the current mode's name on restart rather than the mode
    used at that point in time.

    Removed lines 35-46 (backfill loop). Historical messages without
    assistant_mode now display as generic 'ASSISTANT' via existing fallback
    logic in _format_message_header (lines 299-304).

    This preserves immutability of stored assistant_mode values and prevents
    cross-session pollution.

commit 8968117
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 15:39:47 2025 -0300

    feat(context): add recent_buffers synthetic context (MRU buffers with optional symbols)

commit e6e8948
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 15:35:51 2025 -0300

    feat(ui): stabilize assistant_mode labeling and improve session formatting robustness\n\n- Persist assistant_mode onto latest assistant message after run\n- Backfill assistant_mode for historical assistant messages for stable display names\n- Use assistant_mode (uppercase) in headers instead of generic ASSISTANT\n- Improve revert stats typing and snapshot action anchoring with display_line + range\n- Harden get_message_at_line nil checks to avoid indexing errors\n- Extend MessagePart.type to include patch and step-start; allow OutputExtmark function form\n- Add assistant_mode field to Message type\n- Fix synthetic user message check (part.synthetic ~= true)\n- Improve callout width handling when window invalid; fallback to config width or 80\n- Add type annotations for tool formatting inputs/metadata/output\n- Correct diff virt_text structure and highlight group names\n- General annotation cleanup and stability improvements

commit 2d2cb6a
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 13:27:13 2025 -0300

    fix: add caching to context.load(), debounce WinLeave autocmd, fix types for LSP

commit 888214d
Author: Danilo Verde Ribeiro <danrio@Danilos-MacBook-Pro.local>
Date:   Thu Oct 2 12:50:11 2025 -0300

    feat: enhance context with plugin versions and buffer symbols, update types and tests

commit 0c71b6c
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Thu Oct 2 13:17:10 2025 +0000

    Update README with enhanced context documentation

    Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

commit bcbe451
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Thu Oct 2 13:14:30 2025 +0000

    Add enhanced context gathering functions and tests

    Co-authored-by: DanRioDev <1839750+DanRioDev@users.noreply.github.com>

commit 04403d9
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Thu Oct 2 13:06:57 2025 +0000

    Initial plan

commit 0f2d1e5
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 07:32:58 2025 -0400

    feat(blink): enable other completion sources for blink

    This should fix sudo-tee#65

commit e06f651
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 07:31:11 2025 -0400

    fix(cmp): fix file mention closing when typing for nvim_cmp

commit 84d9ae0
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:32:17 2025 -0400

    fix(mentions): letter `a` appended when triggering mentions

commit 44d22ba
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:23:49 2025 -0400

    test(toggle): fix tests for api.open

commit 826341d
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:18:09 2025 -0400

    fix(toggle): toggle keymap was always triggering insert mode

    This should fix sudo-tee#77

commit 803eb3e
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Wed Oct 22 15:53:52 2025 -0400

    docs(session_picker): add config for delete session in README

commit edba833
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Wed Oct 22 15:50:21 2025 -0400

    feat(session_picker): add keybind in title

commit 357ef3c
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Fri Oct 17 18:37:41 2025 -0700

    feat(session_picker): Fixes sudo-tee#68

commit fed6941
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 15:19:21 2025 -0400

    fix(completion): completion were broken after last change

commit c505554
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:53:50 2025 -0400

    fix(focus_input): fix focusing input on window opening

commit 4824151
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:37:36 2025 -0400

    fix(input_window): properly restore input text when reopening the window

commit ca62c0c
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:24:17 2025 -0400

    fix(bash-tool): properly shown bash command on permission prompt

    This should fix sudo-tee#74

commit 28d6379
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:08:45 2025 -0400

    fix: focusing input window in insert mode

    The shortcut <C-i> is interpreted as <tab> by terminals I moved it to i. sudo-tee#72

    focusing the input_window should restore to the previous position not
    the char before sudo-tee#64

commit 946af3a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 15:11:17 2025 -0400

    fix(slash_commands): allow slash_commands to be entered in input window

    This should fix sudo-tee#71

commit abc1e2a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 11:25:55 2025 -0400

    feat(completion): add folder icon kind

commit 031bf0a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 11:12:19 2025 -0400

    feat: support for folder mentions

commit e99a463
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 16 16:34:41 2025 -0400

    feat(completion): add file search from server api

commit 601cc82
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Thu Oct 9 15:52:47 2025 -0700

    fix(config): add config metatable (sudo-tee#59)

    Fixes sudo-tee#58

    Makes config access less error prone and more ergonomic
DanRioDev pushed a commit to DanRioDev/opencode.nvim that referenced this pull request Oct 29, 2025
commit 7653234
Author: Guillaume BOEHM <github@mail.gboehm.com>
Date:   Wed Oct 29 10:27:47 2025 +0000

    feat: add prompt_guard callback mechanism (sudo-tee#78)

    This PR adds a plugin option to run a callback before sending promts to the LLM or before opening the opencode window.

    In my use case I want to be able to exclude some directories of my computer with sensitive information in order to not mistakenly send them to the LLM.
    I've mostly vibe-coded this and then went back on the code to check what it did, I'm not super well versed in lua so I might have missed things.

    Implementation details:

    Add prompt_guard configuration option (function that returns boolean)
    Check guard before sending prompts (ERROR notification if denied)
    Check guard before opening buffer first time (WARN notification if denied)
    Add util.check_prompt_allowed() helper functions
    Guard has no parameters, users can access vim state directly
    Proper error handling for guard callback failures

    Co-authored-by: Guillaume BOEHM <git@mail.gboehm.com>

commit 0dc254b
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 28 12:01:42 2025 -0400

    fix(run): context args not passed in run new session

commit 6eb7354
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 28 11:18:48 2025 -0400

    chore(icons): deprecate emoji icons in favor of nerdfonts

commit 3dea370
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 28 08:49:27 2025 -0400

    chore(emmyrc): fix broken .emmyrc.json

commit c07f293
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Mon Oct 27 17:32:50 2025 -0700

    fix(renderer): render errors after last part

commit bebe01c
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 27 15:56:57 2025 -0400

    feat(rendering): incremental rendering (sudo-tee#62)

    Introduces an incremental rendering that updates only the changed portion(s) of the buffer instead of re-rendering everything on every change. This reduces CPU usages for large sessions.

    This PR also incorporate a functional test suite in `tests/manual` where you can record a run snapshot tests.

    This is a major revision of the rendering system.

    Co-authored-by:  Cameron Ring <cameron@cs.stanford.edu>

commit 0f2d1e5
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 07:32:58 2025 -0400

    feat(blink): enable other completion sources for blink

    This should fix sudo-tee#65

commit e06f651
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 07:31:11 2025 -0400

    fix(cmp): fix file mention closing when typing for nvim_cmp

commit 84d9ae0
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:32:17 2025 -0400

    fix(mentions): letter `a` appended when triggering mentions

commit 44d22ba
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:23:49 2025 -0400

    test(toggle): fix tests for api.open

commit 826341d
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 23 06:18:09 2025 -0400

    fix(toggle): toggle keymap was always triggering insert mode

    This should fix sudo-tee#77

commit 803eb3e
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Wed Oct 22 15:53:52 2025 -0400

    docs(session_picker): add config for delete session in README

commit edba833
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Wed Oct 22 15:50:21 2025 -0400

    feat(session_picker): add keybind in title

commit 357ef3c
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Fri Oct 17 18:37:41 2025 -0700

    feat(session_picker): Fixes sudo-tee#68

commit fed6941
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 15:19:21 2025 -0400

    fix(completion): completion were broken after last change

commit c505554
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:53:50 2025 -0400

    fix(focus_input): fix focusing input on window opening

commit 4824151
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:37:36 2025 -0400

    fix(input_window): properly restore input text when reopening the window

commit ca62c0c
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:24:17 2025 -0400

    fix(bash-tool): properly shown bash command on permission prompt

    This should fix sudo-tee#74

commit 28d6379
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Mon Oct 20 14:08:45 2025 -0400

    fix: focusing input window in insert mode

    The shortcut <C-i> is interpreted as <tab> by terminals I moved it to i. sudo-tee#72

    focusing the input_window should restore to the previous position not
    the char before sudo-tee#64

commit 946af3a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 15:11:17 2025 -0400

    fix(slash_commands): allow slash_commands to be entered in input window

    This should fix sudo-tee#71

commit abc1e2a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 11:25:55 2025 -0400

    feat(completion): add folder icon kind

commit 031bf0a
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Sat Oct 18 11:12:19 2025 -0400

    feat: support for folder mentions

commit e99a463
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 16 16:34:41 2025 -0400

    feat(completion): add file search from server api

commit 601cc82
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Thu Oct 9 15:52:47 2025 -0700

    fix(config): add config metatable (sudo-tee#59)

    Fixes sudo-tee#58

    Makes config access less error prone and more ergonomic

commit ca0ff90
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 09:50:28 2025 -0400

    chore: update .luarc.json for better support of emmylua_ls

commit a82b08c
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 09:49:28 2025 -0400

    fix: prefix replacement not working properly

commit 9d949e7
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Thu Oct 9 08:43:57 2025 -0400

    feat: add a keymap_prefix to configure the default `<leader>o`

commit 8c65d9b
Author: Cameron Ring <cameron@cs.stanford.edu>
Date:   Thu Oct 9 03:29:02 2025 -0700

    feat(config)!: modern keymap format + mode support (sudo-tee#52)

    This is a complete overhaul of the keymaps,

    The old config should still work but with a warning for migration

    The new format shoud now be:
    ```lua
     keymap = {
        editor = {
          ['<leader>og'] = { 'toggle' }, -- I don't think we really need to support just string, it makes things more complex for nothing
          ['<leader>oi'] = { 'open_input' },
          ['<leader>oI'] = { 'open_input_new_session' },
          ['<leader>oo'] = { 'open_output' },
          ['<leader>ot'] = { 'toggle_focus' },
          ['<leader>oq'] = { 'close' },
          ['<leader>os'] = { 'select_session' },
          ['<leader>op'] = { 'configure_provider' },
          ['<leader>od'] = { 'diff_open' },
          ['<leader>o]'] = { 'diff_next' },
          ['<leader>o['] = { 'diff_prev' },
          ['<leader>oc'] = { 'diff_close' },
          ['<leader>ora'] = { 'diff_revert_all_last_prompt' },
          ['<leader>ort'] = { 'diff_revert_this_last_prompt' },
          ['<leader>orA'] = { 'diff_revert_all' },
          ['<leader>orT'] = { 'diff_revert_this' },
          ['<leader>orr'] = { 'diff_restore_snapshot_file' },
          ['<leader>orR'] = { 'diff_restore_snapshot_all' },
          ['<leader>oC'] = { 'open_configuration_file' },
          ['<leader>ox'] = { 'swap_position' },
          ['<leader>opa'] = { 'permission_accept' },
          ['<leader>opA'] = { 'permission_accept_all' },
          ['<leader>opd'] = { 'permission_deny' },
        },
        output_window = {
          ['<leader>something'] = {function ()
                       -- custom code
          end},
          ['<esc>'] = { 'close' },
          ['<C-c>'] = { 'stop' },
          [']]'] = { 'next_message' },
          ['[['] = { 'prev_message' },
          ['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } },
          ['<C-i>'] = { 'focus_input' },
          ['<leader>oS'] = { 'select_child_session' },
          ['<leader>oD'] = { 'debug_message' },
          ['<leader>oO'] = { 'debug_output' },
          ['<leader>ods'] = { 'debug_session' },
        },
        input_window = {
          ['<cr>'] = { 'submit_input_prompt', mode = { 'n', 'i' } },
          ['<esc>'] = { 'close' },
          ['<C-c>'] = { 'stop' },
          ['~'] = { 'mention_file', mode = 'i' },
          ['@'] = { 'mention', mode = 'i' },
          ['/'] = { 'slash_commands', mode = 'i' },
          ['<tab>'] = { 'toggle_pane', mode = { 'n', 'i' } },
          ['<up>'] = { 'prev_prompt_history', mode = { 'n', 'i' } },
          ['<down>'] = { 'next_prompt_history', mode = { 'n', 'i' } },
          ['<M-m>'] = { 'switch_mode' },
          ['<leader>oS'] = { 'select_child_session' },
          ['<leader>oD'] = { 'debug_message' },
          ['<leader>oO'] = { 'debug_output' },
          ['<leader>ods'] = { 'debug_session' },
        },
        permission = {
          accept = 'a',
          accept_all = 'A',
          deny = 'd',
        },
    ```

commit fb33ce6
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 10:22:36 2025 -0400

    refactor: simplify keymaps by having a corresponding api function

commit fa31457
Author: Francis Belanger <francis.belanger@gmail.com>
Date:   Tue Oct 7 13:23:32 2025 -0400

    feat: restore mentions when navigating history
@cameronr cameronr deleted the fix/config-metatable branch November 1, 2025 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config for input_height and window_width don't work

2 participants