@skyhook-io/k8s-ui 1.5.0 → 1.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyhook-io/k8s-ui",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/skyhook-io/radar",
@@ -88,7 +88,7 @@
88
88
  "react": "^19.2.4",
89
89
  "react-dom": "^19.2.4",
90
90
  "typescript": "^6.0.2",
91
- "vitest": "^4.1.4",
91
+ "vitest": "^4.1.5",
92
92
  "yaml": "^2.8.3"
93
93
  }
94
94
  }
@@ -96,6 +96,35 @@ export function LocalTerminalTab({
96
96
  setTimeout(doFit, 100)
97
97
  })
98
98
 
99
+ // Attach ResizeObserver synchronously — before createSession() resolves.
100
+ // The dock's expand animation runs concurrently with session creation, so
101
+ // a late-attached observer would miss its size changes and leave the
102
+ // terminal stuck at whatever dimensions it had when the dock was still
103
+ // collapsing. Debounced to coalesce animation frames.
104
+ let resizeTimeout: ReturnType<typeof setTimeout> | null = null
105
+ let lastWidth = 0
106
+ let lastHeight = 0
107
+ const resizeObserver = new ResizeObserver((entries) => {
108
+ const entry = entries[0]
109
+ if (!entry) return
110
+ const { width, height } = entry.contentRect
111
+ if (Math.abs(width - lastWidth) < 5 && Math.abs(height - lastHeight) < 5) return
112
+ lastWidth = width
113
+ lastHeight = height
114
+ if (resizeTimeout) clearTimeout(resizeTimeout)
115
+ resizeTimeout = setTimeout(() => {
116
+ if (!fitAddonRef.current || !xtermRef.current) return
117
+ const dims = fitAddonRef.current.proposeDimensions()
118
+ if (dims) xtermRef.current.resize(dims.cols, dims.rows)
119
+ const conn = wsRef.current
120
+ if (conn?.readyState === WebSocket.OPEN) {
121
+ conn.send(JSON.stringify({ type: 'resize', rows: xtermRef.current.rows, cols: xtermRef.current.cols }))
122
+ }
123
+ }, 100)
124
+ })
125
+ resizeObserver.observe(terminalRef.current)
126
+ cleanupRef.current = () => resizeObserver.disconnect()
127
+
99
128
  createSessionRef.current()
100
129
  .then(({ wsUrl }) => {
101
130
  if (cancelledRef.current) return
@@ -152,35 +181,6 @@ export function LocalTerminalTab({
152
181
  ws.send(JSON.stringify({ type: 'input', data }))
153
182
  }
154
183
  })
155
-
156
- // Debounced resize
157
- let resizeTimeout: ReturnType<typeof setTimeout> | null = null
158
- let lastWidth = 0
159
- let lastHeight = 0
160
- const resizeObserver = new ResizeObserver((entries) => {
161
- const entry = entries[0]
162
- if (!entry) return
163
- const { width, height } = entry.contentRect
164
- if (Math.abs(width - lastWidth) < 5 && Math.abs(height - lastHeight) < 5) return
165
- lastWidth = width
166
- lastHeight = height
167
- if (resizeTimeout) clearTimeout(resizeTimeout)
168
- resizeTimeout = setTimeout(() => {
169
- if (fitAddonRef.current && xtermRef.current) {
170
- const dims = fitAddonRef.current.proposeDimensions()
171
- if (dims) xtermRef.current.resize(dims.cols, dims.rows)
172
- if (ws.readyState === WebSocket.OPEN) {
173
- ws.send(JSON.stringify({ type: 'resize', rows: xtermRef.current.rows, cols: xtermRef.current.cols }))
174
- }
175
- }
176
- }, 100)
177
- })
178
- if (terminalRef.current) {
179
- resizeObserver.observe(terminalRef.current)
180
- cleanupRef.current = () => resizeObserver.disconnect()
181
- } else {
182
- resizeObserver.disconnect()
183
- }
184
184
  })
185
185
  .catch((err) => {
186
186
  setError(err instanceof Error ? err.message : 'Failed to connect')
@@ -113,6 +113,35 @@ export function TerminalTab({
113
113
  setTimeout(doFit, 100)
114
114
  })
115
115
 
116
+ // Attach ResizeObserver synchronously — before createSession() resolves.
117
+ // The dock's expand animation runs concurrently with session creation, so
118
+ // a late-attached observer would miss its size changes and leave the
119
+ // terminal stuck at whatever dimensions it had when the dock was still
120
+ // collapsing. Debounced to coalesce animation frames.
121
+ let resizeTimeout: ReturnType<typeof setTimeout> | null = null
122
+ let lastWidth = 0
123
+ let lastHeight = 0
124
+ const resizeObserver = new ResizeObserver((entries) => {
125
+ const entry = entries[0]
126
+ if (!entry) return
127
+ const { width, height } = entry.contentRect
128
+ if (Math.abs(width - lastWidth) < 5 && Math.abs(height - lastHeight) < 5) return
129
+ lastWidth = width
130
+ lastHeight = height
131
+ if (resizeTimeout) clearTimeout(resizeTimeout)
132
+ resizeTimeout = setTimeout(() => {
133
+ if (!fitAddonRef.current || !xtermRef.current) return
134
+ const dims = fitAddonRef.current.proposeDimensions()
135
+ if (dims) xtermRef.current.resize(dims.cols, dims.rows)
136
+ const conn = wsRef.current
137
+ if (conn?.readyState === WebSocket.OPEN) {
138
+ conn.send(JSON.stringify({ type: 'resize', rows: xtermRef.current.rows, cols: xtermRef.current.cols }))
139
+ }
140
+ }, 100)
141
+ })
142
+ resizeObserver.observe(terminalRef.current)
143
+ cleanupRef.current = () => resizeObserver.disconnect()
144
+
116
145
  createSessionRef.current(selectedContainer)
117
146
  .then(({ wsUrl }) => {
118
147
  if (cancelledRef.current) return
@@ -163,35 +192,6 @@ export function TerminalTab({
163
192
  ws.send(JSON.stringify({ type: 'input', data }))
164
193
  }
165
194
  })
166
-
167
- // Debounced resize to avoid infinite loops
168
- let resizeTimeout: ReturnType<typeof setTimeout> | null = null
169
- let lastWidth = 0
170
- let lastHeight = 0
171
- const resizeObserver = new ResizeObserver((entries) => {
172
- const entry = entries[0]
173
- if (!entry) return
174
- const { width, height } = entry.contentRect
175
- if (Math.abs(width - lastWidth) < 5 && Math.abs(height - lastHeight) < 5) return
176
- lastWidth = width
177
- lastHeight = height
178
- if (resizeTimeout) clearTimeout(resizeTimeout)
179
- resizeTimeout = setTimeout(() => {
180
- if (fitAddonRef.current && xtermRef.current) {
181
- const dims = fitAddonRef.current.proposeDimensions()
182
- if (dims) xtermRef.current.resize(dims.cols, dims.rows)
183
- if (ws.readyState === WebSocket.OPEN) {
184
- ws.send(JSON.stringify({ type: 'resize', rows: xtermRef.current.rows, cols: xtermRef.current.cols }))
185
- }
186
- }
187
- }, 100)
188
- })
189
- if (terminalRef.current) {
190
- resizeObserver.observe(terminalRef.current)
191
- cleanupRef.current = () => resizeObserver.disconnect()
192
- } else {
193
- resizeObserver.disconnect()
194
- }
195
195
  })
196
196
  .catch((err) => {
197
197
  setError(err instanceof Error ? err.message : 'Failed to connect')