@tutti-os/agent-gui 0.0.105 → 0.0.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -91,6 +91,9 @@ function agentMentionEmptyGroupLabel(groupId, query) {
91
91
  if (groupId === "collab_sessions") {
92
92
  return translate("agentHost.agentGui.mentionEmptyCollabSessions");
93
93
  }
94
+ if (groupId.startsWith("agent:")) {
95
+ return translate("agentHost.agentGui.mentionEmptyMySessions");
96
+ }
94
97
  return translate("agentHost.agentGui.mentionEmptyIssues");
95
98
  }
96
99
 
@@ -468,7 +471,18 @@ function resolveMentionGroupItems(groupId, rawGroups) {
468
471
  if (groupId === "files") {
469
472
  return [...rawGroups.opened_files, ...rawGroups.agent_generated_files];
470
473
  }
471
- return rawGroups[groupId] ?? [];
474
+ if (groupId === "my_sessions" || groupId === "collab_sessions") {
475
+ return rawGroups.sessions.filter(
476
+ (item) => item.kind === "session" && item.scope === groupId
477
+ );
478
+ }
479
+ if (groupId.startsWith("agent:")) {
480
+ return [];
481
+ }
482
+ if (groupId === "apps" || groupId === "agents" || groupId === "opened_files" || groupId === "agent_generated_files" || groupId === "issues") {
483
+ return rawGroups[groupId];
484
+ }
485
+ return [];
472
486
  }
473
487
  function resolveMentionGroupTotalCount(groupId, totalCounts, itemCount) {
474
488
  if (groupId.startsWith("issue-topic:")) {
@@ -632,6 +646,10 @@ function buildAgentMentionGroups(input) {
632
646
  expandStatus: group.loadMoreStatus
633
647
  }));
634
648
  }
649
+ const provenanceGroups = buildSessionProvenanceGroups(input);
650
+ if (provenanceGroups) {
651
+ return provenanceGroups;
652
+ }
635
653
  const orderedGroupIds = groupIdsForFilter(input.currentFilter);
636
654
  return orderedGroupIds.map((groupId) => {
637
655
  const rawItems = resolveMentionGroupItems(groupId, input.rawGroups);
@@ -693,14 +711,93 @@ function issueTopicPaginationChanges(groupsAtStart, currentGroups) {
693
711
  return [{ ...group, items: appendedItems }];
694
712
  });
695
713
  }
714
+ function buildSessionProvenanceGroups(input) {
715
+ if (input.currentFilter !== "session" || !input.provenanceCatalog?.enabledDimensions.includes("agent")) {
716
+ return null;
717
+ }
718
+ const selectedAgentTargetIds = input.provenanceFilter?.agentTargetIds ?? null;
719
+ const selectedAgentTargetIdSet = selectedAgentTargetIds === null ? null : new Set(selectedAgentTargetIds);
720
+ const sessionItems = input.rawGroups.sessions.filter(
721
+ (item) => item.kind === "session" && (selectedAgentTargetIdSet === null || (item.agentTargetId ? selectedAgentTargetIdSet.has(item.agentTargetId) : false))
722
+ );
723
+ const catalogAgentTargetIds = new Set(
724
+ input.provenanceCatalog.agentOptions.map((option) => option.id)
725
+ );
726
+ const catalogGroups = input.provenanceCatalog.agentOptions.flatMap(
727
+ (option) => {
728
+ const items = sessionItems.filter(
729
+ (item) => item.kind === "session" && item.agentTargetId === option.id
730
+ );
731
+ if (items.length === 0) {
732
+ return [];
733
+ }
734
+ const groupId = agentProvenanceMentionGroupId(option.id);
735
+ const pageSize = mentionGroupPageSize(input.currentFilter, groupId);
736
+ const visibleCount = Math.min(
737
+ items.length,
738
+ input.expandedCounts[groupId] ?? pageSize
739
+ );
740
+ return [
741
+ {
742
+ id: groupId,
743
+ label: option.label,
744
+ items: items.slice(0, visibleCount),
745
+ totalCount: items.length,
746
+ visibleCount,
747
+ hasMore: items.length > visibleCount
748
+ }
749
+ ];
750
+ }
751
+ );
752
+ if (selectedAgentTargetIdSet !== null) {
753
+ return catalogGroups;
754
+ }
755
+ const unmatchedGroups = /* @__PURE__ */ new Map();
756
+ for (const item of sessionItems) {
757
+ if (item.kind !== "session" || item.agentTargetId && catalogAgentTargetIds.has(item.agentTargetId)) {
758
+ continue;
759
+ }
760
+ const identity = item.agentTargetId?.trim() || item.agentName.trim() || item.initiatorName.trim() || item.targetId;
761
+ const key = `uncatalogued:${identity}`;
762
+ const existing = unmatchedGroups.get(key);
763
+ if (existing) {
764
+ existing.items.push(item);
765
+ continue;
766
+ }
767
+ unmatchedGroups.set(key, {
768
+ id: agentProvenanceMentionGroupId(key),
769
+ label: item.agentName.trim() || item.initiatorName.trim() || item.agentTargetId?.trim() || item.title,
770
+ items: [item]
771
+ });
772
+ }
773
+ return [
774
+ ...catalogGroups,
775
+ ...[...unmatchedGroups.values()].map((group) => {
776
+ const pageSize = mentionGroupPageSize(input.currentFilter, group.id);
777
+ const visibleCount = Math.min(
778
+ group.items.length,
779
+ input.expandedCounts[group.id] ?? pageSize
780
+ );
781
+ return {
782
+ ...group,
783
+ items: group.items.slice(0, visibleCount),
784
+ totalCount: group.items.length,
785
+ visibleCount,
786
+ hasMore: group.items.length > visibleCount
787
+ };
788
+ })
789
+ ];
790
+ }
791
+ function agentProvenanceMentionGroupId(agentTargetId) {
792
+ return `agent:${encodeURIComponent(agentTargetId)}`;
793
+ }
696
794
  function emptyAgentMentionRawGroups() {
697
795
  return {
698
796
  apps: [],
699
797
  agents: [],
700
798
  opened_files: [],
701
799
  agent_generated_files: [],
702
- my_sessions: [],
703
- collab_sessions: [],
800
+ sessions: [],
704
801
  issues: []
705
802
  };
706
803
  }
