Fix clipboard on OSX, build-all and unicode support
This commit is contained in:
@@ -483,6 +483,23 @@ class App {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingSessions = this.state.getAllSessions().filter((session) => {
|
||||
if (session.profileId !== profileId) return false;
|
||||
return session.state === 'connected' || session.state === 'connecting' || session.state === 'reconnecting';
|
||||
});
|
||||
if (existingSessions.length > 0) {
|
||||
const preferred = existingSessions.find((s) => s.id === this.state.activeSessionId) || existingSessions[0];
|
||||
const decision = await this._confirmReuseSession(profile, preferred);
|
||||
if (decision === 'existing') {
|
||||
this.tabs.setActive(preferred.id);
|
||||
if (preferred.protocol !== 'raw' && preferred.protocol !== 'github') {
|
||||
this.terminals.focusTerminal(preferred.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (decision !== 'new') return;
|
||||
}
|
||||
|
||||
try {
|
||||
const sessionInfo = await window.go.api.Service.ConnectSession(profileId);
|
||||
this.state.addSession(sessionInfo);
|
||||
@@ -628,6 +645,60 @@ class App {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts to reuse an existing session for a profile.
|
||||
* @param {Object} profile
|
||||
* @param {Object} session
|
||||
* @returns {Promise<'existing'|'new'|null>}
|
||||
* @private
|
||||
*/
|
||||
_confirmReuseSession(profile, session) {
|
||||
const createElement = window.NexusTerminal.createElement;
|
||||
const label = (profile.displayName || profile.host || 'Untitled').trim();
|
||||
const stateLabel = session.state === 'connected' ? 'connected' : 'connecting';
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const backdrop = createElement('div', 'modal-backdrop');
|
||||
const modal = createElement('div', 'modal modal-sm');
|
||||
modal.innerHTML = `
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Connection Already Open</h3>
|
||||
<button class="btn btn-icon btn-xs modal-close">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p style="font-size:var(--text-sm);color:var(--text-secondary)">
|
||||
<strong>${label}</strong> is already ${stateLabel}.
|
||||
Do you want to use the existing session or open a new one?
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-sm confirm-cancel">Cancel</button>
|
||||
<button class="btn btn-sm confirm-new">New Connection</button>
|
||||
<button class="btn btn-sm btn-primary confirm-ok">Use Existing</button>
|
||||
</div>
|
||||
`;
|
||||
backdrop.appendChild(modal);
|
||||
document.body.appendChild(backdrop);
|
||||
requestAnimationFrame(() => {
|
||||
backdrop.classList.add('is-visible');
|
||||
modal.classList.add('is-visible');
|
||||
});
|
||||
|
||||
const close = (val) => {
|
||||
backdrop.classList.remove('is-visible');
|
||||
modal.classList.remove('is-visible');
|
||||
setTimeout(() => backdrop.remove(), 200);
|
||||
resolve(val);
|
||||
};
|
||||
|
||||
modal.querySelector('.modal-close').addEventListener('click', () => close(null));
|
||||
modal.querySelector('.confirm-cancel').addEventListener('click', () => close(null));
|
||||
modal.querySelector('.confirm-ok').addEventListener('click', () => close('existing'));
|
||||
modal.querySelector('.confirm-new').addEventListener('click', () => close('new'));
|
||||
backdrop.addEventListener('click', (e) => { if (e.target === backdrop) close(null); });
|
||||
});
|
||||
}
|
||||
|
||||
// ── Import / Export ──────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Handles data routing, resizing, and search.
|
||||
*/
|
||||
|
||||
/* global Terminal, FitAddon, SearchAddon, WebLinksAddon */
|
||||
/* global Terminal, FitAddon, SearchAddon, WebLinksAddon, Unicode11Addon */
|
||||
|
||||
class TerminalManager {
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ class TerminalManager {
|
||||
const themeName = (this.app.state.preferences || {}).terminalTheme || 'charcoal';
|
||||
const term = new Terminal({
|
||||
theme: window.NexusTerminal.getTerminalTheme(themeName),
|
||||
fontFamily: profile.terminalFontFamily || 'JetBrains Mono, Menlo, Monaco, Consolas, monospace',
|
||||
fontFamily: profile.terminalFontFamily || 'JetBrains Mono, Menlo, Monaco, Consolas, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", monospace',
|
||||
fontSize: profile.terminalFontSize || 14,
|
||||
scrollback: profile.terminalScrollback || 10000,
|
||||
cursorStyle: profile.terminalCursorStyle || 'block',
|
||||
@@ -50,10 +50,19 @@ class TerminalManager {
|
||||
const fitAddon = new FitAddon.FitAddon();
|
||||
const searchAddon = new SearchAddon.SearchAddon();
|
||||
let webLinksAddon = null;
|
||||
let unicode11Addon = null;
|
||||
|
||||
term.loadAddon(fitAddon);
|
||||
term.loadAddon(searchAddon);
|
||||
|
||||
try {
|
||||
unicode11Addon = new Unicode11Addon.Unicode11Addon();
|
||||
term.loadAddon(unicode11Addon);
|
||||
term.unicode.activeVersion = '11';
|
||||
} catch (_) {
|
||||
// Unicode 11 addon is optional; fall back to default unicode handling.
|
||||
}
|
||||
|
||||
// WebLinksAddon may not always be available
|
||||
try {
|
||||
webLinksAddon = new WebLinksAddon.WebLinksAddon((_event, uri) => {
|
||||
@@ -68,6 +77,19 @@ class TerminalManager {
|
||||
const container = document.getElementById(containerId);
|
||||
term.open(container);
|
||||
|
||||
let suppressPasteEvent = false;
|
||||
const attachPasteGuard = () => {
|
||||
const inputEl = term.textarea || container.querySelector('textarea');
|
||||
if (!inputEl) return;
|
||||
inputEl.addEventListener('paste', (e) => {
|
||||
if (!suppressPasteEvent) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
suppressPasteEvent = false;
|
||||
});
|
||||
};
|
||||
attachPasteGuard();
|
||||
|
||||
// Right-click context menu on the terminal viewport
|
||||
const termEl = container.querySelector('.xterm');
|
||||
if (termEl) {
|
||||
@@ -131,6 +153,8 @@ class TerminalManager {
|
||||
|
||||
// Cmd/Ctrl+V — paste from clipboard
|
||||
if (mod && e.key === 'v' && e.type === 'keydown') {
|
||||
suppressPasteEvent = true;
|
||||
setTimeout(() => { suppressPasteEvent = false; }, 250);
|
||||
if (window.runtime && window.runtime.ClipboardGetText) {
|
||||
window.runtime.ClipboardGetText().then(function(text) {
|
||||
if (text) term.paste(text);
|
||||
|
||||
Reference in New Issue
Block a user