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

A workspace's sessions for a work item keep those linked to it

Filtered by a work item, the sessions table's query already takes those on it and those linked to it (a claim, a trailer, #N), but the filter for the other kinds then dropped every row not on it itself.

G1T-Session:
ses_01m56vxcstesp8b57jt5edge6y
syntaqxcommitted Parentfcfc901Browse files
1 file+22−20/1 viewed
+22−2
194194
195195 impl Wanted<'_> {
196196 fn admits(&self, session: &WorkspaceSession) -> bool {
197+ self.admits_listed(session) && self.item.is_none_or(|item| session.item == Some(item))
198+ }
199+
200+ /// For a row of the `sessions` table, which its query already chose by
201+ /// work item, the session's own or one it is linked to
202+ /// ([`workspace_sessions_sql`]): all but that.
203+ fn admits_listed(&self, session: &WorkspaceSession) -> bool {
197204 self.shown.admits(session.state)
198205 && self.kind.is_none_or(|kind| kind == session.kind)
199206 && self.harness.is_none_or(|harness| session.harness == Some(harness))
200207 && self.person.is_none_or(|person| session.actor.as_deref().is_some_and(|actor| actor.eq_ignore_ascii_case(person)))
201− && self.item.is_none_or(|item| session.item == Some(item))
202208 }
203209 }
204210
215221 ) -> Vec<WorkspaceSession> {
216222 let covered: HashSet<(String, u32)> =
217223 sessions.iter().chain(&runs).filter_map(|session| session.pull.map(|pull| (session.repo_id.clone(), pull))).collect();
218− let mut all: Vec<WorkspaceSession> = sessions.into_iter().filter(|session| wanted.admits(session)).collect();
224+ let mut all: Vec<WorkspaceSession> = sessions.into_iter().filter(|session| wanted.admits_listed(session)).collect();
219225 all.extend(runs.into_iter().filter(|run| wanted.admits(run)));
220226 all.extend(
221227 recorded
711717 }
712718
713719 #[test]
720+ fn a_session_linked_to_a_work_item_is_listed_for_it() {
721+ // On no work item of its own, but linked to #12 (a claim, a trailer).
722+ let session: Session = serde_json::from_value(serde_json::json!({
723+ "id": "ses_l", "repoId": "rep_api", "item": null, "pull": null, "branch": null, "actor": { "id": "usr_2", "username": "bo" },
724+ "harness": "codex", "harnessSessionId": null, "title": null, "state": "active", "headCommit": null,
725+ "startedAt": at(5), "lastSeenAt": at(1), "endedAt": null, "endReason": null, "subagents": 0
726+ }))
727+ .unwrap();
728+ let listed = from_session(session, "acme/api", NOW);
729+ let for_item = Wanted { shown: SessionsShown::Recent, kind: None, harness: None, person: None, item: Some(12) };
730+ assert_eq!(merged(vec![listed], Vec::new(), Vec::new(), &for_item, 10).len(), 1);
731+ }
732+
733+ #[test]
714734 fn pull_facts_and_busy_queues_are_read_across_repositories() {
715735 let db = seeded();
716736 let pairs = serde_json::json!([{ "r": "rep_web", "n": 9 }, { "r": "rep_api", "n": 7 }, { "r": "rep_api", "n": 99 }]).to_string();

Comments

Sign in to comment.