mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
fix(cookbook): preserve same-host ssh profile selection (#3373)
* fix(cookbook): preserve same-host ssh profile selection * fix(cookbook): resolve same-host ssh profiles in running tab and port lookups
This commit is contained in:
@@ -12,6 +12,7 @@ let _envState;
|
||||
let _sshCmd;
|
||||
let _getPort;
|
||||
let _getPlatform;
|
||||
let _serverByVal;
|
||||
let _isWindows;
|
||||
let _buildEnvPrefix;
|
||||
let _buildServeCmd;
|
||||
@@ -118,7 +119,7 @@ export function _buildDownloadCmd(model, backend) {
|
||||
const includeArg = includePattern ? `, allow_patterns=["${includePattern.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]` : '';
|
||||
// Reflect the server's download target in the preview (matches the real
|
||||
// download path built server-side). '' = default HF cache.
|
||||
const _dlDir = (_envState.servers.find(s => s.host === (_envState.remoteHost || '')) || {}).downloadDir || '';
|
||||
const _dlDir = (_serverByVal?.(_envState.remoteServerKey || _envState.remoteHost || '') || {}).downloadDir || '';
|
||||
const _localDirArg = _dlDir ? `, local_dir=os.path.expanduser('${_dlDir.replace(/\/$/, '')}/${repo.split('/').pop()}')` : '';
|
||||
const _py = _isWindows() ? 'python' : 'python3';
|
||||
cmd = `${_py} -u -c "
|
||||
@@ -475,10 +476,10 @@ export async function _runModelDownload(panel, model, backend, hostOverride) {
|
||||
// No explicit host passed: resolve from the visible server dropdown rather
|
||||
// than _envState.remoteHost (unreliable — multiple state copies disagree).
|
||||
const ssEl = document.getElementById('hwfit-server-select') || document.getElementById('hwfit-dl-server');
|
||||
// Dropdown values are host strings now ('local' for local); resolve by host
|
||||
// (numeric fallback for any stale value).
|
||||
// Dropdown values are profile keys now ('local' for local); stale host
|
||||
// strings and numeric indices still resolve for backwards compatibility.
|
||||
const _ssv = ssEl ? ssEl.value : null;
|
||||
const _dsrv = (_ssv && _ssv !== 'local') ? (_envState.servers.find(s => s.host === _ssv) || _envState.servers[parseInt(_ssv)]) : null;
|
||||
const _dsrv = (_ssv && _ssv !== 'local') ? (_serverByVal?.(_ssv) || _envState.servers[parseInt(_ssv)]) : null;
|
||||
if (_dsrv) {
|
||||
host = _dsrv.host;
|
||||
} else if (ssEl && ssEl.value === 'local') {
|
||||
@@ -487,7 +488,7 @@ export async function _runModelDownload(panel, model, backend, hostOverride) {
|
||||
host = _envState.remoteHost || '';
|
||||
}
|
||||
}
|
||||
const srv = _envState.servers.find(s => s.host === host) || {};
|
||||
const srv = _serverByVal?.(_envState.remoteServerKey || host) || {};
|
||||
const env = host ? (srv.env || 'none') : (_envState.env || 'none');
|
||||
const envPath = host ? (srv.envPath || '') : (_envState.envPath || '');
|
||||
const platform = host ? (srv.platform || '') : (_envState.platform || '');
|
||||
@@ -546,7 +547,8 @@ export async function _runModelDownload(panel, model, backend, hostOverride) {
|
||||
if (zombieCandidate) {
|
||||
try {
|
||||
const _zh = zombieCandidate.remoteHost || '';
|
||||
const _zPort = (_envState.servers || []).find(s => s.host === _zh)?.port;
|
||||
const _zPort = (_serverByVal?.(_envState.remoteServerKey || _zh)
|
||||
|| (_envState.servers || []).find(s => s.host === _zh) || {}).port;
|
||||
const _sshPf = _zh ? `ssh ${_zPort && _zPort !== '22' ? `-p ${_zPort} ` : ''}${_zh} '` : '';
|
||||
const _sshSf = _zh ? `'` : '';
|
||||
const _probeCmd = `${_sshPf}tmux has-session -t ${zombieCandidate.sessionId} 2>/dev/null${_sshSf}`;
|
||||
@@ -615,6 +617,7 @@ export function initDownload(shared) {
|
||||
_sshCmd = shared._sshCmd;
|
||||
_getPort = shared._getPort;
|
||||
_getPlatform = shared._getPlatform;
|
||||
_serverByVal = shared._serverByVal;
|
||||
_isWindows = shared._isWindows;
|
||||
_buildEnvPrefix = shared._buildEnvPrefix;
|
||||
_buildServeCmd = shared._buildServeCmd;
|
||||
|
||||
Reference in New Issue
Block a user