Skip to content

feat(interface): add ncurses terminal backend, refactor user_interface - #31

Merged
rfprod merged 1 commit into
mainfrom
refactor-ui
Nov 10, 2026
Merged

rfprod merged 1 commit into
mainfrom
refactor-ui

Conversation

@rfprod

@rfprod rfprod commented Nov 10, 2026

Copy link
Copy Markdown
Owner
  • add TerminalBackend class with ncurses init, dark and light themes, and render loop;
  • handle SIGWINCH resize and SIGINT interrupts via atomic flags;
  • route print, spinner, progress, input buffer, and redraw calls through the backend;
  • move Layout struct and message type constants (normal, error, success) into the backend;
  • hold a unique_ptr to TerminalBackend in UserInterface, remove ncurses state;
  • replace ui_running() with backend_running() across all components;
  • use a 100 ms getch timeout in next_prompt so it can detect backend shutdown;
  • replace std::exit with end_session and ExitRequest;
  • add ExitRequest with an exit code, reason, and noexcept code() and what() accessors;
  • add utils/exit_request.hpp so argument handlers can throw ExitRequest;
  • wrap session logic in main in a try block that catches ExitRequest and returns its code;
  • route fatal Qdrant, Ollama, CURL, and system errors through end_session(EXIT_FAILURE);
  • remove std::exit from check_ollama, process_response, and query_model_list;
  • keep HttpException for non-fatal HTTP errors when fail_on_http_error is false;
  • add #pragma once to http_utils to prevent duplicate definitions;
  • replace EXPECT_EXIT death tests with direct calls that check the end_session code;
  • update the UserInterface mock to implement backend_running() instead of ui_running();

- [x] add `TerminalBackend` class with ncurses init, dark and light themes, and render loop;
- [x] handle `SIGWINCH` resize and `SIGINT` interrupts via `atomic` flags;
- [x] route print, spinner, progress, input buffer, and redraw calls through the backend;
- [x] move `Layout` struct and message type constants (normal, error, success) into the backend;
- [x] hold a `unique_ptr` to `TerminalBackend` in `UserInterface`, remove ncurses state;
- [x] replace `ui_running()` with `backend_running()` across all components;
- [x] use a 100 ms `getch` timeout in `next_prompt` so it can detect backend shutdown;
- [x] replace `std::exit` with `end_session` and `ExitRequest`;
- [x] add `ExitRequest` with an exit code, reason, and noexcept `code()` and `what()` accessors;
- [x] add `utils/exit_request.hpp` so argument handlers can throw `ExitRequest`;
- [x] wrap session logic in `main` in a try block that catches `ExitRequest` and returns its code;
- [x] route fatal Qdrant, Ollama, CURL, and system errors through `end_session(EXIT_FAILURE)`;
- [x] remove `std::exit` from `check_ollama`, `process_response`, and `query_model_list`;
- [x] keep `HttpException` for non-fatal HTTP errors when `fail_on_http_error` is false;
- [x] add `#pragma once` to `http_utils` to prevent duplicate definitions;
- [x] replace `EXPECT_EXIT` death tests with direct calls that check the `end_session` code;
- [x] update the `UserInterface` mock to implement `backend_running()` instead of `ui_running()`;
@rfprod rfprod self-assigned this Nov 10, 2026
@rfprod rfprod added Enhancement Existing functionality improvement related changes. Refactor Refactoring related changes. Program Main program logic related changes. Specs: Unit Unit specs related changes. labels Nov 10, 2026
@rfprod
rfprod enabled auto-merge (squash) November 10, 2026 19:53
@rfprod
rfprod merged commit e631974 into main Nov 10, 2026
3 checks passed
@rfprod
rfprod deleted the refactor-ui branch November 10, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Existing functionality improvement related changes. Program Main program logic related changes. Refactor Refactoring related changes. Specs: Unit Unit specs related changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant