### TODO:
- scrolling chat history; (somewhat works out of the box); +
- log errors to file; +
- give serial id to each msg in chat to track it; (use slice index) +
- show msg id next to the msg; +
- regen last message; +
- delete last message; +
- edit message? (including from bot); +
- ability to copy message; +
- menu with old chats (chat files); +
- tab to switch selection between textview and textarea (input and chat); +
- basic tools: memorize and recall;
- stop stream from the bot; +
- sqlitedb instead of chatfiles; +
- define tools and sys prompt for them to be used; +
- add system prompt without tools (for mistral); +
- option to switch between predefined sys prompts; +
- sqlite for the bot memory; +
- rename current chat; +
- help page with all key bindings; +
- default config file (api url, path to sysprompts, path to log, limits, etc); +
- ctrl+n to start new chat; +
- export whole chat into a json file; +
- directory with sys prompts (charcards png & json); +
- colourschemes, colours or markdown of quotes and styles; (partially done) +
- change temp, min-p and other params from tui;
- fullscreen textarea option (bothersome to implement);
- consider adding use /completion of llamacpp, since openai endpoint clearly has template|format issues;
- separate messages that are stored and chat and send to the bot, i.e. option to omit tool calls (there might be a point where they are no longer needed in ctx);
- RAG support|implementation;
- char card is the sys message, but how about giving tools to char that does not have it?
- it is a bit clumsy to mix chats in db and chars from the external files, maybe load external files in db on startup?
- lets say we have two (or more) agents with the same name across multiple chats. These agents go and ask db for topics they memorised. Now they can access topics that aren't meant for them. (so memory should have an option: shareable; that indicates if that memory can be shared across chats);
- delete chat option;
- server mode: no tui but api calls with the func calling, rag, other middleware;

### FIX:
- bot responding (or hanging) blocks everything; +
- program requires history folder, but it is .gitignore; +
- at first run chat table does not exist; run migrations sql on startup; +
- Tab is needed to copy paste text into textarea box, use shift+tab to switch focus; (changed tp pgup) +
- sometimes bots put additional info around the tool call, have a regexp to match tool call; +
- remove all panics from code; +
- new chat replaces old ones in db; +
- empty input to continue bot msg gens new msg index and bot icon; +
- if option to show sys msg enabled: it show display new tool responses; +
- delete last msg: can have unexpected behavior (deletes what appears to be two messages if last bot msg was not generated (should only delete icon in that case)); +
- when bot generation ended with err: need a way to switch back to the bot_resp_false mode; +
- no selection focus on modal sys buttons after opening it a second time; (cannot reproduce) +
- chat should contain char in it (one to many: char: []chats); +
- all page names should be vars; +
- normal case regen omits assistant icon; +
- user icon (and role?) from config is not used; +
- message editing broke ( runtime error: index out of range [-1]); +
- F1 can load any chat, by loading chat of other agent it does not switch agents, if that chat is continued, it will rewrite agent in db; (either allow only chats from current agent OR switch agent on chat loading);
- after chat is deleted: load undeleted chat;