@@ -710,8 +807,7 @@ function cloneAgentMentionRawGroups(rawGroups) {
710
807
  agents: [...rawGroups.agents],
711
808
  opened_files: [...rawGroups.opened_files],
712
809
  agent_generated_files: [...rawGroups.agent_generated_files],
713
- my_sessions: [...rawGroups.my_sessions],
714
- collab_sessions: [...rawGroups.collab_sessions],
810
+ sessions: [...rawGroups.sessions],
715
811
  issues: [...rawGroups.issues]
716
812
  };
717
813
  }
@@ -721,8 +817,12 @@ function totalCountsFromRawGroups(rawGroups) {
721
817
  agents: rawGroups.agents.length,
722
818
  opened_files: rawGroups.opened_files.length,
723
819
  agent_generated_files: rawGroups.agent_generated_files.length,
724
- my_sessions: rawGroups.my_sessions.length,
725
- collab_sessions: rawGroups.collab_sessions.length,
820
+ my_sessions: rawGroups.sessions.filter(
821
+ (item) => item.kind === "session" && item.scope === "my_sessions"
822
+ ).length,
823
+ collab_sessions: rawGroups.sessions.filter(
824
+ (item) => item.kind === "session" && item.scope === "collab_sessions"
825
+ ).length,
726
826
  issues: rawGroups.issues.length
727
827
  };
728
828
  }
@@ -775,12 +875,8 @@ function logAgentMentionLifecycleDiagnostic(payload) {
775
875
  );
776
876
  }
777
877
  }
