Commit 4383639
authored
Fix Terminal Jump Focus + FocusCapability Refactor (#308)
* [bug] terminal jump (R-J) now properly steals focus
The R-J command (cmd+r cmd+j) was not actually jumping to the terminal - it showed
the terminal panel but kept focus in the editor. This was due to `terminal.show(true)`
which preserves focus instead of stealing it.
Changed to use `ideAdapter.showTerminal(terminal, TerminalFocusType.StealFocus)` for
consistency with other terminal operations and correct focus behavior.
Benefits:
- R-J command now actually moves focus to the bound terminal
- Consistent use of adapter pattern for terminal focus operations
- Uses existing TerminalFocusType enum for explicit intent
* Fix Terminal Jump Focus + FocusCapability Refactor
This side-quest addresses two related issues:
1. **Bug Fix**: Terminal jump (R-J) was not actually moving focus to the terminal - it showed the terminal panel but kept focus in the editor
2. **Refactor**: Renamed `PasteExecutor` → `FocusCapability` with symmetric `InsertFactory` injection pattern
- Changed `terminal.show(true)` (preserveFocus) to `ideAdapter.showTerminal(terminal, StealFocus)`
- Now R-J properly moves focus to the terminal
- Renamed types for clarity:
- `PasteExecutor` → `FocusCapability` (emphasizes what it does: focus destinations)
- `FocusSuccess` → `FocusedDestination` (a handle to something focused)
- `CommandPasteExecutor` → `AIAssistantFocusCapability` (domain concept, not implementation)
- Extracted `InsertFactory<T>` interface with class implementations:
- `TerminalInsertFactory` - pastes via clipboard to terminal
- `EditorInsertFactory` - inserts text at cursor
- `AIAssistantInsertFactory` - clipboard paste with command execution
- Made implementations symmetric:
- Both Editor and Terminal capabilities now receive `InsertFactory` as constructor dependency
- Both call `factory.forTarget(target)` to create insert functions
- AI assistant uses `forTarget()` with no argument (void parameter)
```
src/destinations/capabilities/
├── FocusCapability.ts (interface + FocusedDestination + FocusResult)
├── TerminalFocusCapability.ts
├── EditorFocusCapability.ts
├── AIAssistantFocusCapability.ts
├── FocusCapabilityFactory.ts
├── insertFactories/
│ ├── InsertFactory.ts (type definition)
│ ├── terminalInsertFactory.ts
│ ├── editorInsertFactory.ts
│ └── aiAssistantInsertFactory.ts
└── index.ts
```
1. **Clear naming** - Types describe what they do, not how they do it
2. **Symmetry** - All implementations follow same pattern
3. **Testability** - InsertFactory can be mocked in unit tests
4. **Decoupling** - Focus logic separated from insert logic
* Fix `setTimeout()` call
* Add timer methods as global
* [PR feedback] Consolidate test logging, centralize focus constants, fix clipboard error handling
Addresses CodeRabbit review on PR #308. Consolidates standalone logging tests into
behavior tests per T007 rule, removes redundant tests, fixes stale JSDoc, centralizes
AI assistant focus command constants, and adds missing try/catch around clipboard write
in AIAssistantInsertFactory.
Benefits:
- Tests are more focused: logging verified alongside behavior, not in isolation
- Focus command constants colocated in one file instead of split across two
- Clipboard write failure in AI assistant insert is now handled gracefully
Ignored Feedback:
- global.setTimeout replacement: Already fixed in commits 8a05197 and 7f3bc12
Ref: #308 (review)1 parent 9639f28 commit 4383639
File tree
34 files changed
+947
-710
lines changed- packages/rangelink-vscode-extension/src
- __tests__
- destinations
- capabilities
- insertFactories
- helpers
- destinations
- capabilities
- insertFactories
- utils
- __tests__/aiAssistants
- aiAssistants
34 files changed
+947
-710
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
Lines changed: 156 additions & 145 deletions
Large diffs are not rendered by default.
Lines changed: 48 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | | - | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 59 | + | |
| 60 | + | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | | - | |
| 70 | + | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
| |||
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
82 | | - | |
| 80 | + | |
| 81 | + | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
101 | | - | |
| 99 | + | |
| 100 | + | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
| 106 | + | |
| 107 | + | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
| 110 | + | |
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
| |||
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | | - | |
129 | | - | |
| 127 | + | |
| 128 | + | |
130 | 129 | | |
131 | 130 | | |
132 | | - | |
| 131 | + | |
133 | 132 | | |
134 | 133 | | |
135 | 134 | | |
| |||
145 | 144 | | |
146 | 145 | | |
147 | 146 | | |
148 | | - | |
149 | | - | |
| 147 | + | |
| 148 | + | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
154 | | - | |
| 153 | + | |
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
| |||
211 | 210 | | |
212 | 211 | | |
213 | 212 | | |
214 | | - | |
| 213 | + | |
215 | 214 | | |
216 | | - | |
| 215 | + | |
217 | 216 | | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
221 | 220 | | |
222 | 221 | | |
223 | | - | |
| 222 | + | |
224 | 223 | | |
225 | 224 | | |
226 | 225 | | |
| |||
231 | 230 | | |
232 | 231 | | |
233 | 232 | | |
234 | | - | |
235 | | - | |
| 233 | + | |
| 234 | + | |
236 | 235 | | |
237 | 236 | | |
238 | | - | |
| 237 | + | |
239 | 238 | | |
240 | 239 | | |
241 | 240 | | |
242 | 241 | | |
243 | 242 | | |
244 | 243 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 244 | + | |
252 | 245 | | |
253 | 246 | | |
254 | 247 | | |
255 | 248 | | |
256 | 249 | | |
257 | | - | |
| 250 | + | |
258 | 251 | | |
259 | | - | |
| 252 | + | |
260 | 253 | | |
261 | 254 | | |
262 | 255 | | |
263 | 256 | | |
264 | 257 | | |
265 | | - | |
| 258 | + | |
266 | 259 | | |
267 | 260 | | |
268 | 261 | | |
| |||
272 | 265 | | |
273 | 266 | | |
274 | 267 | | |
275 | | - | |
276 | | - | |
| 268 | + | |
| 269 | + | |
277 | 270 | | |
278 | 271 | | |
279 | | - | |
| 272 | + | |
280 | 273 | | |
281 | 274 | | |
282 | 275 | | |
283 | 276 | | |
284 | 277 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 278 | + | |
291 | 279 | | |
292 | 280 | | |
293 | 281 | | |
| |||
303 | 291 | | |
304 | 292 | | |
305 | 293 | | |
306 | | - | |
| 294 | + | |
307 | 295 | | |
308 | 296 | | |
309 | | - | |
| 297 | + | |
310 | 298 | | |
311 | 299 | | |
312 | 300 | | |
313 | 301 | | |
314 | 302 | | |
315 | 303 | | |
316 | | - | |
| 304 | + | |
317 | 305 | | |
318 | 306 | | |
319 | | - | |
320 | | - | |
| 307 | + | |
| 308 | + | |
321 | 309 | | |
322 | | - | |
| 310 | + | |
323 | 311 | | |
324 | 312 | | |
325 | 313 | | |
326 | 314 | | |
327 | 315 | | |
328 | | - | |
329 | | - | |
| 316 | + | |
| 317 | + | |
330 | 318 | | |
331 | 319 | | |
332 | 320 | | |
| |||
341 | 329 | | |
342 | 330 | | |
343 | 331 | | |
344 | | - | |
345 | | - | |
| 332 | + | |
| 333 | + | |
346 | 334 | | |
347 | 335 | | |
348 | 336 | | |
349 | 337 | | |
350 | | - | |
| 338 | + | |
351 | 339 | | |
352 | 340 | | |
353 | 341 | | |
| |||
0 commit comments