File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,36 @@ function Jupyter() {
7
7
8
8
// This is a hack to prevent the editor from overflowing
9
9
// Should be removed after revising the parent and containers
10
+ // Use ResizeObserver to properly track parent width changes
10
11
React . useEffect ( ( ) => {
12
+ let resizeObserver : ResizeObserver | null = null ;
13
+
14
+ resizeObserver = new ResizeObserver ( ( entries ) => {
15
+ for ( const entry of entries ) {
16
+ // Use contentRect.width for more accurate measurements
17
+ const { width } = entry . contentRect ;
18
+ if ( width > 0 ) {
19
+ setParentWidth ( width ) ;
20
+ }
21
+ }
22
+ } ) ;
23
+
11
24
if ( parentRef . current ) {
12
- setParentWidth ( parentRef . current . offsetWidth ) ;
25
+ resizeObserver . observe ( parentRef . current ) ;
13
26
}
27
+
28
+ return ( ) => {
29
+ resizeObserver ?. disconnect ( ) ;
30
+ } ;
14
31
} , [ ] ) ;
15
32
33
+ // Provide a fallback width to prevent the editor from being hidden
34
+ // Use parentWidth if available, otherwise use a large default
35
+ const maxWidth = parentWidth > 0 ? parentWidth : 9999 ;
36
+
16
37
return (
17
38
< div ref = { parentRef } className = "h-full" >
18
- < JupyterEditor maxWidth = { parentWidth } />
39
+ < JupyterEditor maxWidth = { maxWidth } />
19
40
</ div >
20
41
) ;
21
42
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
} from "#/types/message" ;
12
12
import { handleObservationMessage } from "./observations" ;
13
13
import { appendInput } from "#/state/command-slice" ;
14
+ import { appendJupyterInput } from "#/state/jupyter-slice" ;
14
15
import { queryClient } from "#/query-client-config" ;
15
16
16
17
export function handleActionMessage ( message : ActionMessage ) {
@@ -31,6 +32,10 @@ export function handleActionMessage(message: ActionMessage) {
31
32
store . dispatch ( appendInput ( message . args . command ) ) ;
32
33
}
33
34
35
+ if ( message . action === ActionType . RUN_IPYTHON ) {
36
+ store . dispatch ( appendJupyterInput ( message . args . code ) ) ;
37
+ }
38
+
34
39
if ( "args" in message && "security_risk" in message . args ) {
35
40
store . dispatch ( appendSecurityAnalyzerInput ( message ) ) ;
36
41
}
You can’t perform that action at this time.
0 commit comments