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: 1 addition & 1 deletion src/components/chat/CollapsibleUserBubble.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function handleClick(evt: MouseEvent) {
class="s2b-overflow-hidden s2b-transition-[max-height] s2b-duration-200 s2b-ease-out s2b-break-words s2b-wrap-anywhere"
style:max-height={isExpanded || !isTruncated ? "none" : `${COLLAPSED_HEIGHT}px`}
>
<MarkdownRenderer {content} class="[&>p]:s2b-m-0 s2b-break-words s2b-wrap-anywhere" />
<MarkdownRenderer {content} class="s2b-user-bubble-text [&>p]:s2b-m-0 s2b-break-words s2b-wrap-anywhere" />
</div>

{#if isTruncated && !isExpanded}
Expand Down
10 changes: 8 additions & 2 deletions src/components/chat/ContextTray.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type VisibleNote,
type VisibleNoteRef,
} from "../../hooks/useVisibleNotes.svelte";
import { SelectionTracker, type SelectionRef } from "../../hooks/useSelection.svelte";
import { SELECTION_ICON, SelectionTracker, type SelectionRef } from "../../hooks/useSelection.svelte";
import type { GraphNoteRef } from "../../stores/chatTimeline";
import type { ChatAttachment } from "../../types/shared";
import { getPlugin } from "../../stores/state.svelte";
Expand Down Expand Up @@ -218,6 +218,12 @@ function onSelectionClick(evt: MouseEvent): void {
dismissSelection();
}

/** Keep the quote chip of a selection in chat message text (see `SelectionTracker.pinChatSelection`).
* The composer calls this when it is pressed or focused. */
export function pinChatSelection(): void {
selectionTracker.pinChatSelection();
}

function dismissSelection(): void {
dismissedSelection = selectionTracker.selection;
selectionTracker.clear();
Expand Down Expand Up @@ -427,7 +433,7 @@ onDestroy(() => {
})}
onclick={onSelectionClick}
>
<div class="chip-icon" use:icon={activeSelection.icon} style="--icon-size: 12px"></div>
<div class="chip-icon" use:icon={SELECTION_ICON} style="--icon-size: 12px"></div>
<span class="chip-label">{selectionPreview(activeSelection.text)}</span>
{#if selectionTracker.isLong}
<span class="chip-warning" title={t("chat.context_tray.selection_long")}>⚠</span>
Expand Down
18 changes: 17 additions & 1 deletion src/components/chat/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ function sendMessage() {
contentToSend,
attachments.length > 0 ? [...attachments] : undefined,
activeVisibleNotes.length > 0 ? [...activeVisibleNotes] : undefined,
activeSelection ? { ...activeSelection } : undefined,
activeSelection ? withQuoteDestination(activeSelection) : undefined,
activeGraphNotes.length > 0 ? [...activeGraphNotes] : undefined,
)
.catch((error) => {
Expand Down Expand Up @@ -1298,6 +1298,20 @@ async function promoteVisibleNoteToAttachment(note: VisibleNote) {
savingFiles = false;
}
}
// Text selected in a chat's messages shows as a quote chip at once, but it is
// kept only once the user turns to the composer. Capture phase, so it runs
// before the press moves the selection into the editor and collapses it.
function pinChatSelection(): void {
contextTrayRef?.pinChatSelection();
}

/** Snapshot of the selection to send. A chat quote is told here, at send time,
* whether it comes from the thread it is sent in: a pinned quote outlives the
* composer switching threads, so the thread it was pinned in says nothing. */
function withQuoteDestination(selection: SelectionRef): SelectionRef {
if (selection.viewType !== "chat") return { ...selection };
return { ...selection, sameThread: threadPath !== null && selection.path === threadPath };
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}
</script>

<div
Expand Down Expand Up @@ -1337,6 +1351,8 @@ async function promoteVisibleNoteToAttachment(note: VisibleNote) {
ondragleave={dropTargetMode === "input" ? handleDragLeave : undefined}
ondrop={dropTargetMode === "input" ? handleDrop : undefined}
onclick={handleWrapperClick}
onpointerdowncapture={pinChatSelection}
onfocusincapture={pinChatSelection}
role="region"
bind:this={wrapperEl}
style:min-height={cardMinHeight ? `${cardMinHeight}px` : undefined}
Expand Down
3 changes: 2 additions & 1 deletion src/components/chat/MessageContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import AssistantStatusNotice from "./AssistantStatusNotice.svelte";
import ToolCallsSection from "./ToolCallsSection.svelte";
import ChatRecommendations from "./ChatRecommendations.svelte";
import { icon } from "../../utils/utils";
import { SELECTION_ICON } from "../../hooks/useSelection.svelte";
import { getLocale, t } from "../../i18n";

interface Props {
Expand Down Expand Up @@ -813,7 +814,7 @@ $effect(() => {
onmouseover={(evt) => previewReferencedNote(evt, selection.path)}
onfocus={(evt) => previewReferencedNote(evt, selection.path)}
>
<span class="chip-icon" use:icon={selection.icon} style="--icon-size: 12px"
<span class="chip-icon" use:icon={SELECTION_ICON} style="--icon-size: 12px"
></span>
<span
>{selection.basename}<span class="chip-context">
Expand Down
Loading
Loading