Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/differ/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ git-diff = { path = "../../../crates/git-diff" }
# macOS font enumeration
[target.'cfg(target_os = "macos")'.dependencies]
core-text = "20"

[workspace]
2 changes: 2 additions & 0 deletions apps/staged/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ axum = { version = "0.8" }
# [[bin]]
# name = "debug_diff"
# path = "src/bin/debug_diff.rs"

[workspace]
28 changes: 27 additions & 1 deletion apps/staged/src/lib/features/sessions/SessionModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
hasXmlBlocks,
stripCodeFences,
stripXmlTags,
type VerbGroup,
} from './sessionModalHelpers';
import InContentSearch from '../../shared/InContentSearch.svelte';
import { highlightMatches, clearHighlights, scrollToMatch } from '../../shared/textHighlight';
Expand Down Expand Up @@ -926,6 +927,30 @@
return arr;
});

/**
* Pre-compute verb groups for every tools group in both tenses.
* `groupByVerb` is expensive (JSON.parse + string replace per tool call) so we
* cache both the past-tense and present-tense variants here. The template then
* picks the right variant with a cheap boolean lookup instead of re-running the
* heavy computation on every render.
*/
let verbGroupCache = $derived.by(() => {
const cache: { past: VerbGroup[]; present: VerbGroup[] }[] = [];
for (const group of grouped) {
if (group.type === 'tools') {
cache.push({
past: groupByVerb(group.pairs, repoDir, true),
present: groupByVerb(group.pairs, repoDir, false),
});
} else {
// Placeholder — tool-group index won't line up otherwise.
// We use a separate counter in the template instead.
cache.push({ past: [], present: [] });
}
}
return cache;
});

/** Stable key for a message group — used to key the {#each} block for transitions.
* For tools groups, keys off the first pair — safe because the grouping logic
* in `grouped` always pushes at least one pair before creating a tools group. */
Expand Down Expand Up @@ -1124,8 +1149,9 @@
</div>
</div>
{:else}
{@const forcePastTense = !isLive || sending || hasUserAfter[groupIdx]}
<div class="message-row tool-group">
{#each groupByVerb(group.pairs, repoDir, !isLive || sending || hasUserAfter[groupIdx]) as vg, vgIdx}
{#each forcePastTense ? verbGroupCache[groupIdx].past : verbGroupCache[groupIdx].present as vg, vgIdx}
{#if vg.items.length === 1}
{@const item = vg.items[0]}
{@const isExpanded = expandedTools.has(item.pair.call.id)}
Expand Down