Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Keeps the Cargo dependencies and the SHA-pinned actions in .github/workflows current.
#
# Version updates arrive at most monthly, and only for releases at least 7 days old, so a
# compromised release has time to be found and pulled. Minor and patch updates are grouped into
# one PR per ecosystem. Majors open as their own PRs, so one breaking upgrade cannot block the
# rest, and the PR limit leaves room for them beside the group. For a 0.x crate Dependabot counts
# a minor bump (0.28 to 0.29) as a major, as Cargo does. The TUI crates that must move together are
# the exception, in a group of their own. Security updates ignore the version-update groups and
# would open one PR per package, so they get their own group of minor and patch updates, and a
# security major opens on its own.
#
# rust-toolchain.toml sets `channel = "stable"` rather than a version, so it has nothing for
# Dependabot to bump and has no entry here.
# The tools ci.yml installs with taiki-e/install-action are pinned by version in its `tool` input,
# which Dependabot does not read, so those versions are bumped by hand.
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
open-pull-requests-limit: 5
groups:
# ansi-to-tui depends on a ratatui version, and ratatui on a crossterm version, that
# ui/tui/Cargo.toml must match. deny.toml rejects duplicate versions, so one moving alone
# fails CI. They arrive as one PR, majors included. Dependabot gives a dependency to the
# first group that matches, so this group comes before the catch-all.
# Security updates move only the vulnerable crate, so a fix that needs a newer crossterm
# than ratatui allows arrives alone and fails deny. cargo audit fails CI meanwhile, and the
# fix is the ratatui upgrade this group proposes.
tui:
applies-to: version-updates
patterns: [ansi-to-tui, crossterm, ratatui]
cargo:
applies-to: version-updates
patterns: ['*']
update-types: [minor, patch]
cargo-security:
applies-to: security-updates
patterns: ['*']
update-types: [minor, patch]
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
open-pull-requests-limit: 5
groups:
actions:
applies-to: version-updates
patterns: ['*']
update-types: [minor, patch]
actions-security:
applies-to: security-updates
patterns: ['*']
update-types: [minor, patch]
37 changes: 30 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [main]
pull_request:

# CI only reads the repository, so its token can do nothing else, whatever the repo's default is.
permissions:
contents: read

jobs:
check:
# hub runs on macOS and is also developed in Linux sandboxes, so every push to main and every
Expand All @@ -16,16 +20,27 @@ jobs:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# Each action is pinned to a full commit SHA, so a moved tag cannot change the action code CI
# runs. Dependabot proposes new pins (.github/dependabot.yml). The `stable` toolchain still
# follows the latest Rust release.
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
# rustup is already on the hosted runners, so no third-party action installs the toolchain.
- name: install toolchain
run: rustup toolchain install stable --profile minimal --component rustfmt,clippy

- uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3

- name: install tools
run: cargo install cargo-audit cargo-deny cargo-nextest --locked
# Prebuilt binaries at exact versions, each checked against the checksum in the action's
# manifest, so CI compiles none of them, and a new release reaches CI only through a commit
# that changes its version here. `fallback: none` fails the step rather than building a
# version the manifest lacks. Dependabot does not read `tool`, so these versions are bumped
# by hand. This runs after rust-cache, so binaries the cache restores into ~/.cargo/bin are
# replaced rather than used.
- uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32
with:
tool: cargo-audit@0.22.2,cargo-deny@0.20.2,cargo-nextest@0.9.149,taplo@0.10.0
fallback: none

# rustfmt resolves mod declarations even behind #[cfg(feature = "private")],
# so it fails if the private symlinks (from hub-private) aren't present.
Expand All @@ -41,6 +56,14 @@ jobs:
- name: fmt
run: cargo fmt --check

# Dependabot edits the Cargo.toml files without running prek's hooks, so CI checks their
# formatting and TOML syntax the way prek.toml does.
- name: taplo fmt
run: taplo fmt --check

- name: taplo check
run: taplo check

- name: clippy
run: cargo clippy --all-targets -- -D warnings

Expand Down
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ commits and the `Fixes #N` lines in them are lost, and the issues they fixed sta
#384, 2026-10-28). An independent review of the change still runs before the push, and the user
sees its findings first.

**A Dependabot PR that changes `Cargo.toml` or `Cargo.lock` is merged only after `just lint` and
`just test` pass at its head commit, in a checkout where `just setup-private` has linked every
hub-private module.** CI builds only the configuration without hub-private, so a dependency update
that breaks a hub-private build still passes CI. `just check` is not enough here: it rewrites files
and runs no tests.

## Verifying TUI changes

**Every change that alters what the TUI shows or how it behaves is driven live
Expand Down
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ date: 2026-11-01
## Decision

Every commit of hub, with or without each hub-private module, builds, passes clippy and passes its
tests on macOS and on Linux. CI builds, lints and tests every push on both, as a matrix of
`macos-latest` and `ubuntu-latest`.
tests on macOS and on Linux. CI builds, lints and tests every push to `main` and every pull
request on both, as a matrix of `macos-latest` and `ubuntu-latest`.

