repoburg 1.3.199 → 1.3.201
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.
- package/agent-pane/backend/data.db +0 -0
- package/agent-pane/backend/data.db-shm +0 -0
- package/agent-pane/backend/data.db-wal +0 -0
- package/agent-pane/backend/dist/index.js +1425 -272
- package/agent-pane/backend/src/claude/claude-provider.test.ts +393 -3
- package/agent-pane/backend/src/claude/claude-provider.ts +53 -50
- package/agent-pane/backend/src/db/index.ts +6 -0
- package/agent-pane/backend/src/index.ts +5 -2
- package/agent-pane/backend/src/integration/threads-claude-fork.test.ts +241 -0
- package/agent-pane/backend/src/providers/index.ts +3 -1
- package/agent-pane/backend/src/repoburg/action-mapping.ts +216 -0
- package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +271 -0
- package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +262 -0
- package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +271 -0
- package/agent-pane/backend/src/repoburg/backend-resolver.ts +246 -0
- package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +159 -0
- package/agent-pane/backend/src/repoburg/repoburg-client.ts +181 -0
- package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +723 -0
- package/agent-pane/backend/src/repoburg/repoburg-provider.ts +422 -0
- package/agent-pane/backend/src/repoburg/turn-projector.test.ts +475 -0
- package/agent-pane/backend/src/repoburg/turn-projector.ts +537 -0
- package/agent-pane/backend/src/routes/providers.test.ts +18 -1
- package/agent-pane/backend/src/routes/providers.ts +19 -1
- package/agent-pane/backend/src/routes/sessions.ts +12 -0
- package/agent-pane/backend/src/routes/threads.ts +21 -6
- package/agent-pane/backend/src/routes/turns.test.ts +45 -1
- package/agent-pane/frontend/dist/assets/{index-Dwwhx7YN.css → index-34WaZYsW.css} +1 -1
- package/agent-pane/frontend/dist/assets/index-y7xlT86e.js +362 -0
- package/agent-pane/frontend/dist/index.html +2 -2
- package/agent-pane/frontend/src/components/CommentableText.test.tsx +196 -0
- package/agent-pane/frontend/src/components/CommentableText.tsx +109 -21
- package/agent-pane/frontend/src/components/IdeWorkspace.test.tsx +39 -0
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +28 -2
- package/agent-pane/frontend/src/components/ResizeHandle.tsx +29 -0
- package/agent-pane/frontend/src/components/panels/ThreadsPanel.tsx +35 -3
- package/agent-pane/frontend/src/constants/models.ts +37 -0
- package/agent-pane/frontend/src/hooks/useResizable.test.ts +97 -0
- package/agent-pane/frontend/src/hooks/useResizable.ts +75 -0
- package/agent-pane/frontend/src/store/store.test.ts +35 -0
- package/agent-pane/frontend/src/store/uiSlice.ts +50 -0
- package/agent-pane/frontend/src/styles/app.css +10 -1
- package/agent-pane/frontend/src/test/component-helpers.ts +2 -0
- package/agent-pane-bug-repro-no-agent-reply.png +0 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.d.ts +20 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js +112 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js.map +1 -0
- package/backend/dist/src/agent-runtime/agent-runtime.controller.d.ts +11 -0
- package/backend/dist/src/agent-runtime/agent-runtime.controller.js +91 -0
- package/backend/dist/src/agent-runtime/agent-runtime.controller.js.map +1 -0
- package/backend/dist/src/agent-runtime/agent-runtime.module.d.ts +2 -0
- package/backend/dist/src/agent-runtime/agent-runtime.module.js +26 -0
- package/backend/dist/src/agent-runtime/agent-runtime.module.js.map +1 -0
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +77 -0
- package/backend/dist/src/agent-runtime/agent-runtime.types.js +3 -0
- package/backend/dist/src/agent-runtime/agent-runtime.types.js.map +1 -0
- package/backend/dist/src/app.module.js +4 -0
- package/backend/dist/src/app.module.js.map +1 -1
- package/backend/dist/src/interactive-chat/chat.module.js +4 -0
- package/backend/dist/src/interactive-chat/chat.module.js.map +1 -1
- package/backend/dist/src/interactive-chat/chat.service.d.ts +3 -1
- package/backend/dist/src/interactive-chat/chat.service.js +33 -6
- package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.d.ts +3 -1
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +20 -2
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +2 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +4 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +35 -2
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/src/llm-provider/ollama-llm.provider.d.ts +1 -0
- package/backend/dist/src/llm-provider/ollama-llm.provider.js +19 -1
- package/backend/dist/src/llm-provider/ollama-llm.provider.js.map +1 -1
- package/backend/dist/src/llm-responses/llm-responses.module.js +4 -0
- package/backend/dist/src/llm-responses/llm-responses.module.js.map +1 -1
- package/backend/dist/src/llm-responses/llm-responses.service.d.ts +4 -1
- package/backend/dist/src/llm-responses/llm-responses.service.js +52 -2
- package/backend/dist/src/llm-responses/llm-responses.service.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/daemon/dist/index.js +0 -0
- package/package.json +1 -1
- package/agent-pane/frontend/dist/assets/index-BYo-lnxm.js +0 -362
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;450;510;590;600&family=JetBrains+Mono:wght@400;500&display=swap"
|
|
11
11
|
rel="stylesheet"
|
|
12
12
|
/>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-y7xlT86e.js"></script>
|
|
14
|
+
<link rel="stylesheet" crossorigin href="/assets/index-34WaZYsW.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, cleanup, act } from '@testing-library/react';
|
|
3
|
+
import CommentableText from './CommentableText.tsx';
|
|
4
|
+
import { resetStore } from '../test/component-helpers.ts';
|
|
5
|
+
import { useStore } from '../store/store.ts';
|
|
6
|
+
|
|
7
|
+
const CONTENT = 'Hello world this is a line of text';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Select a character range within the rendered markdown container's text node.
|
|
11
|
+
* `backward` emulates a drag selection from end -> start by collapsing the
|
|
12
|
+
* caret to the end and extending it back to the start (anchor after focus).
|
|
13
|
+
*/
|
|
14
|
+
function selectChars(startChar: number, endChar: number, backward: boolean): void {
|
|
15
|
+
const p = screen.getByText(CONTENT);
|
|
16
|
+
const textNode = p.firstChild as Text;
|
|
17
|
+
const sel = window.getSelection()!;
|
|
18
|
+
sel.removeAllRanges();
|
|
19
|
+
if (backward) {
|
|
20
|
+
// anchor at the end, then extend the focus back to the start
|
|
21
|
+
sel.collapse(textNode, endChar);
|
|
22
|
+
sel.extend(textNode, startChar);
|
|
23
|
+
} else {
|
|
24
|
+
sel.collapse(textNode, startChar);
|
|
25
|
+
sel.extend(textNode, endChar);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Dispatch a native `mouseup` whose target is OUTSIDE the markdown container
|
|
30
|
+
* (on document.body), eminating a release in the surrounding padding/gutter. */
|
|
31
|
+
function dispatchMouseUpOutside(): void {
|
|
32
|
+
const evt = new MouseEvent('mouseup', { bubbles: true });
|
|
33
|
+
document.body.dispatchEvent(evt);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Open the discuss popover via a backward selection + Discuss click. Returns the textarea. */
|
|
37
|
+
function openDiscuss(): HTMLTextAreaElement {
|
|
38
|
+
selectChars(0, 5, true);
|
|
39
|
+
act(() => {
|
|
40
|
+
dispatchMouseUpOutside();
|
|
41
|
+
});
|
|
42
|
+
fireEvent.click(screen.getByText('Discuss'));
|
|
43
|
+
return screen.getByPlaceholderText('Ask about this text…') as HTMLTextAreaElement;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('CommentableText — selection quote button', () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
resetStore();
|
|
49
|
+
// jsdom has no layout engine, so Range lacks getBoundingClientRect/getClientRects.
|
|
50
|
+
// Polyfill with zero rects so the production positioning code can run.
|
|
51
|
+
const zeroRect = {
|
|
52
|
+
x: 0, y: 0, top: 0, left: 0, right: 0, bottom: 0, width: 0, height: 0,
|
|
53
|
+
toJSON: () => ({}),
|
|
54
|
+
};
|
|
55
|
+
(Range.prototype as unknown as { getBoundingClientRect: unknown }).getBoundingClientRect =
|
|
56
|
+
() => zeroRect;
|
|
57
|
+
(Range.prototype as unknown as { getClientRects: unknown }).getClientRects = () => [];
|
|
58
|
+
// jsdom has no layout, so offsetWidth/offsetHeight are 0. Mock the popover
|
|
59
|
+
// dimensions so the viewport-clamp logic in useLayoutEffect can be exercised.
|
|
60
|
+
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { configurable: true, get: () => 320 });
|
|
61
|
+
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { configurable: true, get: () => 140 });
|
|
62
|
+
});
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
cleanup();
|
|
65
|
+
window.getSelection()?.removeAllRanges();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('shows the Quote button when a forward selection is released outside the container', () => {
|
|
69
|
+
render(
|
|
70
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
selectChars(0, 5, false);
|
|
74
|
+
act(() => {
|
|
75
|
+
dispatchMouseUpOutside();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Before the fix, the container-only onMouseUp never fired for a release
|
|
79
|
+
// outside the container, so the button did not appear.
|
|
80
|
+
expect(screen.getByText('Quote')).toBeInTheDocument();
|
|
81
|
+
expect(screen.getByText('Discuss')).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('shows the Quote button for a backward selection dragged to the line start (the reported bug)', () => {
|
|
85
|
+
render(
|
|
86
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Drag from the very end back to the very start (line start).
|
|
90
|
+
selectChars(0, CONTENT.length, true);
|
|
91
|
+
act(() => {
|
|
92
|
+
dispatchMouseUpOutside();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(screen.getByText('Quote')).toBeInTheDocument();
|
|
96
|
+
expect(screen.getByText('Discuss')).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('populates the store quotedText when Quote is clicked after a backward selection', () => {
|
|
100
|
+
render(
|
|
101
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
selectChars(0, 5, true);
|
|
105
|
+
act(() => {
|
|
106
|
+
dispatchMouseUpOutside();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
fireEvent.click(screen.getByText('Quote'));
|
|
110
|
+
|
|
111
|
+
const quoted = useStore.getState().quotedText;
|
|
112
|
+
expect(quoted).toBeTruthy();
|
|
113
|
+
expect(quoted).toContain('QUOTE');
|
|
114
|
+
expect(quoted).toContain('Hello');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('keeps the discuss popover on-screen for a backward selection near the left edge', () => {
|
|
118
|
+
render(
|
|
119
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// Backward selection near the start anchors the button at the left edge.
|
|
123
|
+
selectChars(0, 5, true);
|
|
124
|
+
act(() => {
|
|
125
|
+
dispatchMouseUpOutside();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
fireEvent.click(screen.getByText('Discuss'));
|
|
129
|
+
|
|
130
|
+
const popover = document.querySelector('.thread-create-popover') as HTMLElement;
|
|
131
|
+
expect(popover).toBeTruthy();
|
|
132
|
+
const left = parseFloat(popover.style.left);
|
|
133
|
+
const top = parseFloat(popover.style.top);
|
|
134
|
+
// Popover opens to the left via translateX(-100%): visible left edge = left - 320.
|
|
135
|
+
// It must stay on-screen: left edge >= 8 → left >= 328.
|
|
136
|
+
expect(left).toBeGreaterThanOrEqual(328);
|
|
137
|
+
// Right edge (= left) must not overflow the viewport right.
|
|
138
|
+
expect(left).toBeLessThanOrEqual(window.innerWidth - 8);
|
|
139
|
+
// Top edge must be within the viewport.
|
|
140
|
+
expect(top).toBeGreaterThanOrEqual(8);
|
|
141
|
+
expect(top + 140).toBeLessThanOrEqual(window.innerHeight - 8);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('auto-dismisses the popover on outside click when empty', () => {
|
|
145
|
+
render(
|
|
146
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
147
|
+
);
|
|
148
|
+
openDiscuss();
|
|
149
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).toBeInTheDocument();
|
|
150
|
+
fireEvent.mouseDown(document.body);
|
|
151
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).not.toBeInTheDocument();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not auto-dismiss the popover on outside click when it has typed text', () => {
|
|
155
|
+
render(
|
|
156
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
157
|
+
);
|
|
158
|
+
const ta = openDiscuss();
|
|
159
|
+
fireEvent.change(ta, { target: { value: 'a note' } });
|
|
160
|
+
|
|
161
|
+
// Outside click must NOT close a popover that has typed text.
|
|
162
|
+
fireEvent.mouseDown(document.body);
|
|
163
|
+
const still = screen.getByPlaceholderText('Ask about this text…') as HTMLTextAreaElement;
|
|
164
|
+
expect(still).toBeInTheDocument();
|
|
165
|
+
expect(still.value).toBe('a note');
|
|
166
|
+
|
|
167
|
+
// The X button closes explicitly regardless of content.
|
|
168
|
+
fireEvent.click(document.querySelector('.thread-create-close') as HTMLElement);
|
|
169
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).not.toBeInTheDocument();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('closes the popover on a single Esc when empty', () => {
|
|
173
|
+
render(
|
|
174
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
175
|
+
);
|
|
176
|
+
const ta = openDiscuss();
|
|
177
|
+
fireEvent.keyDown(ta, { key: 'Escape' });
|
|
178
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).not.toBeInTheDocument();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('requires double Esc to close the popover when it has typed text', () => {
|
|
182
|
+
render(
|
|
183
|
+
<CommentableText itemId="i1" turnId="t1" sessionId="s1" content={CONTENT} threads={[]} />,
|
|
184
|
+
);
|
|
185
|
+
const ta = openDiscuss();
|
|
186
|
+
fireEvent.change(ta, { target: { value: 'a note' } });
|
|
187
|
+
|
|
188
|
+
// First Esc: protected — must not close.
|
|
189
|
+
fireEvent.keyDown(ta, { key: 'Escape' });
|
|
190
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).toBeInTheDocument();
|
|
191
|
+
|
|
192
|
+
// Second Esc within the window: closes.
|
|
193
|
+
fireEvent.keyDown(ta, { key: 'Escape' });
|
|
194
|
+
expect(screen.queryByPlaceholderText('Ask about this text…')).not.toBeInTheDocument();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState, useCallback } from 'react';
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState, useCallback } from 'react';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import DOMPurify from 'dompurify';
|
|
4
4
|
import { MessageSquarePlus, X, Send, Quote } from 'lucide-react';
|
|
@@ -93,6 +93,11 @@ interface Props {
|
|
|
93
93
|
export default function CommentableText({ itemId, turnId, sessionId, content, threads }: Props) {
|
|
94
94
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
95
95
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
96
|
+
const popoverRef = useRef<HTMLDivElement>(null);
|
|
97
|
+
// Refs to read the current message and Esc timing from stable-closure
|
|
98
|
+
// handlers (handleGlobalMouseDown / handleMouseDown are bound with empty deps).
|
|
99
|
+
const messageRef = useRef('');
|
|
100
|
+
const lastEscRef = useRef(0);
|
|
96
101
|
const [showDiscussBtn, setShowDiscussBtn] = useState(false);
|
|
97
102
|
const [btnPos, setBtnPos] = useState({ x: 0, y: 0 });
|
|
98
103
|
const [showPopover, setShowPopover] = useState(false);
|
|
@@ -119,54 +124,103 @@ export default function CommentableText({ itemId, turnId, sessionId, content, th
|
|
|
119
124
|
}
|
|
120
125
|
});
|
|
121
126
|
|
|
127
|
+
// Keep messageRef in sync so the stable-closure dismiss handlers can read
|
|
128
|
+
// the current message without re-subscribing on every keystroke.
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
messageRef.current = message;
|
|
131
|
+
}, [message]);
|
|
132
|
+
|
|
122
133
|
// Dismiss button + popover when clicking outside the wrapper
|
|
123
134
|
useEffect(() => {
|
|
124
135
|
function handleGlobalMouseDown(e: MouseEvent) {
|
|
125
136
|
if (wrapperRef.current && !wrapperRef.current.contains(e.target as Node)) {
|
|
126
137
|
setShowDiscussBtn(false);
|
|
127
|
-
|
|
138
|
+
// Don't auto-dismiss a popover that has typed text — require Esc/X.
|
|
139
|
+
if (!messageRef.current.trim()) {
|
|
140
|
+
setShowPopover(false);
|
|
141
|
+
}
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
144
|
document.addEventListener('mousedown', handleGlobalMouseDown);
|
|
131
145
|
return () => document.removeEventListener('mousedown', handleGlobalMouseDown);
|
|
132
146
|
}, []);
|
|
133
147
|
|
|
134
|
-
// Handle mousedown in container — hide everything (new selection starting or click)
|
|
148
|
+
// Handle mousedown in container — hide everything (new selection starting or click).
|
|
149
|
+
// Protect a popover that has typed text: only auto-close when it's empty.
|
|
135
150
|
const handleMouseDown = useCallback(() => {
|
|
136
151
|
setShowDiscussBtn(false);
|
|
137
|
-
|
|
152
|
+
if (!messageRef.current.trim()) {
|
|
153
|
+
setShowPopover(false);
|
|
154
|
+
}
|
|
138
155
|
}, []);
|
|
139
156
|
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
// Check the current text selection within the container and position the
|
|
158
|
+
// floating Discuss/Quote buttons. Direction-aware (handles backward
|
|
159
|
+
// selections) and clamps into the viewport so the buttons stay visible.
|
|
160
|
+
const checkSelection = useCallback(() => {
|
|
143
161
|
const container = containerRef.current;
|
|
144
162
|
if (!container) return;
|
|
145
163
|
|
|
146
164
|
const result = getSelectionOffsets(container);
|
|
147
165
|
if (result && result.text.trim().length > 0) {
|
|
148
166
|
const sel = window.getSelection();
|
|
149
|
-
if (sel && sel.rangeCount > 0) {
|
|
167
|
+
if (sel && sel.rangeCount > 0 && sel.anchorNode && sel.focusNode) {
|
|
168
|
+
const range = sel.getRangeAt(0);
|
|
150
169
|
// Use viewport coordinates (position:fixed) — avoids overflow clipping
|
|
151
170
|
// and stacking-context issues from nested containers.
|
|
152
|
-
const selRect =
|
|
171
|
+
const selRect = range.getBoundingClientRect();
|
|
153
172
|
const BUTTON_HEIGHT = 28;
|
|
154
173
|
const GAP = 6;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
174
|
+
const BUTTON_WIDTH_EST = 170;
|
|
175
|
+
|
|
176
|
+
// Detect backward selection: compare anchor (press) and focus (release)
|
|
177
|
+
// endpoints in document order. anchor after focus => user dragged
|
|
178
|
+
// backwards, so the release point is at the start/left of the text.
|
|
179
|
+
let backward = false;
|
|
180
|
+
try {
|
|
181
|
+
const fr = document.createRange();
|
|
182
|
+
fr.setStart(sel.focusNode, sel.focusOffset);
|
|
183
|
+
fr.setEnd(sel.focusNode, sel.focusOffset);
|
|
184
|
+
const ar = document.createRange();
|
|
185
|
+
ar.setStart(sel.anchorNode, sel.anchorOffset);
|
|
186
|
+
ar.setEnd(sel.anchorNode, sel.anchorOffset);
|
|
187
|
+
backward = ar.compareBoundaryPoints(Range.START_TO_START, fr) > 0;
|
|
188
|
+
} catch {
|
|
189
|
+
backward = false;
|
|
158
190
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
191
|
+
|
|
192
|
+
let btnY = selRect.top - BUTTON_HEIGHT - GAP;
|
|
193
|
+
if (btnY < 8) btnY = selRect.bottom + GAP;
|
|
194
|
+
|
|
195
|
+
// Anchor near the release end and keep the whole bar on-screen.
|
|
196
|
+
let btnX = backward ? selRect.left - BUTTON_WIDTH_EST : selRect.right;
|
|
197
|
+
btnX = Math.max(8, Math.min(btnX, window.innerWidth - BUTTON_WIDTH_EST - 8));
|
|
198
|
+
|
|
199
|
+
setBtnPos({ x: btnX, y: btnY });
|
|
163
200
|
setShowDiscussBtn(true);
|
|
164
201
|
setSelectionInfo(result);
|
|
165
202
|
}
|
|
166
203
|
} else {
|
|
167
204
|
setShowDiscussBtn(false);
|
|
168
205
|
}
|
|
169
|
-
}, [
|
|
206
|
+
}, []);
|
|
207
|
+
|
|
208
|
+
// Detect text selections on mouseup anywhere in the document — not just
|
|
209
|
+
// inside the container. When dragging a selection backwards to a line
|
|
210
|
+
// start, the mouse is frequently released in the surrounding padding/gutter
|
|
211
|
+
// (outside the container element), which would otherwise miss a container-
|
|
212
|
+
// bound onMouseUp and never show the quote button.
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
function onDocMouseUp(e: MouseEvent) {
|
|
215
|
+
const t = e.target as HTMLElement | null;
|
|
216
|
+
// Ignore clicks on our own floating buttons/popover — their handlers
|
|
217
|
+
// manage state and may clear the selection themselves.
|
|
218
|
+
if (t && (t.closest('.selection-actions') || t.closest('.thread-create-popover'))) return;
|
|
219
|
+
checkSelection();
|
|
220
|
+
}
|
|
221
|
+
document.addEventListener('mouseup', onDocMouseUp);
|
|
222
|
+
return () => document.removeEventListener('mouseup', onDocMouseUp);
|
|
223
|
+
}, [checkSelection]);
|
|
170
224
|
|
|
171
225
|
// Handle Discuss button click
|
|
172
226
|
const handleDiscussClick = useCallback(() => {
|
|
@@ -176,6 +230,29 @@ export default function CommentableText({ itemId, turnId, sessionId, content, th
|
|
|
176
230
|
setPopoverPos({ x: btnPos.x, y: btnPos.y });
|
|
177
231
|
}, [btnPos]);
|
|
178
232
|
|
|
233
|
+
// Clamp the discuss popover into the viewport once it mounts. The popover
|
|
234
|
+
// uses `transform: translateX(-100%)`, so its visible right edge sits at
|
|
235
|
+
// `left` and it opens to the LEFT. For backward selections the button is
|
|
236
|
+
// anchored near the left edge, which would push the (wider) popover off the
|
|
237
|
+
// left side; for selections near the top it would overflow above. Measure
|
|
238
|
+
// the real size and reposition before paint (no flash).
|
|
239
|
+
useLayoutEffect(() => {
|
|
240
|
+
if (!showPopover) return;
|
|
241
|
+
const el = popoverRef.current;
|
|
242
|
+
if (!el) return;
|
|
243
|
+
const w = el.offsetWidth;
|
|
244
|
+
const h = el.offsetHeight;
|
|
245
|
+
const MARGIN = 8;
|
|
246
|
+
// Visible box is [x - w, x] horizontally (translateX(-100%)) and [y, y + h] vertically.
|
|
247
|
+
let x = btnPos.x;
|
|
248
|
+
let y = btnPos.y;
|
|
249
|
+
if (x - w < MARGIN) x = w + MARGIN; // would overflow left → shift right
|
|
250
|
+
if (x > window.innerWidth - MARGIN) x = window.innerWidth - MARGIN; // overflow right
|
|
251
|
+
if (y < MARGIN) y = MARGIN; // overflow top
|
|
252
|
+
if (y + h > window.innerHeight - MARGIN) y = window.innerHeight - h - MARGIN; // overflow bottom
|
|
253
|
+
setPopoverPos({ x, y });
|
|
254
|
+
}, [showPopover, btnPos]);
|
|
255
|
+
|
|
179
256
|
// Handle submit — create thread
|
|
180
257
|
const handleSubmit = useCallback(async () => {
|
|
181
258
|
if (!selectionInfo || !message.trim()) return;
|
|
@@ -224,7 +301,6 @@ export default function CommentableText({ itemId, turnId, sessionId, content, th
|
|
|
224
301
|
ref={containerRef}
|
|
225
302
|
dangerouslySetInnerHTML={{ __html: renderMarkdown(content || '…') }}
|
|
226
303
|
onMouseDown={handleMouseDown}
|
|
227
|
-
onMouseUp={handleMouseUp}
|
|
228
304
|
onClick={handleMarkClick}
|
|
229
305
|
/>
|
|
230
306
|
|
|
@@ -252,7 +328,7 @@ export default function CommentableText({ itemId, turnId, sessionId, content, th
|
|
|
252
328
|
|
|
253
329
|
{/* Thread creation popover */}
|
|
254
330
|
{showPopover && (
|
|
255
|
-
<div className="thread-create-popover" style={{ left: popoverPos.x, top: popoverPos.y }}>
|
|
331
|
+
<div ref={popoverRef} className="thread-create-popover" style={{ left: popoverPos.x, top: popoverPos.y }}>
|
|
256
332
|
<div className="thread-create-header">
|
|
257
333
|
<span className="thread-create-quote">"{selectionInfo?.text.slice(0, 80)}{selectionInfo && selectionInfo.text.length > 80 ? '…' : ''}"</span>
|
|
258
334
|
<button className="thread-create-close" onClick={() => { setShowPopover(false); setSelectionInfo(null); }}>
|
|
@@ -272,8 +348,20 @@ export default function CommentableText({ itemId, turnId, sessionId, content, th
|
|
|
272
348
|
handleSubmit();
|
|
273
349
|
}
|
|
274
350
|
if (e.key === 'Escape') {
|
|
275
|
-
|
|
276
|
-
|
|
351
|
+
if (messageRef.current.trim()) {
|
|
352
|
+
// Protect typed text: require a second Esc within 400ms to close.
|
|
353
|
+
const now = Date.now();
|
|
354
|
+
if (lastEscRef.current && now - lastEscRef.current < 400) {
|
|
355
|
+
lastEscRef.current = 0;
|
|
356
|
+
setShowPopover(false);
|
|
357
|
+
setSelectionInfo(null);
|
|
358
|
+
} else {
|
|
359
|
+
lastEscRef.current = now;
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
setShowPopover(false);
|
|
363
|
+
setSelectionInfo(null);
|
|
364
|
+
}
|
|
277
365
|
}
|
|
278
366
|
}}
|
|
279
367
|
/>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { render, cleanup, act } from '@testing-library/react';
|
|
3
|
+
import IdeWorkspace from './IdeWorkspace.tsx';
|
|
4
|
+
import { resetStore } from '../test/component-helpers.ts';
|
|
5
|
+
import { useStore } from '../store/store.ts';
|
|
6
|
+
|
|
7
|
+
describe('IdeWorkspace', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
resetStore();
|
|
10
|
+
});
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
cleanup();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders two resize handles (left & right)', () => {
|
|
16
|
+
render(<IdeWorkspace />);
|
|
17
|
+
const handles = document.querySelectorAll('.resize-handle');
|
|
18
|
+
expect(handles).toHaveLength(2);
|
|
19
|
+
expect(handles[0].className).toContain('left');
|
|
20
|
+
expect(handles[1].className).toContain('right');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('applies a 5-track grid reflecting store widths', () => {
|
|
24
|
+
resetStore({ sidebarWidth: 200, rightPanelWidth: 400 });
|
|
25
|
+
render(<IdeWorkspace />);
|
|
26
|
+
const layout = document.querySelector('.ide-layout') as HTMLElement;
|
|
27
|
+
expect(layout.style.gridTemplateColumns).toBe('200px 6px 1fr 6px 400px');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('updates grid when store widths change', () => {
|
|
31
|
+
render(<IdeWorkspace />);
|
|
32
|
+
act(() => {
|
|
33
|
+
useStore.getState().setSidebarWidth(180);
|
|
34
|
+
useStore.getState().setRightPanelWidth(500);
|
|
35
|
+
});
|
|
36
|
+
const layout = document.querySelector('.ide-layout') as HTMLElement;
|
|
37
|
+
expect(layout.style.gridTemplateColumns).toBe('180px 6px 1fr 6px 500px');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -4,12 +4,31 @@ import RenderArea from './RenderArea.tsx';
|
|
|
4
4
|
import CommandInputBar from './CommandInputBar.tsx';
|
|
5
5
|
import RightPanel from './RightPanel.tsx';
|
|
6
6
|
import StatusBar from './StatusBar.tsx';
|
|
7
|
+
import ResizeHandle from './ResizeHandle.tsx';
|
|
8
|
+
import { useStore } from '../store/store.ts';
|
|
9
|
+
import { SIDEBAR_MIN, SIDEBAR_MAX, RIGHT_PANEL_MIN, RIGHT_PANEL_MAX } from '../store/uiSlice.ts';
|
|
7
10
|
|
|
8
11
|
export default function IdeWorkspace() {
|
|
12
|
+
const sidebarWidth = useStore((s) => s.sidebarWidth);
|
|
13
|
+
const rightPanelWidth = useStore((s) => s.rightPanelWidth);
|
|
14
|
+
const setSidebarWidth = useStore((s) => s.setSidebarWidth);
|
|
15
|
+
const setRightPanelWidth = useStore((s) => s.setRightPanelWidth);
|
|
16
|
+
|
|
17
|
+
// 5 grid columns: sidebar | handle | center | handle | right panel.
|
|
18
|
+
// Handles occupy a 6px track each; center stays 1fr so it absorbs slack.
|
|
19
|
+
const gridTemplateColumns = `${sidebarWidth}px 6px 1fr 6px ${rightPanelWidth}px`;
|
|
20
|
+
|
|
9
21
|
return (
|
|
10
22
|
<div className="ide-root">
|
|
11
|
-
<div className="ide-layout">
|
|
23
|
+
<div className="ide-layout" style={{ gridTemplateColumns }}>
|
|
12
24
|
<WorkspaceSidebar />
|
|
25
|
+
<ResizeHandle
|
|
26
|
+
side="left"
|
|
27
|
+
minWidth={SIDEBAR_MIN}
|
|
28
|
+
maxWidth={SIDEBAR_MAX}
|
|
29
|
+
getWidth={() => useStore.getState().sidebarWidth}
|
|
30
|
+
setWidth={setSidebarWidth}
|
|
31
|
+
/>
|
|
13
32
|
<div className="ide-center">
|
|
14
33
|
<SessionTabs />
|
|
15
34
|
<div className="ide-render">
|
|
@@ -17,9 +36,16 @@ export default function IdeWorkspace() {
|
|
|
17
36
|
</div>
|
|
18
37
|
<CommandInputBar />
|
|
19
38
|
</div>
|
|
39
|
+
<ResizeHandle
|
|
40
|
+
side="right"
|
|
41
|
+
minWidth={RIGHT_PANEL_MIN}
|
|
42
|
+
maxWidth={RIGHT_PANEL_MAX}
|
|
43
|
+
getWidth={() => useStore.getState().rightPanelWidth}
|
|
44
|
+
setWidth={setRightPanelWidth}
|
|
45
|
+
/>
|
|
20
46
|
<RightPanel />
|
|
21
47
|
</div>
|
|
22
48
|
<StatusBar />
|
|
23
49
|
</div>
|
|
24
50
|
);
|
|
25
|
-
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useResizable, type ResizeSide } from '../hooks/useResizable.ts';
|
|
2
|
+
|
|
3
|
+
interface ResizeHandleProps {
|
|
4
|
+
side: ResizeSide;
|
|
5
|
+
minWidth: number;
|
|
6
|
+
maxWidth: number;
|
|
7
|
+
getWidth: () => number;
|
|
8
|
+
setWidth: (w: number) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Thin draggable gutter rendered as its own CSS grid track. Sits between a
|
|
13
|
+
* sidebar and the center pane. Dragging adjusts the adjacent sidebar width.
|
|
14
|
+
*/
|
|
15
|
+
export default function ResizeHandle({ side, minWidth, maxWidth, getWidth, setWidth }: ResizeHandleProps) {
|
|
16
|
+
const { onPointerDown, dragging } = useResizable({ side, minWidth, maxWidth, getWidth, setWidth });
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
className={`resize-handle ${side}${dragging ? ' dragging' : ''}`}
|
|
21
|
+
onPointerDown={onPointerDown}
|
|
22
|
+
// Gutter shouldn't catch content scroll / text selection; keyboard a11y is non-goal here.
|
|
23
|
+
role="separator"
|
|
24
|
+
aria-orientation="vertical"
|
|
25
|
+
aria-label={`Resize ${side} panel`}
|
|
26
|
+
data-resizing={dragging ? '' : undefined}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -98,7 +98,7 @@ function ThreadCard({
|
|
|
98
98
|
setShowQuoteBtn(false);
|
|
99
99
|
}, []);
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const checkSelection = useCallback(() => {
|
|
102
102
|
const container = conversationRef.current;
|
|
103
103
|
if (!container) return;
|
|
104
104
|
const sel = window.getSelection();
|
|
@@ -128,13 +128,46 @@ function ThreadCard({
|
|
|
128
128
|
const selRect = range.getBoundingClientRect();
|
|
129
129
|
const BUTTON_HEIGHT = 28;
|
|
130
130
|
const GAP = 6;
|
|
131
|
+
const BUTTON_WIDTH_EST = 170;
|
|
132
|
+
|
|
133
|
+
// Detect backward selection via anchor (press) vs focus (release) order.
|
|
134
|
+
let backward = false;
|
|
135
|
+
if (sel.anchorNode && sel.focusNode) {
|
|
136
|
+
try {
|
|
137
|
+
const fr = document.createRange();
|
|
138
|
+
fr.setStart(sel.focusNode, sel.focusOffset);
|
|
139
|
+
fr.setEnd(sel.focusNode, sel.focusOffset);
|
|
140
|
+
const ar = document.createRange();
|
|
141
|
+
ar.setStart(sel.anchorNode, sel.anchorOffset);
|
|
142
|
+
ar.setEnd(sel.anchorNode, sel.anchorOffset);
|
|
143
|
+
backward = ar.compareBoundaryPoints(Range.START_TO_START, fr) > 0;
|
|
144
|
+
} catch {
|
|
145
|
+
backward = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
131
149
|
let btnY = selRect.top - BUTTON_HEIGHT - GAP;
|
|
132
150
|
if (btnY < 8) btnY = selRect.bottom + GAP;
|
|
133
|
-
|
|
151
|
+
let btnX = backward ? selRect.left - BUTTON_WIDTH_EST : selRect.right;
|
|
152
|
+
btnX = Math.max(8, Math.min(btnX, window.innerWidth - BUTTON_WIDTH_EST - 8));
|
|
153
|
+
setQuoteBtnPos({ x: btnX, y: btnY });
|
|
134
154
|
setSelectedText(text);
|
|
135
155
|
setShowQuoteBtn(true);
|
|
136
156
|
}, []);
|
|
137
157
|
|
|
158
|
+
// Detect selections on mouseup anywhere in the document so that releasing
|
|
159
|
+
// the mouse in the surrounding padding (common with backward drags) still
|
|
160
|
+
// registers the quote button.
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
function onDocMouseUp(e: MouseEvent) {
|
|
163
|
+
const t = e.target as HTMLElement | null;
|
|
164
|
+
if (t && t.closest('.selection-actions')) return;
|
|
165
|
+
checkSelection();
|
|
166
|
+
}
|
|
167
|
+
document.addEventListener('mouseup', onDocMouseUp);
|
|
168
|
+
return () => document.removeEventListener('mouseup', onDocMouseUp);
|
|
169
|
+
}, [checkSelection]);
|
|
170
|
+
|
|
138
171
|
const handleQuoteClick = useCallback(() => {
|
|
139
172
|
const formatted = `\n\`\`\`QUOTE\n${selectedText}\n\`\`\`\n\n`;
|
|
140
173
|
setFollowup((prev) => prev + formatted);
|
|
@@ -180,7 +213,6 @@ function ThreadCard({
|
|
|
180
213
|
className="thread-card-conversation"
|
|
181
214
|
ref={conversationRef}
|
|
182
215
|
onMouseDown={handleConversationMouseDown}
|
|
183
|
-
onMouseUp={handleConversationMouseUp}
|
|
184
216
|
>
|
|
185
217
|
{threadTurns.map((turn) => (
|
|
186
218
|
<ThreadTurnView key={turn.id} turn={turn} />
|
|
@@ -94,6 +94,43 @@ export const PROVIDERS: ProviderDef[] = [
|
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
id: 'repoburg',
|
|
99
|
+
label: 'Repoburg',
|
|
100
|
+
available: true,
|
|
101
|
+
// Curated fallback list — live sessions load the full catalog dynamically
|
|
102
|
+
// from GET /api/providers/repoburg/models (repoburg backend model registry).
|
|
103
|
+
models: [
|
|
104
|
+
{
|
|
105
|
+
slug: 'ollama/glm-5.3:cloud',
|
|
106
|
+
displayName: 'GLM-5.3',
|
|
107
|
+
description: 'Ollama Cloud',
|
|
108
|
+
defaultReasoning: 'medium',
|
|
109
|
+
reasoningLevels: [LEVELS.low, LEVELS.medium, LEVELS.high],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
slug: 'ollama/glm-5.3-flash:cloud',
|
|
113
|
+
displayName: 'GLM-5.3 Flash',
|
|
114
|
+
description: 'Ollama Cloud — fast',
|
|
115
|
+
defaultReasoning: 'medium',
|
|
116
|
+
reasoningLevels: [LEVELS.low, LEVELS.medium, LEVELS.high],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
slug: 'ollama/minimax-m3:cloud',
|
|
120
|
+
displayName: 'MiniMax M3',
|
|
121
|
+
description: 'Ollama Cloud',
|
|
122
|
+
defaultReasoning: 'medium',
|
|
123
|
+
reasoningLevels: [LEVELS.low, LEVELS.medium, LEVELS.high],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
slug: 'ollama/deepseek-v4-pro:cloud',
|
|
127
|
+
displayName: 'DeepSeek V4 Pro',
|
|
128
|
+
description: 'Ollama Cloud',
|
|
129
|
+
defaultReasoning: 'medium',
|
|
130
|
+
reasoningLevels: [LEVELS.low, LEVELS.medium, LEVELS.high],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
97
134
|
];
|
|
98
135
|
|
|
99
136
|
/** Get provider by ID. */
|