Skip to content

feat(tui): add /btw side question command - #48

Merged
Blankeos merged 1 commit into
mainfrom
feat/btw-command
Sep 3, 2026
Merged

feat(tui): add /btw side question command#48
Blankeos merged 1 commit into
mainfrom
feat/btw-command

Conversation

@Blankeos

@Blankeos Blankeos commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Adds a /btw <question> command that answers side questions via a lightweight no-tools LLM call, without touching the main chat turn or session persistence.

  • Works on both home and chat, even while the agent is streaming
  • Q&A rendered in a dismissible overlay panel (Esc) with mouse-wheel scrolling and clamping
  • One in-flight /btw at a time; late replies after dismissal are dropped
  • Includes session history snapshot for context, with tests for session tracking, scroll behavior, and home usage

lmao demo https://x.com/carlo_taleon/status/2095621430067228848?s=20

Adds a `/btw <question>` command that answers side questions via a lightweight no-tools LLM call, without touching the main chat turn or session persistence.

- Works on both home and chat, even while the agent is streaming
- Q&A rendered in a dismissible overlay panel (Esc) with mouse-wheel scrolling and clamping
- One in-flight `/btw` at a time; late replies after dismissal are dropped
- Includes session history snapshot for context, with tests for session tracking, scroll behavior, and home usage
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying crabcode with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7619719
Status: ✅  Deploy successful!
Preview URL: https://83a2a656.crabcode.pages.dev
Branch Preview URL: https://feat-btw-command.crabcode.pages.dev

View logs

@Blankeos

Blankeos commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

PR Review: #48 — feat(tui): add /btw side question command

Branch: feat/btw-commandmain
Commit: 7619719 (single commit, +996/−23 across 6 files)
Merge confidence: 4/5

Body (GitHub-ready)

Adds a /btw <question> command that asks a lightweight, no-tools side question without interrupting the main agent turn. Works on the home screen (no session) and in chat, including while streaming. The Q&A renders in a scrollable side panel above the input (markdown-rendered, capped at 10 visible lines with mouse-wheel scroll) and is deliberately kept out of chat_state.chat.messages and session persistence so it never leaks into the main turn context. Context is built with the usual harness optimizations: compaction-boundary slicing, incomplete-message filtering, and an 8k-token newest-first budget. Includes 12 new unit tests covering panel state, scroll clamping, context selection, and registration.

What it does

  • src/command/handlers.rs — registers btw (non-chat-only); the handler is a stub that defers to the app layer, which needs provider/model access.
  • src/app.rsBtwEntry state, single-flight guard (btw_receiver), Esc dismissal, mouse-wheel hit-testing/scroll, event pump via unbounded mpsc, panel area tracking.
  • src/llm/client.rsgenerate_btw_answer(): no tools, side-channel request, reuses stream_provider_request; handles StreamRollback chunk trimming.
  • src/views/chat.rs / src/views/home.rs — side panel rendering, height computation shared between render and scroll clamp, layout re-indexing for home chunks.
  • Incidental: renames/reformats the queued-messages header hint ("esc again to steer" instead of "esc interrupt and send immediately"). Unrelated to /btw — worth splitting out or calling out in the PR description.

Regressions?

None found. Full cargo test shows 18 failing tests on this branch, but the same failures (19) reproduce on main — they're pre-existing/environment-related (sessions, subagents, ollama cache, state-dir tests), not caused by this PR. All 12 new /btw tests pass, cargo fmt --check is clean, and clippy shows no new warnings attributable to the diff.

One behavioral note (not a regression): dismissing the panel via Esc also nulls the in-flight receiver, so a second /btw can start while the first is still generating — the late reply is intentionally dropped. Also, if the user switches sessions while a /btw is in flight, the reply will fill the entry for the original session and won't be visible until they switch back — reasonable, but the single-flight toast says "already answering" globally.

Migrations needed?

No. Pure in-memory UI state; nothing touches data.db, auth.json, or any persisted schema.

Pre-merge checklist

  • cargo fmt --check — clean
  • cargo clippy --all-targets — no new warnings from this diff
  • All 12 new /btw tests pass
  • Full test suite — failures identical to main (pre-existing, env-related)
  • Manual smoke test: /btw while main agent is streaming (no interference with the main turn)
  • Manual smoke test: /btw on home screen, then start a session — panel dismisses correctly on context switch
  • Manual smoke test: /btw on a small terminal (panel height < 10 lines) — scroll clamp reaches the last line
  • Confirm the queued-messages hint copy change ("esc again to steer") is intentional / wanted in this PR
  • _plans/__TODOS.md checkbox flip + new TODO note is fine to ship, or strip it

Confidence bumps

Each item below raises the score. Current: 4/5.

  • +0 → stays 4/5: Manual smoke tests of streaming-interference and small-terminal scrolling (the three boxes above). Doing these on a real terminal would firm up the rendering/interaction paths that unit tests only partially cover.
  • 4.5/5 if the queued-messages hint rewording is split into its own PR (or confirmed as intentional) — the diff stays purely about /btw.
  • 5/5 if additionally a late-reply race is covered by a test: dismiss the panel while the task is in flight, verify the late Answered event is dropped and doesn't resurrect state (the code handles it, but it's untested).

@Blankeos
Blankeos merged commit c831702 into main Sep 3, 2026
7 checks passed
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.

1 participant