hub runs on macOS. What only macOS has stays macOS-only behind `cfg(target_os = "macos")`: the
disclaimed spawn of decision 027's addendum of 2026-11-01, launchd, and the notifications the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ runs it, `just check` runs `just lint`, and prek runs `just lint` before every c
fails, it names the configurations that failed and points here.

Public CI checks only the first configuration, because it has no hub-private. It checks it on
both platforms: `.github/workflows/ci.yml` runs fmt, clippy, the tests, audit and deny on
both platforms: `.github/workflows/ci.yml` runs fmt, taplo, clippy, the tests, audit and deny on
`macos-latest` and on `ubuntu-latest` for every push to `main` and every pull request.

What the check misses:
Expand All @@ -70,6 +70,9 @@ What the check misses:
push, in only the fullest configuration the checkout has, and public CI runs only the one without
hub-private. So the private configurations' tests run on Linux only when an orb runs `just test`,
and the tests of hub-private without the media module never run on a device that has it.
- **Dependabot's commits.** Dependabot commits on GitHub, where prek never runs `just lint`.
AGENTS.md has a Dependabot PR that changes the Cargo files merged only after `just lint` and
`just test` pass in a checkout with every hub-private module linked.
- **Runtime behaviour.** A stub that compiles can still do the wrong thing. `media_stub.rs` has a
test asserting that it returns an error. That test runs only on a device without the media
module.
14 changes: 7 additions & 7 deletions docs/questions/should-the-tui-be-rebuilt-in-textual.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ same discussion and holds regardless of what the spike shows.
all. Cost: the browser surface Decision 007 deferred stays expensive to reach, and the hand-drawn
chrome plus the 545-line markdown renderer stay hub's to maintain.
- **B. Rebuild in Textual.** Strongest case: `textual serve` keeps Decision 007's one reopening
condition cheap; Textual ships the `Markdown` widget, `TextArea` and CSS borders that five
dependencies currently provide (`pulldown-cmark`, `syntect`, `two-face`, `ansi-to-tui`,
`tui-textarea`); and Python is where the Claude Agent SDK lives if hub ever drives investigation
sessions rather than launching them through tmux. Cost: 641 tests and 51 snapshots do not port
condition cheap; Textual ships the `Markdown` widget and CSS borders that four dependencies
currently provide (`pulldown-cmark`, `syntect`, `two-face`, `ansi-to-tui`); and Python is where
the Claude Agent SDK lives if hub ever drives investigation sessions rather than launching them
through tmux. Cost: 641 tests and 51 snapshots do not port
mechanically, and the domain newtypes lose compile-time enforcement in exchange for mypy at CI
time.
- **C. Not yet.** Strongest case: Decisions 021 and 022 are not fully built (the TUI still fetches
Expand All @@ -91,9 +91,9 @@ into a decision record._
`render/` and `markdown/`, plus `main.rs`; `render/status_bar.rs` imports none of it.
- *Measured* (2026-09-16): Textual's latest release is v8.2.8, 30 June 2026, from
https://github.com/Textualize/textual/releases.
- *Sourced*: `ui/tui/Cargo.toml` pins ratatui at 0.29 because 0.30 moved `Widget` into a separate
crate, and pins itertools at 0.13 solely to match ratatui's own copy and satisfy `cargo-deny`'s
duplicate-version ban. Both pins carry the reason in a manifest comment.
- *Sourced*: `ui/tui/Cargo.toml` keeps ratatui at 0.29 because `ansi-to-tui` 7 depends on it, and
`ansi-to-tui` 8 moved to `ratatui-core` with ratatui 0.30. `crossterm` follows ratatui's copy to
satisfy `cargo-deny`'s duplicate-version ban. The manifest comments carry both reasons.
- *Sourced*: there is no release pipeline. `.github/workflows/ci.yml` runs checks and produces no
artifacts; installation is `cargo install --path ui/tui` on the machine that will run it. Neither
language has a distribution advantage here until that changes.
Expand Down
16 changes: 5 additions & 11 deletions ui/tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,16 @@
chrono = "0.4"
clients = { path = "../../clients" }
config = { path = "../../config" }
# The crossterm version ratatui depends on (0.28 for ratatui 0.29). deny.toml rejects a second
# copy, so this moves with ratatui.
crossterm = { version = "0.28", features = ["event-stream"] }
domain = { path = "../../domain" }
futures = "0.3"
# Pinned to 0.13 to unify with ratatui 0.29, which also depends on itertools 0.13.
# cargo-deny's bans check rejects duplicate versions; only with_position()/Position
# are used here, an API present in both 0.13 and 0.14. Bump in lockstep with ratatui.
itertools = "0.13"
open = "5"
pulldown-cmark = { version = "0.13", default-features = false }
# Pinned to 0.29 to unify with tui-textarea 0.7, which also depends on 0.29.
# tui-textarea 0.7 implements ratatui 0.29's Widget trait; ratatui 0.30 moved
# Widget into a new ratatui-core crate, making set_block() and direct TextArea
# rendering fail to compile. Before bumping this, check that the target
# tui-textarea version also supports the new ratatui version — and keep
# ansi-to-tui in sync (v8 switched to ratatui-core; v7 uses ratatui 0.29).
# ansi-to-tui must depend on this ratatui version: v7 uses ratatui 0.29, and v8 moved to
# ratatui-core with ratatui 0.30. ratatui, crossterm and ansi-to-tui move together, and
# Dependabot proposes them as one PR (the `tui` group in .github/dependabot.yml).
ratatui = "0.29"
rusqlite = { version = "0.31", features = ["bundled"] }
secrecy = "0.8"
Expand All @@ -50,7 +45,6 @@
"regex-fancy",
] }
tokio = { version = "1", features = ["full"] }
tui-textarea = { version = "0.7", features = ["crossterm"] }
two-face = { version = "0.5", default-features = false, features = [
"syntect-fancy",
] }
Expand Down
9 changes: 6 additions & 3 deletions ui/tui/src/markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Vendored and patched fork of [tui-markdown 0.3.7][tui-markdown] (MIT/Apache-2.0)

