Skip to content

feat(extensions): add Tabby extension for persisting tab names#78

Closed
ChristophSchmidpeter wants to merge 1 commit intostevearc:masterfrom
ChristophSchmidpeter:feat/tabby-extension
Closed

feat(extensions): add Tabby extension for persisting tab names#78
ChristophSchmidpeter wants to merge 1 commit intostevearc:masterfrom
ChristophSchmidpeter:feat/tabby-extension

Conversation

@ChristophSchmidpeter
Copy link
Copy Markdown

@ChristophSchmidpeter ChristophSchmidpeter commented Sep 27, 2025

What

Add a new extension that saves and restores Tabby (nanozuki/tabby.nvim)
tab names across sessions. It prefers Tabby’s canonical global
vim.g.TabbyTabNames when present and falls back to querying Tabby’s API
to build a JSON mapping.

Why

Tabby users often assign custom tab names, but those are lost when
restarting Neovim. This extension ensures tab names are preserved
seamlessly with resession.

How

  • Save hook: export vim.g.TabbyTabNames or compute a fallback via Tabby’s API.
  • Load hook: restore the JSON, refresh the tabline.
  • Safety measures:
    • wrap external calls in pcall so loading works if Tabby is absent,
    • only write the global when the JSON differs,
    • trigger a UI refresh (redrawtabline) after restore.

Notes

  • No configuration required.
  • Fails gracefully when Tabby is not installed.

Add a new extension that saves and restores Tabby (nanozuki/tabby.nvim)
tab names across sessions. It prefers Tabby’s canonical global
`vim.g.TabbyTabNames` when present and falls back to querying Tabby’s API
to build a JSON mapping.

Restoration is safe and conservative:
- wrap external calls in `pcall` so loading works if Tabby is absent,
- only write the global when the JSON differs,
- trigger a UI refresh (`redrawtabline`) after restore.
Copilot AI review requested due to automatic review settings September 27, 2025 14:12
@github-actions github-actions bot requested a review from stevearc September 27, 2025 14:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Add a new extension for resession.nvim that persists Tabby tab names across session saves and restores. The extension provides fallback mechanisms and safe restoration practices.

  • Implements on_save and on_post_load functions for the resession extension API
  • Adds fallback logic to compute tab names from Tabby API when global variable is unavailable
  • Uses defensive programming with pcall wrappers for safe external library calls

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if type(data) ~= "table" then return end
local json = data.tabby_tab_names_json
if type(json) ~= "string" or json == "" then return end
vim.g.TabbyTabNames = json
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restoration unconditionally overwrites vim.g.TabbyTabNames even when the current value might be identical. According to the description, it should 'only write the global when the JSON differs', but there's no comparison with the existing value.

Suggested change
vim.g.TabbyTabNames = json
if vim.g.TabbyTabNames ~= json then
vim.g.TabbyTabNames = json
end

Copilot uses AI. Check for mistakes.
local json = data.tabby_tab_names_json
if type(json) ~= "string" or json == "" then return end
vim.g.TabbyTabNames = json
-- LSP false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table.
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment refers to 'LSP false positive' but should refer to 'LuaLS false positive' or 'language server false positive' for clarity, since LSP (Language Server Protocol) is the protocol, not the specific tool generating the warning.

Suggested change
-- LSP false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table.
-- LuaLS false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table.

Copilot uses AI. Check for mistakes.
@stevearc
Copy link
Copy Markdown
Owner

Thanks for the PR! For organizational purposes, I think it makes more sense to put these plugin-specific extensions into the plugin repos instead of in resession. The only extensions that resession ships with are for built-in neovim features (colorscheme and quickfix). The resession API is very stable; I think it's only changed once, and it was done in a backwards compatible way, so it's likely better to keep the extension code more tightly coupled with the plugin it supports because it is more likely those will have to change in tandem.

@stevearc stevearc closed this Sep 30, 2025
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