Skip to content

fix(pager): fix pagers that use stdio - #214

Merged
bougyman merged 2 commits into
mainfrom
fix-pager
Sep 4, 2026
Merged

fix(pager): fix pagers that use stdio#214
bougyman merged 2 commits into
mainfrom
fix-pager

Conversation

@bougyman

@bougyman bougyman commented Sep 4, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI lite review requested due to automatic review settings September 4, 2026 15:55
@bougyman
bougyman merged commit 6d56882 into main Sep 4, 2026
4 checks passed
@bougyman
bougyman deleted the fix-pager branch September 4, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated pager module docstring is currently broken, and the new default runner can raise hard when sh isn’t available (e.g., on Windows targets) instead of gracefully falling back.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the CLI pager invocation so that pagers which render to standard output (rather than interacting via /dev/tty) work correctly in LinearCli.CLI.Pager.

Changes:

  • Switch the default pager runner from System.shell/1 to a Port.open/2-based runner intended to inherit the terminal’s standard streams.
  • Add a test setup hook to ensure $PAGER is consistently unset/restored across tests.
File summaries
File Description
app/lib/linear_cli/cli/pager.ex Changes the default pager execution strategy and updates related module documentation.
app/test/linear_cli/cli/pager_test.exs Adds setup to isolate $PAGER environment state during the pager test suite.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +89 to +104
# `System.shell/1` captures a child's stdout. That made pagers such as
# `bat` appear to succeed while their output was silently discarded.
defp run_pager(command) do
shell = System.find_executable("sh") || raise "could not find sh on PATH"

port =
Port.open({:spawn_executable, shell}, [
:nouse_stdio,
:exit_status,
args: ["-c", command]
])

receive do
{^port, {:exit_status, status}} -> {"", status}
end
end
Comment on lines 13 to +16
When paging is needed the content is written to a temp file and the
pager is invoked via `System.shell/1`, which — like
`Owl.IO.open_in_editor/2`'s own use of the same function — lets the
child process open `/dev/tty` directly for interactive keyboard
control.
The pager inherits the terminal's standard streams, so pagers that
render to standard output (such as `bat`) work as well as interactive
pagers such as `less`.
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.

2 participants