## What changed

Two lines in `mod.rs` differ from upstream:
These changes in `render.rs` differ from upstream:

1. **`SYNTAX_SET`** — uses `two_face::syntax::extra_newlines()` instead of
`SyntaxSet::load_defaults_newlines()`. This extends the bundled syntax set from
Expand All @@ -14,6 +14,9 @@ Two lines in `mod.rs` differ from upstream:
2. **`MOCHA_THEME`** — uses `two_face::theme::extra().get(EmbeddedThemeName::CatppuccinMocha)`
instead of `base16-ocean.dark`.

3. **`text`** — splits multi-line text with `enumerate()` where upstream uses
`itertools::with_position()`, so hub does not depend on `itertools`.

`style_sheet.rs` adds `CatppuccinStyleSheet`, which the module's `from_str` uses
as its default. It styles headings and inline code in Mocha mauve to match
`FOCUS_COLOR` in `render/mod.rs`.
Expand All @@ -24,8 +27,8 @@ avoid the `tracing` dependency.
## Staying in sync with upstream

[tui-markdown releases][releases] are infrequent. If a new version ships, diff
`src/lib.rs` from upstream against `mod.rs` here, apply any logic changes, and
re-apply the two patches above.
`src/lib.rs` from upstream against `render.rs` here, apply any logic changes, and
re-apply the patches above.

[tui-markdown]: https://github.com/joshka/tui-markdown
[releases]: https://github.com/joshka/tui-markdown/releases
1 change: 1 addition & 0 deletions ui/tui/src/markdown/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// - SYNTAX_SET uses two-face's extended syntax set (adds TypeScript, TOML, etc.)
// - Theme uses two-face's built-in CatppuccinMocha instead of base16-ocean.dark
// - tracing instrumentation removed
// - multi-line text split with enumerate() instead of itertools' with_position()
// - pub(crate) visibility throughout
pub(crate) mod options;
pub(crate) mod render;
Expand Down
24 changes: 21 additions & 3 deletions ui/tui/src/markdown/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// - SYNTAX_SET uses two-face's extended syntax set (adds TypeScript, TOML, etc.)
// - Theme uses two-face's built-in CatppuccinMocha instead of base16-ocean.dark
// - tracing instrumentation removed
// - multi-line text split with enumerate() instead of itertools' with_position()
// - pub(crate) visibility throughout

use std::sync::LazyLock;

use ansi_to_tui::IntoText;
use itertools::{Itertools, Position};
use pulldown_cmark::{
BlockQuoteKind, CodeBlockKind, CowStr, Event, HeadingLevel, Options as ParseOptions, Parser,
Tag, TagEnd,
Expand Down Expand Up @@ -294,12 +294,12 @@ where
return;
}

for (position, line) in text.lines().with_position() {
for (i, line) in text.lines().enumerate() {
if self.needs_newline {
self.push_line(Line::default());
self.needs_newline = false;
}
if matches!(position, Position::Middle | Position::Last) {
if i > 0 {
self.push_line(Line::default());
}
let style = self.inline_styles.last().copied().unwrap_or_default();
Expand Down Expand Up @@ -521,6 +521,24 @@ mod tests {
);
}

fn line_texts(lines: &[Line]) -> Vec<String> {
lines
.iter()
.map(|l| l.spans.iter().map(|s| s.content.as_ref()).collect())
.collect()
}

#[rstest]
#[case::one_line("```\nonly\n```\n", &["```", "only", "```"])]
#[case::two_lines("```\nhello\nworld\n```\n", &["```", "hello", "world", "```"])]
#[case::blank_middle_line("```\na\n\nb\n```\n", &["```", "a", "", "b", "```"])]
fn fence_text_renders_one_line_per_source_line(
#[case] markdown: &str,
#[case] expected: &[&str],
) {
assert_eq!(line_texts(&from_str(markdown).lines), expected);
}

#[test]
fn unlanguaged_fence_delimiters_are_unstyled() {
let styles = fence_styles(&from_str("```\nhello\n```\n").lines);
Expand Down
Loading