@stigmer/react 3.1.4 → 3.1.5

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.
Files changed (118) hide show
  1. package/execution/FileReviewContext.d.ts +15 -1
  2. package/execution/FileReviewContext.d.ts.map +1 -1
  3. package/execution/FileReviewContext.js +20 -1
  4. package/execution/FileReviewContext.js.map +1 -1
  5. package/execution/MessageThread.d.ts +65 -2
  6. package/execution/MessageThread.d.ts.map +1 -1
  7. package/execution/MessageThread.js +42 -23
  8. package/execution/MessageThread.js.map +1 -1
  9. package/execution/TodoCard.d.ts +8 -0
  10. package/execution/TodoCard.d.ts.map +1 -1
  11. package/execution/TodoCard.js +6 -4
  12. package/execution/TodoCard.js.map +1 -1
  13. package/execution/TodoList.d.ts +20 -1
  14. package/execution/TodoList.d.ts.map +1 -1
  15. package/execution/TodoList.js +9 -6
  16. package/execution/TodoList.js.map +1 -1
  17. package/execution/ToolCallDetail.d.ts +3 -2
  18. package/execution/ToolCallDetail.d.ts.map +1 -1
  19. package/execution/ToolCallDetail.js +49 -16
  20. package/execution/ToolCallDetail.js.map +1 -1
  21. package/execution/file-review-status.d.ts +15 -0
  22. package/execution/file-review-status.d.ts.map +1 -1
  23. package/execution/file-review-status.js +22 -0
  24. package/execution/file-review-status.js.map +1 -1
  25. package/execution/index.d.ts +5 -5
  26. package/execution/index.d.ts.map +1 -1
  27. package/execution/index.js +3 -3
  28. package/execution/index.js.map +1 -1
  29. package/github/useGitHubFileReader.d.ts +4 -2
  30. package/github/useGitHubFileReader.d.ts.map +1 -1
  31. package/github/useGitHubFileReader.js +16 -3
  32. package/github/useGitHubFileReader.js.map +1 -1
  33. package/github/useGitHubTreeLister.d.ts +2 -1
  34. package/github/useGitHubTreeLister.d.ts.map +1 -1
  35. package/github/useGitHubTreeLister.js +7 -3
  36. package/github/useGitHubTreeLister.js.map +1 -1
  37. package/index.d.ts +3 -3
  38. package/index.d.ts.map +1 -1
  39. package/index.js +3 -3
  40. package/index.js.map +1 -1
  41. package/internal/VirtualizedThread.d.ts +3 -2
  42. package/internal/VirtualizedThread.d.ts.map +1 -1
  43. package/internal/VirtualizedThread.js +3 -2
  44. package/internal/VirtualizedThread.js.map +1 -1
  45. package/package.json +4 -4
  46. package/session/SessionViewer.d.ts +11 -1
  47. package/session/SessionViewer.d.ts.map +1 -1
  48. package/session/SessionViewer.js +12 -5
  49. package/session/SessionViewer.js.map +1 -1
  50. package/session/index.d.ts +1 -0
  51. package/session/index.d.ts.map +1 -1
  52. package/session/index.js +1 -0
  53. package/session/index.js.map +1 -1
  54. package/session/useWorkspaceReadRefs.d.ts +45 -0
  55. package/session/useWorkspaceReadRefs.d.ts.map +1 -0
  56. package/session/useWorkspaceReadRefs.js +104 -0
  57. package/session/useWorkspaceReadRefs.js.map +1 -0
  58. package/src/execution/FileReviewContext.ts +27 -1
  59. package/src/execution/MessageThread.tsx +110 -22
  60. package/src/execution/TodoCard.tsx +20 -4
  61. package/src/execution/TodoList.tsx +26 -4
  62. package/src/execution/ToolCallDetail.tsx +69 -16
  63. package/src/execution/__tests__/ToolCallDetail.test.tsx +188 -2
  64. package/src/execution/__tests__/file-review-status.test.ts +47 -0
  65. package/src/execution/__tests__/message-thread-slots.test.tsx +463 -0
  66. package/src/execution/file-review-status.ts +24 -0
  67. package/src/execution/index.ts +13 -3
  68. package/src/github/__tests__/useGitHubFileReader.test.ts +35 -2
  69. package/src/github/__tests__/useGitHubTreeLister.test.ts +14 -0
  70. package/src/github/useGitHubFileReader.ts +19 -6
  71. package/src/github/useGitHubTreeLister.ts +7 -3
  72. package/src/index.ts +4 -0
  73. package/src/internal/VirtualizedThread.tsx +5 -1
  74. package/src/session/SessionViewer.tsx +27 -2
  75. package/src/session/__tests__/useWorkspaceReadRefs.test.ts +245 -0
  76. package/src/session/index.ts +2 -0
  77. package/src/session/useWorkspaceReadRefs.ts +118 -0
  78. package/src/workspace/FileViewer.tsx +144 -38
  79. package/src/workspace/WorkspaceFileReader.ts +21 -0
  80. package/src/workspace/__tests__/FileViewer.test.tsx +138 -3
  81. package/src/workspace/__tests__/useWorkspaceFileContent.test.tsx +20 -0
  82. package/src/workspace/__tests__/workspaceListingCache.test.ts +114 -0
  83. package/src/workspace/index.ts +4 -1
  84. package/src/workspace/useWorkspaceEntries.ts +11 -0
  85. package/src/workspace/useWorkspaceFileContent.ts +4 -1
  86. package/src/workspace/useWorkspaceFileSearch.ts +8 -3
  87. package/src/workspace/useWorkspaceFiles.ts +3 -2
  88. package/src/workspace/workspaceListingCache.ts +21 -7
  89. package/styles.css +1 -1
  90. package/workspace/FileViewer.d.ts +1 -1
  91. package/workspace/FileViewer.d.ts.map +1 -1
  92. package/workspace/FileViewer.js +55 -5
  93. package/workspace/FileViewer.js.map +1 -1
  94. package/workspace/WorkspaceFileReader.d.ts +17 -0
  95. package/workspace/WorkspaceFileReader.d.ts.map +1 -1
  96. package/workspace/WorkspaceFileReader.js +18 -0
  97. package/workspace/WorkspaceFileReader.js.map +1 -1
  98. package/workspace/index.d.ts +1 -1
  99. package/workspace/index.d.ts.map +1 -1
  100. package/workspace/index.js +1 -1
  101. package/workspace/index.js.map +1 -1
  102. package/workspace/useWorkspaceEntries.d.ts +11 -0
  103. package/workspace/useWorkspaceEntries.d.ts.map +1 -1
  104. package/workspace/useWorkspaceEntries.js.map +1 -1
  105. package/workspace/useWorkspaceFileContent.d.ts.map +1 -1
  106. package/workspace/useWorkspaceFileContent.js +4 -1
  107. package/workspace/useWorkspaceFileContent.js.map +1 -1
  108. package/workspace/useWorkspaceFileSearch.d.ts.map +1 -1
  109. package/workspace/useWorkspaceFileSearch.js +8 -3
  110. package/workspace/useWorkspaceFileSearch.js.map +1 -1
  111. package/workspace/useWorkspaceFiles.d.ts +2 -1
  112. package/workspace/useWorkspaceFiles.d.ts.map +1 -1
  113. package/workspace/useWorkspaceFiles.js +3 -2
  114. package/workspace/useWorkspaceFiles.js.map +1 -1
  115. package/workspace/workspaceListingCache.d.ts +1 -1
  116. package/workspace/workspaceListingCache.d.ts.map +1 -1
  117. package/workspace/workspaceListingCache.js +20 -7
  118. package/workspace/workspaceListingCache.js.map +1 -1
