bug: dashboard terminal takes 10 seconds to display stdout
Did you check docs and existing issues?
- [x] I have read all the snacks.nvim docs
- [x] I have updated the plugin to the latest version before submitting this issue
- [x] I have searched the existing issues of snacks.nvim
- [x] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
NVIM v0.11.0 Build type: Release LuaJIT 2.1.1744318430 Run "nvim -V1 -v" for more info
Operating system/version
macOS 15.3.2
Describe the bug
The terminal sections on the dashboard if they take anything more than a few ms, will have their output delayed for 10 seconds.
Steps To Reproduce
-
Use the dashboard section configuration specified here: https://github.com/folke/snacks.nvim/blob/main/docs/dashboard.md#github
-
Start nvim
-
Dashboard will display instantly with fast startup time, but terminal sections using
ghon right will take 10 seconds before they display any output. Even though the same commands run in a terminal will run in less than 1 second.
Expected Behavior
That the dashboard terminal sections display the stdout in real time or relatively real time.
Repro
In this repro there's two terminal sections on the right. One displays the gh command output that makes a http request and so takes < 1s, while the other displays git command output that finishes much faster.
The slower command output takes 10s-12s to display, even though it completes in 1s.
The repro assumes the gh command is installed.
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{
"folke/snacks.nvim",
opts = {
dashboard = {
enabled = true,
sections = {
{ section = "header" },
{ section = "keys", gap = 1, padding = 1 },
function()
local in_git = Snacks.git.get_root() ~= nil
local cmds = {
{
title = "Open Issues",
cmd = "gh issue list -L 3",
key = "i",
action = function()
vim.fn.jobstart("gh issue list --web", { detach = true })
end,
icon = " ",
height = 7,
},
{
icon = " ",
title = "Git Status",
cmd = "git --no-pager diff --stat -B -M -C",
height = 10,
},
}
return vim.tbl_map(function(cmd)
return vim.tbl_extend("force", {
pane = 2,
section = "terminal",
enabled = in_git,
padding = 1,
ttl = 5 * 60,
indent = 3,
}, cmd)
end, cmds)
end,
{ section = "startup" },
},
},
},
},
},
})
I've updated the description above narrowing the repro so that it is much smaller.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
The problem still appears to happen with latest version.
This issue appears on my machine as well. The dashboard starts very fast, but the outcome of the command appears very slow. The command runs much faster in the general terminal. Link to the configuration.
This also happens for me where it takes a very long time.
And, this week, the Issue and PR sections now no longer seem to actually show the tables, but the command line does? I see the results flash on my terminal for a second and then get replaced with a ":"
i also encounter this problem. terminal section with chafa command will show output after 5 seconds. but trivial commands like echo or ls show result immediatly
Yeah I noticed this as well. Tried setting ttl: 0 but that didn't help either. Takes about 10 seconds for me, even though running the command from the terminal is under a second.
I figured it out! It's an issue with chafa.
Adding --probe off to my chafa command fixed it for me. According to chafa --help, chafa tries to probe the terminal it's running in before displaying the image. The default amount of time it spends trying to probe is 5 seconds
I figured it out! It's an issue with chafa.
Adding
--probe offto my chafa command fixed it for me. According tochafa --help, chafa tries to probe the terminal it's running in before displaying the image. The default amount of time it spends trying to probe is 5 seconds
works for me.
I get this issue with gh contribs (an extension), and my other gh terminal outputs... possible to add something like a spinner for each terminal until commands complete and then replace spinner with command output?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
sorry to bring this back from the dead, but i'm still experiencing this issue with gh commands in the dashboard. any solutions?
It is definitely not dead. Thanks for bringing it back
i have no idea why this changes anything, but when i write my own scripts, i get fast output again.
for example, i have defined the following jq functions in ~/.jq (which gets auto-sourced by jq)
def time_delta:
now - (. | fromdateiso8601) | floor as $secs |
($secs / 60) | floor as $mins |
($secs / 3600) | floor as $hours |
($secs / 86400) | floor as $days |
if $days >= 90 then
"stale"
elif $days >= 1 then
($days | tostring) + "d ago"
elif $hours >= 1 then
($hours | tostring) + "h ago"
elif $mins >= 1 then
($mins | tostring) + "m ago"
else
($secs | tostring) + "s ago"
end;
def ascii_only:
[explode[] | select(. < 128)] | implode;
def rpad(size):
. | tostring |
if (. | length) >= size then
.[:size]
else
. + (" " * (size - (. | length)))
end;
def lpad(size):
. | tostring |
if (. | length) >= size then
.[:size]
else
(" " * (size - (. | length))) + .
end;
def ascii_rpad(size):
. | tostring | ascii_only |
if (. | length) >= size then
.[:size]
else
. + (" " * (size - (. | length)))
end;
def ascii_lpad(size):
. | tostring | ascii_only |
if (. | length) >= size then
.[:size]
else
(" " * (size - (. | length))) + .
end;
def read_status:
if .unread then
"◉"
else
""
end;
def notification_type:
if .subject.type == "PullRequest" then
"PR"
elif .subject.type == "Issue" then
"ISS"
elif .subject.type == "Release" then
"REL"
else
.subject.type
end;
and i have defined the following scripts on my $PATH. each is in their own file, just grouped here for brevity:
#!/usr/bin/env sh
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" '/notifications?per_page=5' |
jq -r '.[] | "\u001b[32m\(read_status | rpad(2)) \u001b[35m\(.repository.name | rpad(16)) \u001b[0m\(.subject.title | rpad(32)) \u001b[38;2;84;92;126m\(notification_type | ascii_lpad(4))"'
gh pr list -L 5 --state open --json number,title,updatedAt |
jq -r '.[] | "\u001b[32m#\(.number | rpad(6)) \u001b[0m\(.title | ascii_rpad(40)) \u001b[38;2;84;92;126m\(.updatedAt | time_delta | ascii_lpad(8))"'
gh issue list -L 5 --state open --json number,title,updatedAt |
jq -r '.[] | "\u001b[32m#\(.number | rpad(6)) \u001b[0m\(.title | ascii_rpad(40)) \u001b[38;2;84;92;126m\(.updatedAt | time_delta | ascii_lpad(8))"'
then in my snacks dashboard opts i have (basically the same as the docs but using the scripts i wrote as commands):
function()
local in_git = Snacks.git.get_root() ~= nil
local cmds = {
{
title = "Notifications",
cmd = "gh-notifications",
icon = " ",
key = "n",
height = 5,
action = function()
vim.ui.open("https://github.com/notifications")
end,
enabled = true,
},
{
title = "Open Issues",
cmd = "gh-issues",
icon = " ",
key = "i",
action = function()
vim.fn.jobstart("gh issue list --web", { detach = true })
end,
height = 5,
},
{
title = "Open PRs",
cmd = "gh-prs",
icon = " ",
key = "p",
height = 5,
action = function()
vim.fn.jobstart("gh pr list --web", { detach = true })
end,
},
}
return vim.tbl_map(function(cmd)
return vim.tbl_extend("force", {
pane = 2,
section = "terminal",
enabled = in_git,
padding = 1,
ttl = 60, -- 1 minute
indent = 3,
}, cmd)
end, cmds)
end,
this gets me close enough to my desired dashboard with a response time i'm very happy with. see the image for my dashboard. its not vim porn or anything but i like it.
for anyone looking for a workaround, hope this helps!
I was working on an additional option for fields where it wouldn't stop showing output after a certain time. But I've since gotten sidetracked on other work. However I do plan on coming back to it at some point.
Can we re-open this, since the issue still exist?
This should be fixed on main. Did you update?
This commit: https://github.com/folke/snacks.nvim/commit/fb016d20c2a415450708e3eb837462f6dcea46ba
Oh. Sorry, I'm using the latest version instead of main. Yes, this is fixed on the main branch. Thanks a lot.