Skip to content

Conversation

krishna-bala
Copy link
Collaborator

@krishna-bala krishna-bala commented Jun 3, 2025

Summary

  • Makes claude-code terminal buffer unlisted by default (doesn't appear in :ls output)
  • Maintains compatibility with new multi-instance support
  • Includes comprehensive test coverage for the nobuflisted behavior

Test plan

  • Rebased onto latest main branch
  • All existing tests pass (52/54 - 2 pre-existing failures unrelated to this change)
  • New test verifies nobuflisted behavior is applied correctly
  • Code formatting applied with stylua

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Terminal buffers are now unlisted by default and will no longer appear in the output of the :ls command.
  • Bug Fixes

    • None.
  • Tests

    • Added a test to verify that new terminal buffers are set as unlisted.
  • Documentation

    • Updated the changelog to reflect the new buffer listing behavior.

krishna-bala and others added 2 commits June 2, 2025 18:28
Prevents claude-code terminal buffer from appearing in buffer lists (`:ls`, `:buffers`)
by adding 'setlocal nobuflisted' when creating the terminal window.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

The changes update the changelog to document that terminal buffers are now unlisted by default. The terminal module is modified to explicitly set new terminal buffers as unlisted, preventing them from appearing in buffer lists. Corresponding tests are added to verify this behavior by checking the issued Vim commands.

Changes

File(s) Change Summary
CHANGELOG.md Added an entry noting that terminal buffers are now unlisted by default.
lua/claude-code/terminal.lua Set new terminal buffers as unlisted; minor code style adjustments in conditionals and strings.
tests/spec/terminal_spec.lua Added tests to ensure terminal buffers are set as unlisted when created.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TerminalModule
    participant Vim

    User->>TerminalModule: Call toggle()
    TerminalModule->>Vim: Create new terminal buffer
    TerminalModule->>Vim: Set bufhidden=hide
    TerminalModule->>Vim: Set nobuflisted
Loading

Possibly related PRs

  • Add instance per git root #26: Refactored terminal buffer management to support multiple instances and keyed buffers, which is directly extended by the current PR's unlisting feature.

Poem

A buffer once listed, now hidden from view,
The rabbit hops softly, with something new.
No longer in :ls does the terminal appear,
Unlisted by magic, the code is now clear.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffdf35d and 02f1723.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • lua/claude-code/terminal.lua (3 hunks)
  • tests/spec/terminal_spec.lua (1 hunks)
🔇 Additional comments (5)
lua/claude-code/terminal.lua (3)

72-72: LGTM: Clean conditional consolidation.

The refactoring consolidates multiple conditional checks into a single line without changing the logic, improving code readability.


110-110: LGTM: Consistent quote style.

The change from double quotes to single quotes maintains consistency with the surrounding code style.


155-155: LGTM: Core feature implementation looks correct.

The addition of setlocal nobuflisted correctly implements the main feature of making terminal buffers unlisted by default. This is placed appropriately after the terminal creation and before other buffer configurations, ensuring the buffer won't appear in :ls output as intended.

tests/spec/terminal_spec.lua (1)

409-428: LGTM: Comprehensive test coverage for the new feature.

The test correctly verifies that the setlocal nobuflisted command is issued when creating a new terminal buffer. The test setup, execution, and assertion follow the established patterns in the file and provide appropriate coverage for the unlisted buffer functionality.

CHANGELOG.md (1)

13-13: LGTM: Clear documentation of the new feature.

The changelog entry accurately documents the new unlisted buffer behavior with a clear explanation of its user-visible impact. The placement under the "Added" section is appropriate for this new feature.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@greggh
Copy link
Owner

greggh commented Jun 10, 2025

I know there was some discussion around this idea, but I don't see it in these comments. I believe it was related to other PRs and work you might have been doing. Can you clarify that for me before we merge this one in?

@willgoudie
Copy link

why hasn't this been merged?

@greggh
Copy link
Owner

greggh commented Jul 2, 2025

why hasn't this been merged?

I had an accident and multiple fractures with many hospital visits that kept me away. I am starting to catch up now, but I'm pretty slow with only one hand available.

On this one I was/am waiting on as reply from @krishna-bala to my last comment to see what we do next.

@krishna-bala
Copy link
Collaborator Author

@willgoudie @greggh sorry for the delay. My initial concern with merging this was due to other PRs which were adding a feature to enable multiple claude code buffers. Let me review the other open PRs and come back to this one - I will try and merge or close this PR by end of week.

khaneliman added a commit to khaneliman/khanelivim that referenced this pull request Sep 16, 2025
prevent accidentally closing claude-code session with bufremove
commands. greggh/claude-code.nvim#34
khaneliman added a commit to khaneliman/khanelivim that referenced this pull request Sep 16, 2025
prevent accidentally closing claude-code session with bufremove
commands. greggh/claude-code.nvim#34
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.

3 participants