@@ -3,9 +3,12 @@
3
3
  // Both surfaces that need a listing read through here: the Files accordion
4
4
  // (`useWorkspaceFiles`, one entry) and workspace search (`useWorkspaceFileSearch`,
5
5
  // many entries). Keeping one module-level cache — keyed by the stable-within-page
6
- // `entry.id` guarantees the two never double-fetch or drift, and lets one fetch
7
- // produce every shape a consumer needs (flat files for search, a tree for the
8
- // accordion, and the truncation flag for the banner).
6
+ // `entry.id` plus the entry's effective read ref guarantees the two never
7
+ // double-fetch or drift, and lets one fetch produce every shape a consumer needs
8
+ // (flat files for search, a tree for the accordion, and the truncation flag for
9
+ // the banner). The ref is part of the key because a listing is a snapshot of one
10
+ // ref: when a session's write-back advances `readRef`, the old listing is stale
11
+ // by definition and must not be served.
9
12
 
10
13
  import { buildFileTree, type TreeNode } from "../internal/file-tree/index.js";
11
14
  import type { WorkspaceEntry } from "./useWorkspaceEntries.js";
@@ -40,13 +43,24 @@ export interface LoadEntryFilesOptions {
40
43
 
41
44
  const sharedCache = new Map<string, WorkspaceListing>();
42
45
 
46
+ /**
47
+ * Cache key for one entry's listing: identity plus the ref the listing was
48
+ * taken at. `entry.id` alone is NOT sufficient — it anchors file-selection
49
+ * identity across the surface and stays stable while `readRef` advances with
50
+ * each write-back push, so the ref must contribute to the key or consumers
51
+ * would see the pre-push tree forever.
52
+ */
53
+ function listingCacheKey(entry: WorkspaceEntry): string {
54
+ return `${entry.id}\u0000${entry.readRef ?? entry.gitBranch ?? ""}`;
55
+ }
56
+
43
57
  /**
44
58
  * Returns a cached {@link WorkspaceListing} for an entry synchronously, or
45
59
  * `undefined` when nothing is cached. Lets a consumer render a warm listing
46
60
  * instantly (no loading flash) before deciding whether to fetch.
47
61
  */
48
- export function peekEntryListing(entryId: string): WorkspaceListing | undefined {
49
- return sharedCache.get(entryId);
62
+ export function peekEntryListing(entry: WorkspaceEntry): WorkspaceListing | undefined {
63
+ return sharedCache.get(listingCacheKey(entry));
50
64
  }
51
65
 
52
66
  /**
@@ -63,7 +77,7 @@ export async function loadEntryFiles(
63
77
  options: LoadEntryFilesOptions = {},
64
78
  ): Promise<WorkspaceListing | null> {
65
79
  if (!options.bustCache) {
66
- const cached = sharedCache.get(entry.id);
80
+ const cached = sharedCache.get(listingCacheKey(entry));
67
81
  if (cached) return cached;
68
82
  }
69
83
 
@@ -71,7 +85,7 @@ export async function loadEntryFiles(
71
85
  if (raw === null) return null;
72
86
 
73
87
  const listing = buildListing(raw);
74
- sharedCache.set(entry.id, listing);
88
+ sharedCache.set(listingCacheKey(entry), listing);
75
89
  return listing;
76
90
  }
77
91