Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions public/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,12 @@ function renderProjects(projects, resort) {
const newBtn = document.createElement('button');
newBtn.className = 'project-new-btn';
newBtn.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5"><line x1="6" y1="2" x2="6" y2="10"/><line x1="2" y1="6" x2="10" y2="6"/></svg>';
newBtn.title = 'New session';
if (project.remoteAlias) {
newBtn.disabled = true;
newBtn.title = 'Read-only mirror of ' + project.remoteAlias + ' — new sessions must be started on that host';
} else {
newBtn.title = 'New session';
}
header.appendChild(newBtn);

const sessionsList = buildSessionsList(fId, visible, older, subagentIndex, project.projectPath);
Expand Down Expand Up @@ -924,7 +929,11 @@ function rebindSidebarEvents(projects) {
if (!header) continue;
const newBtn = header.querySelector('.project-new-btn');
if (newBtn) {
newBtn.onclick = (e) => { e.stopPropagation(); showNewSessionPopover(project, newBtn); };
if (project.remoteAlias) {
newBtn.onclick = (e) => e.stopPropagation();
} else {
newBtn.onclick = (e) => { e.stopPropagation(); showNewSessionPopover(project, newBtn); };
}
}
const scheduleBtn = header.querySelector('.project-schedule-btn');
if (scheduleBtn) {
Expand Down
14 changes: 14 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,20 @@ body { display: flex; flex-direction: column; }
color: #5ec46a;
}

.project-new-btn:disabled {
cursor: default;
opacity: 0.4;
}

.project-new-btn:disabled:hover {
background: transparent;
color: #808098;
}

.project-header:hover .project-new-btn:disabled {
opacity: 0.4;
}

.project-archive-btn:hover {
background: rgba(120,130,255,0.1);
color: #8088ff;
Expand Down
76 changes: 76 additions & 0 deletions test/dom-sidebar-remote-project-new-btn.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Issue #214: a project group mirrored from an SSH host has no local
// filesystem to spawn a PTY in. The "+" new-session button in its header
// must not let a click reach launchNewSession/open-terminal with isNew and
// the remote host's projectPath.

const test = require('node:test');
const assert = require('node:assert/strict');

const { setupSidebarDom, makeSampleProject } = require('./dom-setup');

function remoteProject() {
return makeSampleProject({
projectPath: '/srv/supervision',
folder: 'planificator::-srv-supervision',
remoteAlias: 'planificator',
sessions: [{
sessionId: 'remote-1',
summary: 'ripcord protocol',
modified: '2026-09-06T10:00:00.000Z',
starred: false,
archived: 0,
messageCount: 4,
projectPath: '/srv/supervision',
remoteAlias: 'planificator',
}],
});
}

test('the new-session button of a remote project group is disabled', () => {
const ctx = setupSidebarDom();
try {
ctx.sidebar.renderProjects([remoteProject()], true);
const fId = ctx.sidebar.folderId('/srv/supervision');
const header = ctx.document.getElementById('ph-' + fId);
const newBtn = header.querySelector('.project-new-btn');
assert.ok(newBtn, 'the button must still render');
assert.equal(newBtn.disabled, true);
assert.match(newBtn.title, /planificator/);
} finally { ctx.destroy(); }
});

test('clicking the new-session button of a remote project group opens nothing', () => {
const ctx = setupSidebarDom();
try {
ctx.sidebar.renderProjects([remoteProject()], true);
const fId = ctx.sidebar.folderId('/srv/supervision');
const header = ctx.document.getElementById('ph-' + fId);
const newBtn = header.querySelector('.project-new-btn');

const popovers = [];
ctx.window.showNewSessionPopover = (project, btn) => popovers.push(project.projectPath);

newBtn.onclick({ stopPropagation: () => {} });

assert.deepEqual(popovers, [], 'showNewSessionPopover must never be invoked for a remote project group');
} finally { ctx.destroy(); }
});

test('a local project group is unaffected: the new-session button stays enabled and wired', () => {
const ctx = setupSidebarDom();
try {
ctx.sidebar.renderProjects([makeSampleProject()], true);
const fId = ctx.sidebar.folderId('/home/dev/myproj');
const header = ctx.document.getElementById('ph-' + fId);
const newBtn = header.querySelector('.project-new-btn');
assert.equal(newBtn.disabled, false);
assert.equal(newBtn.title, 'New session');

const popovers = [];
ctx.window.showNewSessionPopover = (project, btn) => popovers.push(project.projectPath);

newBtn.onclick({ stopPropagation: () => {} });

assert.deepEqual(popovers, ['/home/dev/myproj']);
} finally { ctx.destroy(); }
});
Loading