Editable stage history, auto-ghosting, and an Add-form fix

Stage history editor:
- The edit form's Pipeline section is now the application's history:
  one row per step (stage + date), Add Step and Remove Step, kept in
  date order. The last step is the current stage and the first step's
  date the date applied, replacing the separate Stage and Date Applied
  fields. An application logged after the fact (applied, interviewed,
  rejected) keeps its whole path.
- JobsDatabase::replaceStageHistory() rewrites a job's history in one
  transaction (sorted, repeats collapsed, stage and date applied kept in
  step); StageHistoryModel backs the section; JobsModel::addJob() now
  returns the new id so a new application's history can be saved.
- `kareer history <id> [Stage=YYYY-MM-DD ...]` shows or replaces it.

Auto-ghosting:
- Applications still at Applied with no activity (the later of the
  date applied and the last stage change) for more than 30 days move to
  Ghosted, recorded like any stage change. Runs at startup for GUI and
  CLI, after switching databases, and shortly after the setting changes.
- Preferences gains an Applications section: on/off and the number of
  days (kareerrc [AutoGhost]). The GUI shows a passive notification; the
  CLI notes it on stderr so --json output stays clean.

Fixes:
- The Add Application form pre-filled empty text fields with the word
  "undefined" (typing "a" gave "undefineda"): fields with no value
  reached QML as undefined. Every field now gets a typed default.
- Embed the app icon as the window icon fallback, so the window and
  About page show it when running uninstalled.

Tests: history replacement and the after-the-fact Allstate case, the
ghosting rules (fresh/stale/logged-late/reopened/threshold), and empty
new-form fields.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxDf7HqD1xPnsZP8wt3NTk
This commit is contained in:
2026-09-11 17:00:45 -05:00
co-authored by Claude Opus 5
parent 289246a6d0
commit eb47a589cb
24 changed files with 1106 additions and 32 deletions
+66 -1
View File
@@ -43,6 +43,12 @@ private Q_SLOTS:
QCOMPARE(valueOf(edit, u"company"_s).toString(), u"Acme Corp"_s);
QCOMPARE(valueOf(edit, u"title"_s).toString(), u"Engineer"_s);
QCOMPARE(valueOf(edit, u"salaryMin"_s).toInt(), 100000);
// The history's first step shows the date applied, not when it was logged.
StageHistoryModel *history = edit.history();
QCOMPARE(history->rowCount(), 1);
QCOMPARE(history->data(history->index(0), StageHistoryModel::StageRole).toString(), u"Applied"_s);
QCOMPARE(history->data(history->index(0), StageHistoryModel::DateRole).toDate(), QDate(2026, 6, 1));
}
void savesEditsToExistingJob()
@@ -79,17 +85,55 @@ private Q_SLOTS:
edit.setEditingJobId(id);
edit.setJobsModel(&jobs);
setValueOf(edit, u"stage"_s, u"Interview"_s);
// Moving the application on is adding a step to its history.
StageHistoryModel *history = edit.history();
history->appendStep();
history->setStage(history->rowCount() - 1, u"Interview"_s);
QVERIFY2(edit.save(), qPrintable(edit.lastError()));
JobsDatabase db;
QCOMPARE(db.jobById(id)->stage, u"Interview"_s);
QCOMPARE(db.jobById(id)->dateApplied, QDate(2026, 6, 1));
const auto transitions = db.stageTransitions();
QCOMPARE(transitions.size(), 2);
QCOMPARE(transitions.last().fromStage, u"Applied"_s);
QCOMPARE(transitions.last().toStage, u"Interview"_s);
}
// Applied, interviewed, then rejected: logged in one go after the fact.
void logsApplicationAfterTheFact()
{
JobsModel jobs;
JobEditModel edit;
edit.setJobsModel(&jobs);
setValueOf(edit, u"company"_s, u"Allstate"_s);
setValueOf(edit, u"title"_s, u"Software Engineer"_s);
StageHistoryModel *history = edit.history();
const auto day = [](int month, int dayOfMonth) {
return QDateTime(QDate(2026, month, dayOfMonth), QTime(9, 0));
};
history->setDate(0, day(8, 1));
history->appendStep();
history->setStage(1, u"Interview"_s);
history->setDate(1, day(8, 15));
history->appendStep();
history->setStage(2, u"Rejected"_s);
history->setDate(2, day(8, 20));
QVERIFY2(edit.save(), qPrintable(edit.lastError()));
JobsDatabase db;
const QList<Job> all = db.allJobs();
QCOMPARE(all.size(), 1);
QCOMPARE(all.first().stage, u"Rejected"_s);
QCOMPARE(all.first().dateApplied, QDate(2026, 8, 1));
const QList<StageStep> steps = db.stageHistory(all.first().id);
QCOMPARE(steps.size(), 3);
QCOMPARE(steps.at(1).stage, u"Interview"_s);
QCOMPARE(steps.at(1).at.toLocalTime().date(), QDate(2026, 8, 15));
QCOMPARE(steps.at(2).at.toLocalTime().date(), QDate(2026, 8, 20));
}
void addsNewJob()
{
JobsModel jobs;
@@ -108,6 +152,27 @@ private Q_SLOTS:
QCOMPARE(all.first().stage, u"Applied"_s);
}
// A new form's text fields must start empty; a missing value showed up
// in QML as the word "undefined".
void newFormFieldsStartEmpty()
{
JobsModel jobs;
JobEditModel edit;
edit.setJobsModel(&jobs);
for (int row = 0; row < edit.rowCount(); ++row) {
const QVariant value = edit.data(edit.index(row), JobEditModel::ValueRole);
const QString id = edit.data(edit.index(row), JobEditModel::FieldIdRole).toString();
QVERIFY2(value.isValid(), qPrintable(id));
}
for (const QString &id : {u"company"_s, u"title"_s, u"location"_s, u"source"_s, u"url"_s, u"contact"_s, u"notes"_s}) {
const QVariant value = valueOf(edit, id);
QCOMPARE(value.typeId(), QMetaType::QString);
QVERIFY2(value.toString().isEmpty(), qPrintable(id));
}
QCOMPARE(valueOf(edit, u"currency"_s).toString(), u"USD"_s);
QCOMPARE(valueOf(edit, u"remoteType"_s).toString(), u"Unspecified"_s);
}
void missingCompanyIsReported()
{
JobsModel jobs;