@lethevimlet/sshift 0.6.0 → 0.9.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/README.md +104 -9
- package/example.config.json +20 -0
- package/package.json +2 -1
- package/plugins/claude-attention/index.js +296 -0
- package/plugins/claude-attention/package.json +6 -0
- package/plugins/opencode-attention/index.js +248 -0
- package/plugins/opencode-attention/package.json +6 -0
- package/src/server/index.js +39 -1
- package/src/server/plugins/plugin-manager.js +256 -0
- package/src/server/services/ssh-manager.js +14 -0
- package/src/server/utils/config.js +23 -0
- package/src/webapp/css/style.css +138 -0
- package/src/webapp/js/app.js +255 -72
package/src/webapp/css/style.css
CHANGED
|
@@ -1920,6 +1920,144 @@ body {
|
|
|
1920
1920
|
color: var(--text-primary);
|
|
1921
1921
|
}
|
|
1922
1922
|
|
|
1923
|
+
.tab.flashing {
|
|
1924
|
+
animation: tab-flash 1s ease-in-out infinite;
|
|
1925
|
+
transition: none;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
@keyframes tab-flash {
|
|
1929
|
+
0%, 100% {
|
|
1930
|
+
background: transparent;
|
|
1931
|
+
border-bottom-color: var(--accent-primary);
|
|
1932
|
+
color: var(--accent-primary);
|
|
1933
|
+
}
|
|
1934
|
+
50% {
|
|
1935
|
+
background: var(--accent-primary);
|
|
1936
|
+
color: #fff;
|
|
1937
|
+
border-bottom-color: var(--accent-primary);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
.tab.active.flashing {
|
|
1942
|
+
animation: tab-flash-active 1s ease-in-out infinite;
|
|
1943
|
+
transition: none;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
@keyframes tab-flash-active {
|
|
1947
|
+
0%, 100% {
|
|
1948
|
+
background: var(--bg-tertiary);
|
|
1949
|
+
border-bottom-color: var(--accent-primary);
|
|
1950
|
+
color: var(--accent-primary);
|
|
1951
|
+
}
|
|
1952
|
+
50% {
|
|
1953
|
+
background: var(--accent-primary);
|
|
1954
|
+
color: #fff;
|
|
1955
|
+
border-bottom-color: var(--accent-primary);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
.mobile-tabs-toggle.flashing {
|
|
1960
|
+
animation: mobile-toggle-flash 1s ease-in-out infinite;
|
|
1961
|
+
transition: none;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
@keyframes mobile-toggle-flash {
|
|
1965
|
+
0%, 100% {
|
|
1966
|
+
background: var(--bg-tertiary);
|
|
1967
|
+
border-color: var(--accent-primary);
|
|
1968
|
+
box-shadow: 0 0 0 1px var(--accent-primary);
|
|
1969
|
+
}
|
|
1970
|
+
50% {
|
|
1971
|
+
background: var(--accent-primary);
|
|
1972
|
+
border-color: var(--accent-primary);
|
|
1973
|
+
color: #fff;
|
|
1974
|
+
box-shadow: 0 0 8px var(--accent-primary);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
.mobile-tab-option.flashing {
|
|
1979
|
+
animation: mobile-option-flash 1s ease-in-out infinite;
|
|
1980
|
+
transition: none;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
@keyframes mobile-option-flash {
|
|
1984
|
+
0%, 100% {
|
|
1985
|
+
background: transparent;
|
|
1986
|
+
color: var(--accent-primary);
|
|
1987
|
+
}
|
|
1988
|
+
50% {
|
|
1989
|
+
background: var(--accent-primary);
|
|
1990
|
+
color: #fff;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
[data-theme="light"] .tab.flashing {
|
|
1995
|
+
animation: tab-flash-light 1s ease-in-out infinite;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
@keyframes tab-flash-light {
|
|
1999
|
+
0%, 100% {
|
|
2000
|
+
background: transparent;
|
|
2001
|
+
border-bottom-color: var(--accent-primary);
|
|
2002
|
+
color: var(--accent-primary);
|
|
2003
|
+
}
|
|
2004
|
+
50% {
|
|
2005
|
+
background: var(--accent-primary);
|
|
2006
|
+
color: #fff;
|
|
2007
|
+
border-bottom-color: var(--accent-primary);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
[data-theme="light"] .tab.active.flashing {
|
|
2012
|
+
animation: tab-flash-active-light 1s ease-in-out infinite;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
@keyframes tab-flash-active-light {
|
|
2016
|
+
0%, 100% {
|
|
2017
|
+
background: var(--bg-tertiary);
|
|
2018
|
+
border-bottom-color: var(--accent-primary);
|
|
2019
|
+
color: var(--accent-primary);
|
|
2020
|
+
}
|
|
2021
|
+
50% {
|
|
2022
|
+
background: var(--accent-primary);
|
|
2023
|
+
color: #fff;
|
|
2024
|
+
border-bottom-color: var(--accent-primary);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
[data-theme="light"] .mobile-tabs-toggle.flashing {
|
|
2029
|
+
animation: mobile-toggle-flash-light 1s ease-in-out infinite;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
@keyframes mobile-toggle-flash-light {
|
|
2033
|
+
0%, 100% {
|
|
2034
|
+
background: var(--bg-tertiary);
|
|
2035
|
+
border-color: var(--accent-primary);
|
|
2036
|
+
box-shadow: 0 0 0 1px var(--accent-primary);
|
|
2037
|
+
}
|
|
2038
|
+
50% {
|
|
2039
|
+
background: var(--accent-primary);
|
|
2040
|
+
border-color: var(--accent-primary);
|
|
2041
|
+
color: #fff;
|
|
2042
|
+
box-shadow: 0 0 8px var(--accent-primary);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
[data-theme="light"] .mobile-tab-option.flashing {
|
|
2047
|
+
animation: mobile-option-flash-light 1s ease-in-out infinite;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
@keyframes mobile-option-flash-light {
|
|
2051
|
+
0%, 100% {
|
|
2052
|
+
background: transparent;
|
|
2053
|
+
color: var(--accent-primary);
|
|
2054
|
+
}
|
|
2055
|
+
50% {
|
|
2056
|
+
background: var(--accent-primary);
|
|
2057
|
+
color: #fff;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
|
|
1923
2061
|
.tab-icon {
|
|
1924
2062
|
font-size: 12px;
|
|
1925
2063
|
}
|
package/src/webapp/js/app.js
CHANGED
|
@@ -3058,6 +3058,9 @@ class SSHIFTClient {
|
|
|
3058
3058
|
// Update mobile tabs Dropdown after restoration
|
|
3059
3059
|
this.updateMobileTabsDropdown();
|
|
3060
3060
|
|
|
3061
|
+
// Apply any flash states that arrived before DOM elements existed
|
|
3062
|
+
this.applyFlashStates();
|
|
3063
|
+
|
|
3061
3064
|
// Clear restoring flag after restoration is complete
|
|
3062
3065
|
this.isRestoring = false;
|
|
3063
3066
|
}
|
|
@@ -3160,6 +3163,7 @@ class SSHIFTClient {
|
|
|
3160
3163
|
console.log('[SSHIFT] Tab order updated:', data.order);
|
|
3161
3164
|
if (this.sticky) {
|
|
3162
3165
|
this.reorderTabsInDOM(data.order);
|
|
3166
|
+
this.updateMobileTabsDropdown();
|
|
3163
3167
|
}
|
|
3164
3168
|
});
|
|
3165
3169
|
|
|
@@ -3430,39 +3434,70 @@ class SSHIFTClient {
|
|
|
3430
3434
|
session.isController = data.controllerSocket === this.socket.id;
|
|
3431
3435
|
session.controllerSocket = data.controllerSocket;
|
|
3432
3436
|
|
|
3437
|
+
if (session.isController && !wasController) {
|
|
3438
|
+
// We just became the controller — hide overlay immediately
|
|
3439
|
+
// to avoid measuring stale dimensions, then resize after layout settles
|
|
3440
|
+
const overlay = document.getElementById(`control-overlay-${data.sessionId}`);
|
|
3441
|
+
if (overlay) overlay.style.display = 'none';
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3433
3444
|
this.updateControlOverlay(data.sessionId);
|
|
3434
3445
|
|
|
3435
3446
|
if (session.isController && !wasController) {
|
|
3436
|
-
//
|
|
3447
|
+
// Resize to our container after browser finishes layout
|
|
3437
3448
|
if (session.terminal && session.fitAddon) {
|
|
3438
|
-
session.isResyncing = true;
|
|
3439
3449
|
if (session.resizeTimeout) {
|
|
3440
3450
|
clearTimeout(session.resizeTimeout);
|
|
3441
3451
|
session.resizeTimeout = null;
|
|
3442
3452
|
}
|
|
3443
|
-
this._fitTerminal(session);
|
|
3444
|
-
session.isResyncing = false;
|
|
3445
|
-
this.socket.emit('ssh-resize', {
|
|
3446
|
-
sessionId: data.sessionId,
|
|
3447
|
-
cols: session.terminal.cols,
|
|
3448
|
-
rows: session.terminal.rows
|
|
3449
|
-
});
|
|
3450
|
-
console.log('[SSHIFT] Resized terminal after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3451
3453
|
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3454
|
+
requestAnimationFrame(() => {
|
|
3455
|
+
requestAnimationFrame(() => {
|
|
3456
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
3457
|
+
try {
|
|
3458
|
+
session.isResyncing = true;
|
|
3459
|
+
this._fitTerminal(session);
|
|
3460
|
+
session.isResyncing = false;
|
|
3461
|
+
|
|
3462
|
+
if (session.terminal && session.connected) {
|
|
3463
|
+
this.socket.emit('ssh-resize', {
|
|
3464
|
+
sessionId: data.sessionId,
|
|
3465
|
+
cols: session.terminal.cols,
|
|
3466
|
+
rows: session.terminal.rows
|
|
3467
|
+
});
|
|
3468
|
+
console.log('[SSHIFT] Resized terminal after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
setTimeout(() => {
|
|
3472
|
+
if (session.terminal && session.fitAddon && session.isController) {
|
|
3473
|
+
session.isResyncing = true;
|
|
3474
|
+
const prevCols = session.terminal.cols;
|
|
3475
|
+
const prevRows = session.terminal.rows;
|
|
3476
|
+
this._fitTerminal(session);
|
|
3477
|
+
session.isResyncing = false;
|
|
3478
|
+
if (session.terminal.cols !== prevCols || session.terminal.rows !== prevRows) {
|
|
3479
|
+
this.socket.emit('ssh-resize', {
|
|
3480
|
+
sessionId: data.sessionId,
|
|
3481
|
+
cols: session.terminal.cols,
|
|
3482
|
+
rows: session.terminal.rows
|
|
3483
|
+
});
|
|
3484
|
+
console.log('[SSHIFT] Corrected dimensions after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
}, 300);
|
|
3488
|
+
|
|
3489
|
+
setTimeout(() => {
|
|
3490
|
+
if (session.terminal && session.connected && session.isController) {
|
|
3491
|
+
console.log('[SSHIFT] Requesting screen sync after becoming controller to redraw at local dimensions');
|
|
3492
|
+
this.requestScreenSync(data.sessionId);
|
|
3493
|
+
}
|
|
3494
|
+
}, 500);
|
|
3495
|
+
} catch (e) {
|
|
3496
|
+
console.warn('[SSHIFT] Error resizing terminal after becoming controller:', e.message);
|
|
3497
|
+
session.isResyncing = false;
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
});
|
|
3466
3501
|
}
|
|
3467
3502
|
this.showToast('You are now in control (previous controller left)', 'info');
|
|
3468
3503
|
} else if (!session.isController) {
|
|
@@ -3490,57 +3525,71 @@ class SSHIFTClient {
|
|
|
3490
3525
|
if (session) {
|
|
3491
3526
|
session.isController = true;
|
|
3492
3527
|
session.controllerSocket = this.socket.id;
|
|
3528
|
+
|
|
3529
|
+
// Immediately hide the overlay so the terminal container can recalculate
|
|
3530
|
+
// its dimensions before we fit. Skip the 50ms debounce in updateControlOverlay
|
|
3531
|
+
// to avoid measuring stale dimensions.
|
|
3532
|
+
const overlay = document.getElementById(`control-overlay-${data.sessionId}`);
|
|
3533
|
+
if (overlay) overlay.style.display = 'none';
|
|
3493
3534
|
this.updateControlOverlay(data.sessionId);
|
|
3494
3535
|
|
|
3495
3536
|
// Resize the SSH terminal to match our local terminal dimensions
|
|
3496
|
-
//
|
|
3537
|
+
// Use double requestAnimationFrame to ensure the browser has finished
|
|
3538
|
+
// layout after hiding the overlay (same pattern as tab switching).
|
|
3497
3539
|
if (session.terminal && session.fitAddon) {
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
session.
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
session.
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
// Fit the terminal to our container first
|
|
3510
|
-
session.isResyncing = true;
|
|
3511
|
-
this._fitTerminal(session);
|
|
3512
|
-
|
|
3513
|
-
// Clear the resyncing flag before emitting resize
|
|
3514
|
-
session.isResyncing = false;
|
|
3515
|
-
|
|
3516
|
-
// Now emit the resize event to update the SSH terminal and other clients
|
|
3517
|
-
this.socket.emit('ssh-resize', {
|
|
3518
|
-
sessionId: data.sessionId,
|
|
3519
|
-
cols: session.terminal.cols,
|
|
3520
|
-
rows: session.terminal.rows
|
|
3521
|
-
});
|
|
3522
|
-
|
|
3523
|
-
console.log('[SSHIFT] Resized SSH terminal after taking control:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3524
|
-
|
|
3525
|
-
// Delayed refit to handle viewport transitions (e.g. mobile -> desktop)
|
|
3526
|
-
// The container dimensions may not be final when fit first runs
|
|
3527
|
-
setTimeout(() => {
|
|
3528
|
-
if (session.terminal && session.fitAddon && session.isController) {
|
|
3540
|
+
// Clear any pending resize timeout to prevent duplicate resize events
|
|
3541
|
+
if (session.resizeTimeout) {
|
|
3542
|
+
clearTimeout(session.resizeTimeout);
|
|
3543
|
+
session.resizeTimeout = null;
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
requestAnimationFrame(() => {
|
|
3547
|
+
requestAnimationFrame(() => {
|
|
3548
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
3549
|
+
try {
|
|
3529
3550
|
session.isResyncing = true;
|
|
3530
3551
|
this._fitTerminal(session);
|
|
3531
3552
|
session.isResyncing = false;
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3553
|
+
|
|
3554
|
+
if (session.terminal && session.connected) {
|
|
3555
|
+
this.socket.emit('ssh-resize', {
|
|
3556
|
+
sessionId: data.sessionId,
|
|
3557
|
+
cols: session.terminal.cols,
|
|
3558
|
+
rows: session.terminal.rows
|
|
3559
|
+
});
|
|
3560
|
+
console.log('[SSHIFT] Resized SSH terminal after taking control:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
setTimeout(() => {
|
|
3564
|
+
if (session.terminal && session.fitAddon && session.isController) {
|
|
3565
|
+
session.isResyncing = true;
|
|
3566
|
+
const prevCols = session.terminal.cols;
|
|
3567
|
+
const prevRows = session.terminal.rows;
|
|
3568
|
+
this._fitTerminal(session);
|
|
3569
|
+
session.isResyncing = false;
|
|
3570
|
+
if (session.terminal.cols !== prevCols || session.terminal.rows !== prevRows) {
|
|
3571
|
+
this.socket.emit('ssh-resize', {
|
|
3572
|
+
sessionId: data.sessionId,
|
|
3573
|
+
cols: session.terminal.cols,
|
|
3574
|
+
rows: session.terminal.rows
|
|
3575
|
+
});
|
|
3576
|
+
console.log('[SSHIFT] Corrected dimensions after take control:', session.terminal.cols, 'x', session.terminal.rows);
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
}, 300);
|
|
3580
|
+
|
|
3581
|
+
setTimeout(() => {
|
|
3582
|
+
if (session.terminal && session.connected && session.isController) {
|
|
3583
|
+
console.log('[SSHIFT] Requesting screen sync after taking control to redraw at local dimensions');
|
|
3584
|
+
this.requestScreenSync(data.sessionId);
|
|
3585
|
+
}
|
|
3586
|
+
}, 500);
|
|
3587
|
+
} catch (e) {
|
|
3588
|
+
console.warn('[SSHIFT] Error resizing terminal after taking control:', e.message);
|
|
3589
|
+
session.isResyncing = false;
|
|
3538
3590
|
}
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
console.warn('[SSHIFT] Error resizing terminal after taking control:', e.message);
|
|
3542
|
-
session.isResyncing = false;
|
|
3543
|
-
}
|
|
3591
|
+
});
|
|
3592
|
+
});
|
|
3544
3593
|
}
|
|
3545
3594
|
|
|
3546
3595
|
this.showToast('You are now in control', 'success');
|
|
@@ -3721,6 +3770,15 @@ class SSHIFTClient {
|
|
|
3721
3770
|
this.renderBookmarks();
|
|
3722
3771
|
}
|
|
3723
3772
|
});
|
|
3773
|
+
|
|
3774
|
+
// Plugin-driven tab flash events
|
|
3775
|
+
this.socket.on('tab-flash', (data) => {
|
|
3776
|
+
this.startTabFlash(data.sessionId, data);
|
|
3777
|
+
});
|
|
3778
|
+
|
|
3779
|
+
this.socket.on('tab-flash-stop', (data) => {
|
|
3780
|
+
this.stopTabFlash(data.sessionId);
|
|
3781
|
+
});
|
|
3724
3782
|
}
|
|
3725
3783
|
|
|
3726
3784
|
// Event Listeners
|
|
@@ -4676,6 +4734,9 @@ class SSHIFTClient {
|
|
|
4676
4734
|
const option = document.createElement('div');
|
|
4677
4735
|
option.className = `mobile-tab-option${isActive ? ' active' : ''}`;
|
|
4678
4736
|
option.dataset.sessionId = sessionId;
|
|
4737
|
+
if (this._flashingSessions && this._flashingSessions.has(sessionId)) {
|
|
4738
|
+
option.classList.add('flashing');
|
|
4739
|
+
}
|
|
4679
4740
|
option.innerHTML = `
|
|
4680
4741
|
<i class="fas ${icon} tab-icon ${iconClass}"></i>
|
|
4681
4742
|
<span class="tab-name">${displayName}</span>
|
|
@@ -4723,6 +4784,13 @@ class SSHIFTClient {
|
|
|
4723
4784
|
iconElement.className = `fas ${activeTabIcon} tab-icon-active`;
|
|
4724
4785
|
}
|
|
4725
4786
|
mobileTabsLabel.textContent = activeTabName;
|
|
4787
|
+
|
|
4788
|
+
// Restore flashing state on toggle if any tab is flashing
|
|
4789
|
+
if (this._flashingSessions && this._flashingSessions.size > 0) {
|
|
4790
|
+
mobileTabsToggle.classList.add('flashing');
|
|
4791
|
+
} else {
|
|
4792
|
+
mobileTabsToggle.classList.remove('flashing');
|
|
4793
|
+
}
|
|
4726
4794
|
} else {
|
|
4727
4795
|
// Desktop: Update dropdowns per panel (original behavior)
|
|
4728
4796
|
// If panelId is provided, update only that panel's dropdown
|
|
@@ -4766,6 +4834,9 @@ class SSHIFTClient {
|
|
|
4766
4834
|
const option = document.createElement('div');
|
|
4767
4835
|
option.className = `mobile-tab-option${isActive ? ' active' : ''}`;
|
|
4768
4836
|
option.dataset.sessionId = sessionId;
|
|
4837
|
+
if (this._flashingSessions && this._flashingSessions.has(sessionId)) {
|
|
4838
|
+
option.classList.add('flashing');
|
|
4839
|
+
}
|
|
4769
4840
|
option.innerHTML = `
|
|
4770
4841
|
<i class="fas ${icon} tab-icon ${iconClass}"></i>
|
|
4771
4842
|
<span class="tab-name">${name}</span>
|
|
@@ -4813,6 +4884,15 @@ class SSHIFTClient {
|
|
|
4813
4884
|
iconElement.className = `fas ${activeTabIcon} tab-icon-active`;
|
|
4814
4885
|
}
|
|
4815
4886
|
mobileTabsLabel.textContent = activeTabName;
|
|
4887
|
+
|
|
4888
|
+
// Restore flashing state on toggle if any tab is flashing
|
|
4889
|
+
if (mobileTabsToggle) {
|
|
4890
|
+
if (this._flashingSessions && this._flashingSessions.size > 0) {
|
|
4891
|
+
mobileTabsToggle.classList.add('flashing');
|
|
4892
|
+
} else {
|
|
4893
|
+
mobileTabsToggle.classList.remove('flashing');
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4816
4896
|
});
|
|
4817
4897
|
}
|
|
4818
4898
|
}
|
|
@@ -6531,10 +6611,101 @@ class SSHIFTClient {
|
|
|
6531
6611
|
URL.revokeObjectURL(url);
|
|
6532
6612
|
}
|
|
6533
6613
|
|
|
6534
|
-
|
|
6614
|
+
// Tab Management
|
|
6615
|
+
|
|
6616
|
+
startTabFlash(sessionId, options = {}) {
|
|
6617
|
+
const flashingSessions = this._flashingSessions || (this._flashingSessions = new Set());
|
|
6618
|
+
flashingSessions.add(sessionId);
|
|
6619
|
+
|
|
6620
|
+
const tab = document.querySelector(`.tab[data-session-id="${sessionId}"]`);
|
|
6621
|
+
if (tab) {
|
|
6622
|
+
tab.classList.add('flashing');
|
|
6623
|
+
}
|
|
6624
|
+
|
|
6625
|
+
const mobileOption = document.querySelector(`.mobile-tab-option[data-session-id="${sessionId}"]`);
|
|
6626
|
+
if (mobileOption) {
|
|
6627
|
+
mobileOption.classList.add('flashing');
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6630
|
+
const mobileToggle = document.querySelector('.mobile-tabs-toggle');
|
|
6631
|
+
if (mobileToggle) {
|
|
6632
|
+
mobileToggle.classList.add('flashing');
|
|
6633
|
+
}
|
|
6634
|
+
|
|
6635
|
+
if (!this._tabFlashTimers) this._tabFlashTimers = new Map();
|
|
6636
|
+
if (options.duration) {
|
|
6637
|
+
const existing = this._tabFlashTimers.get(sessionId);
|
|
6638
|
+
if (existing) clearTimeout(existing);
|
|
6639
|
+
this._tabFlashTimers.set(sessionId, setTimeout(() => {
|
|
6640
|
+
this.stopTabFlash(sessionId);
|
|
6641
|
+
}, options.duration));
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
// Safety net: schedule a delayed applyFlashStates in case DOM elements
|
|
6645
|
+
// didn't exist yet when this call was made (e.g., during tab sync)
|
|
6646
|
+
if (!this._flashApplyTimer) this._flashApplyTimer = null;
|
|
6647
|
+
clearTimeout(this._flashApplyTimer);
|
|
6648
|
+
this._flashApplyTimer = setTimeout(() => this.applyFlashStates(), 150);
|
|
6649
|
+
}
|
|
6650
|
+
|
|
6651
|
+
stopTabFlash(sessionId) {
|
|
6652
|
+
const flashingSessions = this._flashingSessions;
|
|
6653
|
+
if (flashingSessions) {
|
|
6654
|
+
flashingSessions.delete(sessionId);
|
|
6655
|
+
}
|
|
6656
|
+
|
|
6657
|
+
const tab = document.querySelector(`.tab[data-session-id="${sessionId}"]`);
|
|
6658
|
+
if (tab) {
|
|
6659
|
+
tab.classList.remove('flashing');
|
|
6660
|
+
}
|
|
6661
|
+
|
|
6662
|
+
const mobileOption = document.querySelector(`.mobile-tab-option[data-session-id="${sessionId}"]`);
|
|
6663
|
+
if (mobileOption) {
|
|
6664
|
+
mobileOption.classList.remove('flashing');
|
|
6665
|
+
}
|
|
6666
|
+
|
|
6667
|
+
const mobileToggle = document.querySelector('.mobile-tabs-toggle');
|
|
6668
|
+
if (mobileToggle && (!flashingSessions || flashingSessions.size === 0)) {
|
|
6669
|
+
mobileToggle.classList.remove('flashing');
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6672
|
+
if (this._tabFlashTimers) {
|
|
6673
|
+
const timer = this._tabFlashTimers.get(sessionId);
|
|
6674
|
+
if (timer) {
|
|
6675
|
+
clearTimeout(timer);
|
|
6676
|
+
this._tabFlashTimers.delete(sessionId);
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
applyFlashStates() {
|
|
6682
|
+
const flashingSessions = this._flashingSessions;
|
|
6683
|
+
if (!flashingSessions || flashingSessions.size === 0) return;
|
|
6684
|
+
|
|
6685
|
+
for (const sessionId of flashingSessions) {
|
|
6686
|
+
const tab = document.querySelector(`.tab[data-session-id="${sessionId}"]`);
|
|
6687
|
+
if (tab) {
|
|
6688
|
+
tab.classList.add('flashing');
|
|
6689
|
+
}
|
|
6690
|
+
|
|
6691
|
+
const mobileOption = document.querySelector(`.mobile-tab-option[data-session-id="${sessionId}"]`);
|
|
6692
|
+
if (mobileOption) {
|
|
6693
|
+
mobileOption.classList.add('flashing');
|
|
6694
|
+
}
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6697
|
+
const mobileToggle = document.querySelector('.mobile-tabs-toggle');
|
|
6698
|
+
if (mobileToggle) {
|
|
6699
|
+
mobileToggle.classList.add('flashing');
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6702
|
+
|
|
6535
6703
|
switchTab(sessionId, panelId = null) {
|
|
6536
6704
|
console.log('[SSHIFT] switchTab called for session:', sessionId, 'panel:', panelId);
|
|
6537
6705
|
|
|
6706
|
+
// Stop any active flash on this tab since user is viewing it
|
|
6707
|
+
this.stopTabFlash(sessionId);
|
|
6708
|
+
|
|
6538
6709
|
// Determine which panel this session belongs to
|
|
6539
6710
|
if (!panelId) {
|
|
6540
6711
|
panelId = this.getPanelForSession(sessionId);
|
|
@@ -6746,9 +6917,10 @@ class SSHIFTClient {
|
|
|
6746
6917
|
|
|
6747
6918
|
// Update mobile tabs dropdown
|
|
6748
6919
|
this.updateMobileTabsDropdown();
|
|
6920
|
+
|
|
6921
|
+
// Apply any flash states that may have arrived before the tab DOM existed
|
|
6922
|
+
this.applyFlashStates();
|
|
6749
6923
|
}
|
|
6750
|
-
|
|
6751
|
-
// Handle tab closed by another client
|
|
6752
6924
|
handleTabClosed(sessionId) {
|
|
6753
6925
|
// Check if we have this session
|
|
6754
6926
|
const session = this.sessions.get(sessionId) || this.sftpSessions.get(sessionId);
|
|
@@ -6808,8 +6980,16 @@ class SSHIFTClient {
|
|
|
6808
6980
|
}
|
|
6809
6981
|
|
|
6810
6982
|
// Sync tabs from server (called on connect when sticky is enabled)
|
|
6811
|
-
|
|
6812
|
-
|
|
6983
|
+
async syncTabsFromServer(tabs) {
|
|
6984
|
+
// Wait for any in-progress restoration to complete before syncing
|
|
6985
|
+
// This prevents the race condition where restoreTabs starts first,
|
|
6986
|
+
// sets isRestoring=true, and then this function returns early, missing
|
|
6987
|
+
// server tabs that aren't in localStorage
|
|
6988
|
+
let waitCount = 0;
|
|
6989
|
+
while (this.isRestoring && waitCount < 200) {
|
|
6990
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
6991
|
+
waitCount++;
|
|
6992
|
+
}
|
|
6813
6993
|
|
|
6814
6994
|
console.log('[SSHIFT] Syncing tabs from server:', tabs.length);
|
|
6815
6995
|
this.isRestoring = true;
|
|
@@ -6846,6 +7026,9 @@ class SSHIFTClient {
|
|
|
6846
7026
|
// Update mobile tabs dropdown after syncing
|
|
6847
7027
|
this.updateMobileTabsDropdown();
|
|
6848
7028
|
|
|
7029
|
+
// Apply any flash states that arrived before DOM elements existed
|
|
7030
|
+
this.applyFlashStates();
|
|
7031
|
+
|
|
6849
7032
|
this.isRestoring = false;
|
|
6850
7033
|
}
|
|
6851
7034
|
|