cdpearlman Cursor commited on
Commit
718dfcb
·
1 Parent(s): 78691d1

Add drag-to-resize on chat window left edge

Browse files

Co-authored-by: Cursor <cursoragent@cursor.com>

Files changed (5) hide show
  1. assets/chat_resize.js +54 -0
  2. assets/style.css +15 -0
  3. components/chatbot.py +1 -0
  4. plans.md +11 -5
  5. todo.md +7 -0
assets/chat_resize.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Drag-to-resize for the chat window's left edge
2
+ document.addEventListener("DOMContentLoaded", function () {
3
+ var handle = null;
4
+ var chatWindow = null;
5
+ var startX = 0;
6
+ var startWidth = 0;
7
+
8
+ function initResize(e) {
9
+ chatWindow = document.getElementById("chat-window");
10
+ if (!chatWindow) return;
11
+ handle = document.getElementById("chat-resize-handle");
12
+ startX = e.clientX;
13
+ startWidth = chatWindow.getBoundingClientRect().width;
14
+ if (handle) handle.classList.add("active");
15
+ document.addEventListener("mousemove", doResize);
16
+ document.addEventListener("mouseup", stopResize);
17
+ e.preventDefault();
18
+ }
19
+
20
+ function doResize(e) {
21
+ if (!chatWindow) return;
22
+ // Dragging left increases width (panel anchored to right)
23
+ var newWidth = startWidth + (startX - e.clientX);
24
+ var minW = 320;
25
+ var maxW = window.innerWidth * 0.8;
26
+ newWidth = Math.max(minW, Math.min(maxW, newWidth));
27
+ chatWindow.style.width = newWidth + "px";
28
+ chatWindow.style.maxWidth = "none";
29
+ }
30
+
31
+ function stopResize() {
32
+ if (handle) handle.classList.remove("active");
33
+ document.removeEventListener("mousemove", doResize);
34
+ document.removeEventListener("mouseup", stopResize);
35
+ chatWindow = null;
36
+ }
37
+
38
+ // Use MutationObserver to attach listener whenever the handle appears
39
+ var observer = new MutationObserver(function () {
40
+ var h = document.getElementById("chat-resize-handle");
41
+ if (h && !h._resizeInit) {
42
+ h.addEventListener("mousedown", initResize);
43
+ h._resizeInit = true;
44
+ }
45
+ });
46
+ observer.observe(document.body, { childList: true, subtree: true });
47
+
48
+ // Also try binding immediately in case element already exists
49
+ var h = document.getElementById("chat-resize-handle");
50
+ if (h) {
51
+ h.addEventListener("mousedown", initResize);
52
+ h._resizeInit = true;
53
+ }
54
+ });
assets/style.css CHANGED
@@ -1126,6 +1126,21 @@ details[open].transformer-layers-container .transformer-layers-summary::before {
1126
  animation: slideInRight 0.3s ease-out;
1127
  }
1128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129
  @keyframes slideInRight {
1130
  from {
1131
  transform: translateX(100%);
 
1126
  animation: slideInRight 0.3s ease-out;
1127
  }
1128
 
1129
+ /* Drag handle on left edge of chat window for resizing */
1130
+ .chat-resize-handle {
1131
+ position: absolute;
1132
+ top: 0;
1133
+ left: 0;
1134
+ width: 5px;
1135
+ height: 100%;
1136
+ cursor: ew-resize;
1137
+ z-index: 10;
1138
+ }
1139
+ .chat-resize-handle:hover,
1140
+ .chat-resize-handle.active {
1141
+ background-color: rgba(59, 130, 246, 0.5);
1142
+ }
1143
+
1144
  @keyframes slideInRight {
1145
  from {
1146
  transform: translateX(100%);
components/chatbot.py CHANGED
@@ -183,6 +183,7 @@ def create_chat_window():
183
  Dash HTML component for the chat window
184
  """
185
  return html.Div([
 
186
  create_chat_header(),
187
  create_messages_container(),
188
  create_input_area()
 
183
  Dash HTML component for the chat window
184
  """
185
  return html.Div([
186
+ html.Div(className="chat-resize-handle", id="chat-resize-handle"),
187
  create_chat_header(),
188
  create_messages_container(),
189
  create_input_area()
plans.md CHANGED
@@ -1,5 +1,11 @@
1
- Worktree Ideas:
2
- - host on a website
3
- - add AI bot to help
4
- - AI bot worked examples ("Ask me how to ...")
5
- - animated "learning mode"?
 
 
 
 
 
 
 
1
+ - specs on what each attention head does
2
+ - change attention to entire generated sequence
3
+ - output slider to look at each token
4
+ - put in a more obvious place?
5
+ - experiment results side by side comparison
6
+ - output streaming for chatbot
7
+ - change width of chatbot window
8
+ - shorter, concise responses in system prompt
9
+ - add video links to glossary
10
+ - three blue one brown
11
+ - add output token generation to attention, tokenization, etc
todo.md CHANGED
@@ -193,3 +193,10 @@
193
  - [x] Delete embeddings_cache.json, update rag_docs/README.md with full inventory
194
  - [x] Update todo.md and conductor docs
195
  - Total: 30 RAG documents covering transformer concepts, dashboard usage, guided experiments, interpretation, troubleshooting, and research context
 
 
 
 
 
 
 
 
193
  - [x] Delete embeddings_cache.json, update rag_docs/README.md with full inventory
194
  - [x] Update todo.md and conductor docs
195
  - Total: 30 RAG documents covering transformer concepts, dashboard usage, guided experiments, interpretation, troubleshooting, and research context
196
+
197
+ ## Completed: Resizable Chat Window
198
+
199
+ - [x] Add drag handle div to left edge of chat window in chatbot.py
200
+ - [x] Add CSS for `.chat-resize-handle` (cursor, hover highlight) in style.css
201
+ - [x] Add `assets/chat_resize.js` for mousedown/mousemove/mouseup drag logic
202
+ - Default size unchanged (25vw, 320px–450px); drag overrides max-width up to 80vw