Skip to content

Commit c44922b

Browse files
committed
fix(terminal): compact icon-only tabs and fix kill race condition
Replace tab text with icon-only tabs (close icon on hover) for a narrower tab bar. Fix N-API uncaught exception on terminal close by letting the onExit handler do cleanup instead of racing with killTerminal.
1 parent 64b29c5 commit c44922b

3 files changed

Lines changed: 41 additions & 43 deletions

File tree

src-node/terminal.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,14 @@ exports.createTerminal = async function ({id, shell, args, cwd, cols, rows, env}
156156
});
157157

158158
ptyProcess.onExit(function ({exitCode, signal}) {
159-
// Flush any remaining buffered output
160-
clearTimeout(terminals[id].flushTimer);
161-
terminals[id].flushTimer = null;
162-
_flushBuffer(id);
163-
delete terminals[id];
159+
const exitingTerm = terminals[id];
160+
if (exitingTerm) {
161+
// Flush any remaining buffered output
162+
clearTimeout(exitingTerm.flushTimer);
163+
exitingTerm.flushTimer = null;
164+
_flushBuffer(id);
165+
delete terminals[id];
166+
}
164167
nodeConnector.triggerPeer("terminalExit", {id, exitCode, signal});
165168
});
166169

@@ -211,6 +214,7 @@ exports.killTerminal = async function ({id}) {
211214
if (!term) {
212215
return {ok: true}; // already dead
213216
}
217+
// Just kill the process; the onExit handler will clean up the terminal entry
214218
try {
215219
if (process.platform === "win32") {
216220
// On Windows, use taskkill for process tree kill
@@ -224,13 +228,11 @@ exports.killTerminal = async function ({id}) {
224228
term.pty.kill();
225229
}
226230
} catch (e) {
227-
// Process may already be dead
231+
// Process may already be dead — ensure cleanup still happens
232+
clearTimeout(term.flushTimer);
233+
term.flushTimer = null;
234+
delete terminals[id];
228235
}
229-
// Clean up
230-
clearTimeout(term.flushTimer);
231-
term.flushTimer = null;
232-
_flushBuffer(id);
233-
delete terminals[id];
234236
return {ok: true};
235237
};
236238

src/extensionsIntegrated/Terminal/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ define(function (require, exports, module) {
226226
function _createTab(instance) {
227227
const $tab = $('<div class="terminal-tab" data-terminal-id="' + instance.id + '" title="' + _escapeHtml(instance.title) + '">' +
228228
'<i class="fa-solid fa-terminal terminal-tab-icon"></i>' +
229-
'<span class="terminal-tab-name">' + _escapeHtml(instance.title) + '</span>' +
230229
'<span class="terminal-tab-close"><i class="fa-solid fa-xmark"></i></span>' +
231230
'</div>');
232231

@@ -331,7 +330,6 @@ define(function (require, exports, module) {
331330
*/
332331
function _onTerminalTitleChanged(id, title) {
333332
const $tab = $tabsList.find('.terminal-tab[data-terminal-id="' + id + '"]');
334-
$tab.find(".terminal-tab-name").text(title);
335333
$tab.attr("title", title);
336334
}
337335

src/styles/Extn-Terminal.less

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@
9292
.terminal-new-dropdown-wrapper {
9393
position: relative;
9494
display: flex;
95-
flex-direction: row;
95+
flex-direction: column;
9696
border-top: 1px solid var(--terminal-border);
9797
}
9898

9999
.terminal-shell-dropdown {
100100
position: absolute;
101-
bottom: 100%;
102-
left: 0;
101+
bottom: 0;
102+
right: 100%;
103103
min-width: 180px;
104104
background: var(--terminal-tab-bg);
105105
border: 1px solid var(--terminal-border);
@@ -150,31 +150,35 @@
150150
.terminal-tab-bar {
151151
display: flex;
152152
flex-direction: column;
153-
width: 80px;
154-
min-width: 80px;
153+
width: 30px;
154+
min-width: 30px;
155155
background: var(--terminal-tab-bg);
156156
border-left: 1px solid var(--terminal-border);
157-
overflow-y: auto;
158-
overflow-x: hidden;
157+
overflow: hidden;
159158
}
160159

161160
.terminal-tabs-list {
162161
flex: 1;
162+
min-height: 0;
163+
display: flex;
164+
flex-direction: column;
163165
overflow-y: auto;
166+
overflow-x: hidden;
164167
}
165168

166169
.terminal-tab {
170+
position: relative;
167171
display: flex;
168172
align-items: center;
169-
padding: 6px 8px;
173+
justify-content: center;
174+
width: 31px;
175+
height: 28px;
176+
min-height: 28px;
170177
cursor: pointer;
171178
color: var(--terminal-tab-text);
172-
font-size: 12px;
173179
border-left: 2px solid transparent;
174180
user-select: none;
175-
white-space: nowrap;
176-
overflow: hidden;
177-
text-overflow: ellipsis;
181+
box-sizing: border-box;
178182
}
179183

180184
.terminal-tab:hover {
@@ -188,36 +192,31 @@
188192
}
189193

190194
.terminal-tab .terminal-tab-icon {
191-
display: none;
192-
}
193-
194-
.terminal-tab .terminal-tab-name {
195-
flex: 1;
196-
overflow: hidden;
197-
text-overflow: ellipsis;
195+
font-size: 11px;
196+
line-height: 1;
198197
}
199198

200199
.terminal-tab .terminal-tab-close {
201-
opacity: 0;
202-
margin-left: 4px;
203-
font-size: 10px;
204-
padding: 2px 4px;
205-
border-radius: 3px;
200+
display: none;
201+
font-size: 14px;
206202
color: var(--terminal-tab-text);
203+
line-height: 1;
204+
}
205+
206+
.terminal-tab:hover .terminal-tab-icon {
207+
display: none;
207208
}
208209

209210
.terminal-tab:hover .terminal-tab-close {
210-
opacity: 0.6;
211+
display: flex;
211212
}
212213

213214
.terminal-tab .terminal-tab-close:hover {
214-
opacity: 1;
215-
background: rgba(255, 255, 255, 0.1);
215+
color: var(--terminal-tab-active-text);
216216
}
217217

218218
/* New terminal button at bottom of tab bar */
219219
.terminal-tab-new-btn {
220-
flex: 1;
221220
display: flex;
222221
align-items: center;
223222
justify-content: center;
@@ -236,7 +235,6 @@
236235

237236
/* Dropdown chevron button */
238237
.terminal-tab-dropdown-btn {
239-
flex: 1;
240238
display: flex;
241239
align-items: center;
242240
justify-content: center;
@@ -246,7 +244,7 @@
246244
font-size: 10px;
247245
background: transparent;
248246
border: none;
249-
border-left: 1px solid var(--terminal-border);
247+
border-top: 1px solid var(--terminal-border);
250248
}
251249

252250
.terminal-tab-dropdown-btn:hover {

0 commit comments

Comments
 (0)