Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

An agent saying its session's title again leaves it settled when it was

Each heartbeat that gave the same title moved title_settled_at on, so the title was never old enough to be named again.

G1T-Session:
ses_01m56vxcstesp8b57jt5edge6y
syntaqxcommitted Parent7dcb910Browse files
2 files+24−30/2 viewed
+17−0
745745 }
746746
747747 #[test]
748+fn an_agent_saying_its_title_again_leaves_when_it_settled() {
749+ let db = database();
750+ start(&db, "ses_1", Some("a"));
751+ heartbeat_titled(&db, "ses_1", "Rewrite the auth flow", "agent", NOW + MINUTE);
752+ let settled = |db: &Connection| -> Option<String> {
753+ db.query_row("SELECT title_settled_at FROM sessions WHERE id = 'ses_1'", [], |row| row.get(0)).unwrap()
754+ };
755+ assert_eq!(settled(&db), Some(rfc3339(NOW + MINUTE)));
756+ // Every heartbeat says it again: it settled when first given.
757+ heartbeat_titled(&db, "ses_1", "Rewrite the auth flow", "agent", NOW + 30 * MINUTE);
758+ assert_eq!(settled(&db), Some(rfc3339(NOW + MINUTE)));
759+ // A new title settles anew.
760+ heartbeat_titled(&db, "ses_1", "Rewrite auth and sessions", "agent", NOW + 40 * MINUTE);
761+ assert_eq!(settled(&db), Some(rfc3339(NOW + 40 * MINUTE)));
762+}
763+
764+#[test]
748765 fn an_agent_echoing_the_provisional_title_keeps_it_provisional() {
749766 let db = database();
750767 start(&db, "ses_1", Some("a"));
+7−3
135135 }
136136
137137 /// A title its agent gives (`?5` of the heartbeat): pinned ones keep
138−/// theirs. `?13` is where it came from ([`given_source`]), `?11` now.
138+/// theirs. `?13` is where it came from ([`given_source`]), `?11` now. An
139+/// agent saying again the title it gave changes nothing: it settled when
140+/// first given, and is as stale as it was.
139141 pub(crate) const SET_TITLE: &str = "title = CASE WHEN ?5 IS NULL OR title_source = 'person' THEN title ELSE ?5 END,
140− title_due_at = CASE WHEN ?5 IS NULL OR title_source = 'person' OR ?13 <> 'agent' THEN title_due_at ELSE NULL END,
141− title_settled_at = CASE WHEN ?5 IS NULL OR title_source = 'person' OR ?13 <> 'agent' THEN title_settled_at ELSE ?11 END,
142+ title_due_at = CASE WHEN ?5 IS NULL OR title_source = 'person' OR ?13 <> 'agent'
143+ OR (title_source = 'agent' AND lower(title) = lower(?5)) THEN title_due_at ELSE NULL END,
144+ title_settled_at = CASE WHEN ?5 IS NULL OR title_source = 'person' OR ?13 <> 'agent'
145+ OR (title_source = 'agent' AND lower(title) = lower(?5)) THEN title_settled_at ELSE ?11 END,
142146 title_source = CASE WHEN ?5 IS NULL OR title_source = 'person' THEN title_source ELSE ?13 END";
143147
144148 /// A person names session `?3` `?1` at `?2`: pinned.

Comments

Sign in to comment.