feat: «Здесь» from a machine's file pane opens the terminal in that pane's folder (the agent starts the shell there; an older agent, or a folder gone, at home)

This commit is contained in:
redtea committed 2026-10-16 18:17:11 +03:00
1 parent 4fb26a9652
commit 57c2f1338f
10 files changed
+143 -12

No files matched your search

+5 -2
View File
@@ -262,9 +262,11 @@ window.TermKeys = (function () {
class Session {
// ssh, when given, is where the agent connects by SSH for this shell:
// {host, port, user} and the secret to sign in with, sent once on open.
constructor(agent, ssh) {
// dir, for a shell on the machine, is the folder it starts in.
constructor(agent, ssh, dir) {
this.agent = agent;
this.ssh = ssh || null;
this.dir = dir || '';
this.kind = ssh ? 'ssh' : 'term';
// Where its files are, for dropped paths: the machine, or the SSH host
// through it.
@@ -310,6 +312,7 @@ window.TermKeys = (function () {
async open() {
try {
let opt = { method: 'POST' };
if (this.dir) opt = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ dir: this.dir }) };
if (this.ssh) {
opt = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ssh: this.ssh }) };
// The password or key goes once, to the agent; the page keeps no copy.
@@ -461,7 +464,7 @@ window.TermKeys = (function () {
}
W.paneTypes.term = agent => new Session(agent);
W.paneTypes.term = (agent, opts) => new Session(agent, null, opts.dir);
W.paneTypes.ssh = (agent, opts) => new Session(agent, opts.ssh);
// For the touch helpers: the terminal being typed in.
window.TermPane = {active: () => { const p = W.activePane(); return p && p.term ? p : null; }};
+6 -1
View File
@@ -565,7 +565,12 @@
list.appendChild(inner);
g.after(list);
if (here) item(content, '<span class="ico">+</span><span><b>Здесь</b><small>' + esc(here.name) + ' · ' + esc(here.user + '@' + here.host) + '</small></span>',
() => { closeMenu(); openPane(kind, here); });
() => {
closeMenu();
// A terminal from a machine's file pane starts in its folder.
const dir = kind === 'term' && activePane.kind === 'files' ? activePane.cwd : '';
openPane(kind, here, dir ? {dir} : null);
});
const box = document.createElement('div');
box.innerHTML = '<div class="muted" style="padding:8px 10px;font-size:13px">загрузка…</div>';
content.appendChild(box);