| 1 | -- Session titles that settle (src/coordination/titles.rs). A session's |
| 2 | -- title says where it came from (`title_source`): `prompt` (provisional, |
| 3 | -- the first prompt's intent), `agent` (its harness or agent said so), |
| 4 | -- `person` (pinned from the site, never replaced), `item` or `pull` (the |
| 5 | -- work item's or pull request's title) or `summary` (g1t named the whole |
| 6 | -- of the work, with the workspace's AI provider or without one). |
| 7 | -- |
| 8 | -- g1t settles a title when one is due (`title_due_at`, read by the cron): |
| 9 | -- once the session has enough to go on, again only when what it works on |
| 10 | -- changes (at most every 20 minutes), and a last time when it ends |
| 11 | -- (`title_final`). `title_basis` is what it was settled from (its work |
| 12 | -- items and pull requests), `title_prompts` how many prompts it had then, |
| 13 | -- `title_calls` how many times the AI provider was asked (a handful at |
| 14 | -- most), and `prompts` how many prompts it recorded. |
| 15 | ALTER TABLE sessions ADD COLUMN title_source TEXT; |
| 16 | ALTER TABLE sessions ADD COLUMN title_settled_at TEXT; |
| 17 | ALTER TABLE sessions ADD COLUMN title_due_at TEXT; |
| 18 | ALTER TABLE sessions ADD COLUMN title_final INTEGER NOT NULL DEFAULT 0; |
| 19 | ALTER TABLE sessions ADD COLUMN title_basis TEXT; |
| 20 | ALTER TABLE sessions ADD COLUMN title_prompts INTEGER NOT NULL DEFAULT 0; |
| 21 | ALTER TABLE sessions ADD COLUMN title_calls INTEGER NOT NULL DEFAULT 0; |
| 22 | ALTER TABLE sessions ADD COLUMN prompts INTEGER NOT NULL DEFAULT 0; |
| 23 | |
| 24 | UPDATE sessions SET prompts = ( |
| 25 | SELECT COUNT(*) FROM session_entries e WHERE e.session_id = sessions.id AND e.kind = 'prompt' |
| 26 | ); |
| 27 | |
| 28 | -- Every session started before this is settled once (the backfill): a |
| 29 | -- subagent keeps its task, so only sessions at the top of a tree. |
| 30 | UPDATE sessions SET title_due_at = COALESCE(ended_at, last_seen_at) WHERE parent_id IS NULL; |
| 31 | |
| 32 | CREATE INDEX sessions_title_due ON sessions (title_due_at) WHERE title_due_at IS NOT NULL; |