778
- function normalizeSessionMentionItemsForMySessions(input) {
779
- return input.items.filter((item) => item.kind === "session").filter(
780
- (item) => input.currentUserId ? item.scope === "my_sessions" : true
781
- ).map(
782
- (item) => item.scope === "my_sessions" ? item : { ...item, scope: "my_sessions" }
783
- );
878
+ function normalizeSessionMentionItems(input) {
879
+ return input.items.filter((item) => item.kind === "session");
784
880
  }
785
881
  function providerItemToAgentMentionItem(input) {
786
882
  const label = compactText4(input.label);
@@ -908,6 +1004,7 @@ function providerItemToAgentMentionItem(input) {
908
1004
  initiatorName: "",
909
1005
  agentName,
910
1006
  agentIconUrl: presentation.agentIconUrl?.trim() || presentation.iconUrl?.trim() || void 0,
1007
+ ...scope.agentTargetId ? { agentTargetId: scope.agentTargetId } : {},
911
1008
  status: presentation.status?.trim() || void 0,
912
1009
  inputPreview: description || void 0,
913
1010
  summaryPreview
@@ -1376,14 +1473,16 @@ async function fetchAgentMentionFilterResult(input) {
1376
1473
  workspaceId: input.workspaceId,
1377
1474
  currentUserId: input.currentUserId,
1378
1475
  query: input.query,
1379
- limit: DEFAULT_SESSION_LIMIT,
1476
+ // A provenance-aware host owns a room-scoped directory snapshot and
1477
+ // grouping must see that complete snapshot. Legacy providers retain
1478
+ // the bounded query contract.
1479
+ limit: input.provenanceCatalog?.enabledDimensions.includes("agent") ? void 0 : DEFAULT_SESSION_LIMIT,
1380
1480
  sessionCwd: input.sessionCwd,
1381
1481
  diagnostics: providerDiagnostics,
1382
1482
  provenanceFilter: input.provenanceFilter
1383
1483
  });
1384
1484
  const rawGroups = emptyAgentMentionRawGroups();
1385
- rawGroups.my_sessions = normalizeSessionMentionItemsForMySessions({
1386
- currentUserId: input.currentUserId,
1485
+ rawGroups.sessions = normalizeSessionMentionItems({
1387
1486
  items: sessionItems
1388
1487
  });
1389
1488
  return {
@@ -1657,6 +1756,7 @@ var AgentMentionSearchControllerBase = class {
1657
1756
  currentQuery = "";
1658
1757
  currentSessionCwd = "";
1659
1758
  currentProvenanceFilter = null;
1759
+ currentProvenanceCatalog = null;
1660
1760
  currentFileSearchLimit;
1661
1761
  currentIssueSearchLimit;
1662
1762
  agentGeneratedBrowsePath = null;
@@ -2039,6 +2139,9 @@ var AgentMentionSearchControllerBase = class {
2039
2139
  }
2040
2140
  }
2041
2141
  resetExpandedCounts() {
2142
+ for (const groupId of Object.keys(this.expandedCounts)) {
2143
+ delete this.expandedCounts[groupId];
2144
+ }
2042
2145
  for (const groupId of [
2043
2146
  "files",
2044
2147
  "opened_files",
@@ -2096,7 +2199,9 @@ var AgentMentionSearchControllerBase = class {
2096
2199
  expandedCounts: this.expandedCounts,
2097
2200
  rawGroups: this.rawGroups,
2098
2201
  totalCounts: this.totalCounts,
2099
- issueTopicGroups: this.issueTopicGroups
2202
+ issueTopicGroups: this.issueTopicGroups,
2203
+ provenanceCatalog: this.currentProvenanceCatalog,
2204
+ provenanceFilter: this.currentProvenanceFilter
2100
2205
  });
2101
2206
  }
2102
2207
  browseCacheKey(input, provenanceFilter = this.currentProvenanceFilter) {
@@ -2133,6 +2238,7 @@ var AgentMentionSearchControllerBase = class {
2133
2238
  fileLimit: this.fileLimit,
2134
2239
  currentFileSearchLimit: this.currentFileSearchLimit,
2135
2240
  currentIssueSearchLimit: this.currentIssueSearchLimit,
2241
+ provenanceCatalog: this.currentProvenanceCatalog,
2136
2242
  provenanceFilter,
2137
2243
  queryProviderMentionGroupsById: (queryInput) => this.queryProviderMentionGroupsById({ ...queryInput, abortSignal }),
2138
2244
  queryProviderMentionItemsById: (queryInput) => this.queryProviderMentionItemsById({ ...queryInput, abortSignal })
@@ -2154,6 +2260,17 @@ var AgentMentionSearchControllerBase = class {
2154
2260
  import { referenceProvenanceFilterCacheKey as referenceProvenanceFilterCacheKey2 } from "@tutti-os/workspace-file-reference/core";
2155
2261
  var AgentMentionSearchController = class extends AgentMentionSearchControllerBase {
2156
2262
  issueLoadMoreRequests = /* @__PURE__ */ new Map();
2263
+ setProvenanceCatalog(catalog) {
2264
+ if (this.currentProvenanceCatalog === catalog) return;
2265
+ this.currentProvenanceCatalog = catalog;
2266
+ if (this.currentFilter !== "session" || this.state.status !== "ready" && this.state.status !== "loading") {
2267
+ return;
2268
+ }
2269
+ this.setState({
2270
+ ...this.state,
2271
+ groups: this.groupsFromRawGroups()
2272
+ });
2273
+ }
2157
2274
  setProvenanceFilter(filter) {
2158
2275
  const previousKey = this.currentProvenanceFilter ? referenceProvenanceFilterCacheKey2(this.currentProvenanceFilter) : "disabled";
2159
2276
  const nextKey = filter ? referenceProvenanceFilterCacheKey2(filter) : "disabled";
@@ -2689,4 +2806,4 @@ export {
2689
2806
  AgentMentionSearchController,
2690
2807
  preloadAgentMentionBrowse
2691
2808
  };
2692
- //# sourceMappingURL=chunk-JG7HGKZL.js.map
2809
+ //# sourceMappingURL=chunk-BXOKBZH4.js.map