generated from nhcarrigan/template
feat: batch of fixes and features (#56)
## Summary This PR includes a batch of bug fixes and new features: ### Bug Fixes - **Links in chat history now open in default browser** instead of navigating within the app - Closes #54 - **Allow spaces in tab names** - space key no longer acts like enter when renaming tabs - Closes #52 ### New Features - **`/cd` command** - Change the working directory of an active tab with context preservation - Closes #55 - **`/search` command** - Search and highlight matches within the conversation - Closes #32 ## Test Plan - [ ] Click a link in chat history and verify it opens in the default browser - [ ] Rename a tab and verify spaces can be typed - [ ] Use `/cd <path>` and verify the directory changes while preserving conversation context - [ ] Use `/search <query>` and verify matches are highlighted in yellow - [ ] Use `/search` with no args to clear the search highlighting ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Reviewed-on: #56 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #56.
This commit is contained in:
@@ -3,10 +3,17 @@
|
||||
import { afterUpdate } from "svelte";
|
||||
import ConversationTabs from "./ConversationTabs.svelte";
|
||||
import Markdown from "./Markdown.svelte";
|
||||
import HighlightedText from "./HighlightedText.svelte";
|
||||
import { searchState, searchQuery } from "$lib/stores/search";
|
||||
|
||||
let terminalElement: HTMLDivElement;
|
||||
let shouldAutoScroll = true;
|
||||
let lines: TerminalLine[] = [];
|
||||
let currentSearchQuery = "";
|
||||
|
||||
searchQuery.subscribe((value) => {
|
||||
currentSearchQuery = value;
|
||||
});
|
||||
|
||||
claudeStore.terminalLines.subscribe((value) => {
|
||||
lines = value;
|
||||
@@ -64,6 +71,23 @@
|
||||
minute: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
$: {
|
||||
if (currentSearchQuery && lines.length > 0) {
|
||||
const escapedQuery = currentSearchQuery.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const regex = new RegExp(escapedQuery, "gi");
|
||||
let totalMatches = 0;
|
||||
for (const line of lines) {
|
||||
const matches = line.content.match(regex);
|
||||
if (matches) {
|
||||
totalMatches += matches.length;
|
||||
}
|
||||
}
|
||||
searchState.setMatchCount(totalMatches);
|
||||
} else {
|
||||
searchState.setMatchCount(0);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -102,9 +126,9 @@
|
||||
<span class="terminal-tool-name mr-2">[{line.toolName}]</span>
|
||||
{/if}
|
||||
{#if line.type === "assistant"}
|
||||
<Markdown content={line.content} />
|
||||
<Markdown content={line.content} searchQuery={currentSearchQuery} />
|
||||
{:else}
|
||||
<span class="whitespace-pre-wrap">{line.content}</span>
|
||||
<HighlightedText content={line.content} searchQuery={currentSearchQuery} />
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
@@ -162,4 +186,11 @@
|
||||
.terminal-header-text {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
:global(.search-highlight) {
|
||||
background-color: var(--search-highlight, #fbbf24);
|
||||
color: var(--search-highlight-text, #000);
|
||||
border-radius: 2px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user