Repository navigation
refactor(program): use shared ownership and graceful signal shutdown - #29
Merged
Merged
Conversation
- [x] use `std::shared_ptr` for `UserInterface`, `ProgressSpinner`, and component ownership;
- [x] store the `UserInterface` singleton as `std::weak_ptr`, add `create()` factory overloads;
- [x] create `UserInterface` through `create()` and allocate components with `std::make_shared`;
- [x] initialize `OllamaClient` and its members through constructor initializer lists;
- [x] accept shared pointers in `CurlUtils`, `EmbeddingUtils`, `RetrievingUtils`, `SystemUtils`;
- [x] replace the `SIGINT` handler's direct exit with a graceful interrupt flag;
- [x] make resize and interrupt flags static `volatile sig_atomic_t` members;
- [x] add a `terminal_restored` flag and guard terminal cleanup against repeated calls;
- [x] prevent self-join in `stop_render_thread`;
- [x] add static `ui_running()` helper and use it for UI state checks in all components;
- [x] add a default exit code to `end_session()` and rename its parameter;
- [x] replace `exit()` calls with `std::exit(EXIT_SUCCESS)` or `std::exit(EXIT_FAILURE)`;
- [x] return `EXIT_SUCCESS` from `main` and end UI sessions with `EXIT_FAILURE` on fatal errors;
- [x] hold CURL easy handles and header lists in `unique_ptr` with custom deleters;
- [x] add `CurlUtils::add_header()` to append headers to a `curl_slist` safely;
- [x] use `reset()` on owned CURL pointers in place of manual cleanup calls;
- [x] initialize `WebContent::error_buffer` with `{}` so it starts zeroed;
- [x] remove DEBUG-only theme logging from `init_ncurses()`;
- [x] add doc comments for client, `CurlUtils`, `EmbeddingUtils`, and `RetrievingUtils` methods;
- [x] document `fetch_web_content_stream()` and fix the `@throws` note in `fetch_web_content()`;
- [x] remove the `is_running()` note from `catch_error()` documentation;
rfprod
enabled auto-merge (squash)
November 7, 2026 18:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
std::shared_ptrforUserInterface,ProgressSpinner, and component ownership;UserInterfacesingleton asstd::weak_ptr, addcreate()factory overloads;UserInterfacethroughcreate()and allocate components withstd::make_shared;OllamaClientand its members through constructor initializer lists;CurlUtils,EmbeddingUtils,RetrievingUtils,SystemUtils;SIGINThandler's direct exit with a graceful interrupt flag;volatile sig_atomic_tmembers;terminal_restoredflag and guard terminal cleanup against repeated calls;stop_render_thread;ui_running()helper and use it for UI state checks in all components;end_session()and rename its parameter;exit()calls withstd::exit(EXIT_SUCCESS)orstd::exit(EXIT_FAILURE);EXIT_SUCCESSfrommainand end UI sessions withEXIT_FAILUREon fatal errors;unique_ptrwith custom deleters;CurlUtils::add_header()to append headers to acurl_slistsafely;reset()on owned CURL pointers in place of manual cleanup calls;WebContent::error_bufferwith{}so it starts zeroed;init_ncurses();CurlUtils,EmbeddingUtils, andRetrievingUtilsmethods;fetch_web_content_stream()and fix the@throwsnote infetch_web_content();is_running()note fromcatch_error()documentation;