Status system reworked

This commit is contained in:
alejo committed 2026-10-29 01:02:06 -03:00
1 parent 33567db5a3
commit a29ba6e4d2
18 files changed
+326 -345

No files matched your search

+18 -10
View File
@@ -22,10 +22,15 @@ private:
ErrorCode code_;
};
// All the rules for changing accounts and tasks (waits, auto-unwait, status
// handling...). The prompt and the C API are both thin layers over this class.
// Each change appends human-readable notes (what the prompt prints), which
// takeMessages() hands over.
// All the rules for changing accounts and tasks. The prompt and the C API are
// both thin layers over this class. Each change appends human-readable notes
// (what the prompt prints), which takeMessages() hands over.
//
// How waits work: an account hits its limit until a time ("acc wait"). A task set
// to Wait is waiting for that: it shows Wait until then, and when the time passes
// the account stops waiting by itself and the task shows Limit reset (the
// conversation can be continued). Prompt / Testing tasks are not waiting: they
// show as they are, with "(account-waiting)" appended while the account waits.
class Tracker {
public:
explicit Tracker(Database& db);
@@ -43,16 +48,19 @@ public:
void deleteAccount(const std::string& name);
void renameAccount(const std::string& name, const std::string& newName);
// The account hits its limit until `until` (or a clock time such as "16:30",
// "4:30pm"; a time that has passed today means tomorrow).
// The account hit its limit until `until` (or a clock time such as "16:30",
// "4:30pm"; a time that has passed today means tomorrow). Tasks set to Wait
// follow the new time.
void setAccountWait(const std::string& name, std::time_t until);
void setAccountWaitText(const std::string& name, const std::string& timeText);
// Returns false if the account was not waiting.
// Ends the wait now: its Wait tasks become Limit reset. Returns false if the
// account was not waiting.
bool clearAccountWait(const std::string& name);
// ---- Tasks --------------------------------------------------------------
// `statusText` is what the user would type: "testing", "wait 4pm", "wait"...
// nullopt = Prompt, without the auto-unwait that an explicit status triggers.
// nullopt = Prompt. "wait <time>" sets the account's wait too; "wait" alone
// joins the account's running wait (and is an error if it is not waiting).
void addTask(const std::string& name, const std::optional<std::string>& account,
const std::optional<std::string>& statusText);
void deleteTask(const std::string& name);
@@ -72,8 +80,8 @@ private:
std::string existingAccount(const std::string& name) const;
TaskRow existingTask(const std::string& name) const;
std::optional<std::time_t> runningWait(const std::string& account) const;
void taskInUse(const std::string& taskName, const std::string& accountName);
void makeTaskFollowAccount(const TaskRow& task);
void settle();
int endAccountWait(const std::string& account, std::time_t endedAt);
void note(const std::string& message);
Database& db_;