fix: remove unused dependencies from Cargo.lock and improve selection toolbar behavior in LatexEditor

This commit is contained in:
delibae 2026-03-02 12:03:41 +09:00
parent 3ed156af22
commit 2ecb218f29
3 changed files with 23 additions and 42 deletions

View file

@ -1130,8 +1130,6 @@ dependencies = [
"libc",
"libgit2-sys",
"log",
"openssl-probe",
"openssl-sys",
"url",
]
@ -1792,9 +1790,7 @@ checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487"
dependencies = [
"cc",
"libc",
"libssh2-sys",
"libz-sys",
"openssl-sys",
"pkg-config",
]
@ -1818,20 +1814,6 @@ dependencies = [
"libc",
]
[[package]]
name = "libssh2-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "220e4f05ad4a218192533b300327f5150e809b54c4ec83b5a1d91833601811b9"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
]
[[package]]
name = "libz-sys"
version = "1.1.23"
@ -2286,24 +2268,6 @@ dependencies = [
"pathdiff",
]
[[package]]
name = "openssl-probe"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
[[package]]
name = "openssl-sys"
version = "0.9.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "option-ext"
version = "0.2.0"

View file

@ -266,7 +266,10 @@ const UserMessage: FC<{ message: ClaudeStreamMessage }> = ({ message }) => {
</span>
)}
{contextLabel && bodyText && <br />}
{bodyText}
<MarkdownRenderer
content={bodyText}
className="prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"
/>
</div>
</div>
);

View file

@ -100,6 +100,9 @@ export function LatexEditor() {
const [mergeChunkInfo, setMergeChunkInfo] = useState({ total: 0, current: 0 });
const [diagnostics, setDiagnostics] = useState<DiagnosticItem[]>([]);
const [selectionCoords, setSelectionCoords] = useState<{ top: number; left: number } | null>(null);
// When the selection toolbar is visible, prevent CM selection changes from clearing it.
// Only explicit dismiss/send/action should clear the toolbar.
const toolbarStickyRef = useRef(false);
const parentRef = useRef<HTMLDivElement>(null);
const { resolvedTheme } = useTheme();
@ -335,12 +338,12 @@ export function LatexEditor() {
if (update.selectionSet) {
const { from, to, head } = update.state.selection.main;
setCursorPosition(head);
setSelectionRange(from !== to ? { start: from, end: to } : null);
// Compute toolbar position below the selection end
// Skip toolbar for "select all" (Cmd+A) to avoid overlay issues
const isSelectAll = from === 0 && to === update.state.doc.length;
if (from !== to && !isSelectAll) {
setSelectionRange({ start: from, end: to });
const startCoords = update.view.coordsAtPos(from);
const endCoords = update.view.coordsAtPos(to);
if (endCoords && startCoords) {
@ -349,7 +352,12 @@ export function LatexEditor() {
left: startCoords.left, // aligned to selection start
});
}
} else {
toolbarStickyRef.current = true;
} else if (!toolbarStickyRef.current) {
// Only clear selection/coords if the toolbar is not being interacted with.
// Clicking the toolbar input causes CM to lose focus and collapse the selection,
// but we want to keep the toolbar visible until explicitly dismissed.
setSelectionRange(null);
setSelectionCoords(null);
}
}
@ -647,10 +655,12 @@ export function LatexEditor() {
const handleToolbarSendPrompt = useCallback(
(prompt: string) => {
toolbarStickyRef.current = false;
setSelectionCoords(null);
setSelectionRange(null);
useClaudeChatStore.getState().sendPrompt(prompt);
},
[],
[setSelectionRange],
);
const editorToolbarActions: ToolbarAction[] = useMemo(() => [
@ -659,17 +669,21 @@ export function LatexEditor() {
const handleToolbarAction = useCallback(
(actionId: string) => {
toolbarStickyRef.current = false;
setSelectionCoords(null);
setSelectionRange(null);
if (actionId === "proofread") {
useClaudeChatStore.getState().sendPrompt("Proofread and fix any errors in this text");
}
},
[],
[setSelectionRange],
);
const handleToolbarDismiss = useCallback(() => {
toolbarStickyRef.current = false;
setSelectionCoords(null);
}, []);
setSelectionRange(null);
}, [setSelectionRange]);
// History review action handlers
const handleHistoryRestore = useCallback(async () => {