openvibers/openvibe.actor Commits

Actor: the Console links each online computer's live screen on OpenVibe.Bot (#76)

OP OpenVibers committed 29 days ago · f94bfbd84e · 3 files, +8 −3

The Console links a computer's live screen (plan T14, "screen streaming to the Console").

- In **Your computers**, an online computer that offers a screen gets **Watch the screen**. The link goes to `openvibe.bot/machines/:id/screen` (Bot#115). There the owner starts it, or watches it if it's already shown, on the computer's own private stream.
- An offline computer gets no link.
- Agents are unchanged: the live screen is the owner's, and neither Actor nor any agent can start it.

`test/console.test.js` passes. It checks that the link is there for an online computer and absent for an offline one.

Changes

ddiff --git a/public/css/console.css b/public/css/console.css
iindex 50b2c24..7347a7f 100644
---- a/public/css/console.css
++++ b/public/css/console.css
@@@ -81,3 +81,4 @@
.cn-command-row { justify-content: space-between; }
.cn-command textarea { min-height: 5.4rem; }
}
++.cn-list .cn-link { font-size: 13px; color: var(--accent, #60a5fa); }
ddiff --git a/server/http/console-pages.js b/server/http/console-pages.js
iindex 6965f65..e6a41f3 100644
---- a/server/http/console-pages.js
++++ b/server/http/console-pages.js
@@@ -97,7 +97,8 @@ function createConsolePages(ctx, { robots = null, computers = null } = {}) {
: !result.value.computers.length ? html`<p class="cn-empty">No computer is open to your agent. Add one on <a href="${pages}/machines">openvibe.bot/machines</a> with <code>--computer ask</code>, then turn on “Let my agent use this computer”.</p>`
: html`<ul class="cn-list">${result.value.computers.map((c) => html`<li><span class="cn-dot${c.online ? ' on' : ''}" aria-hidden="true"></span><b>${c.name || c.id}</b>
<span class="cn-meta">${c.online ? 'Online' : 'Offline'} · ${LEVEL_TEXT[c.level] || 'On'}${c.can.length ? html` · ${c.can.join(', ')}` : ''}</span>
--${c.waiting_for_approval ? html`<span class="pill pill-running">${String(c.waiting_for_approval)} waiting on the machine</span>` : ''}</li>`)}</ul>`;
++${c.waiting_for_approval ? html`<span class="pill pill-running">${String(c.waiting_for_approval)} waiting on the machine</span>` : ''}
++${c.online && c.can.includes('screen') ? html`<a class="cn-link" href="${pages}/machines/${encodeURIComponent(c.id)}/screen">Watch the screen</a>` : ''}</li>`)}</ul>`;
return html`<section class="cn-card" aria-labelledby="cn-computers"><h2 id="cn-computers">Your computers</h2>${body}
<p class="cn-more"><a href="${pages}/machines">Machines on OpenVibe.Bot</a></p></section>`;
}
ddiff --git a/test/console.test.js b/test/console.test.js
iindex 2b0739f..0a99fcf 100644
---- a/test/console.test.js
++++ b/test/console.test.js
@@@ -20,7 +20,8 @@ const approvals = require('../server/agents/approvals');
mine: async (subject) => {
asked.push(['computers', subject]);
if (botMode === 'fail') return { error: 'Bot answered 503 for your computers' };
-- return { computers: [{ id: 'dev_01M4W5JBFDG2TJ8C4FRDMCWBZ9', name: 'desk-pc', online: true, level: 'ask', can: ['terminal', 'files'], folders: ['/home/ada'], waiting_for_approval: 2 }] };
++ return { computers: [{ id: 'dev_01M4W5JBFDG2TJ8C4FRDMCWBZ9', name: 'desk-pc', online: true, level: 'ask', can: ['terminal', 'files', 'screen'], folders: ['/home/ada'], waiting_for_approval: 2 },
++ { id: 'dev_01M4W5JBFDG2TJ8C4FRDMCWBZA', name: 'old-laptop', online: false, level: 'observe', can: ['files', 'screen'], folders: [] }] };
},
},
robots: {
@@@ -71,7 +72,9 @@ const approvals = require('../server/agents/approvals');
assert.match(h, /2 on your computers/);
assert.match(h, /cn-count">3</, 'one approval here and two on the machine');
assert.match(h, /Morning briefing/);
-- assert.match(h, /desk-pc[\s\S]*Ask first · terminal, files/);
++ assert.match(h, /desk-pc[\s\S]*Ask first · terminal, files, screen/);
++ assert.match(h, /href="https:\/\/[^"]+\/machines\/dev_01M4W5JBFDG2TJ8C4FRDMCWBZ9\/screen">Watch the screen</, 'an online computer with a screen links its live screen on Bot');
++ assert.ok(!h.includes('dev_01M4W5JBFDG2TJ8C4FRDMCWBZA/screen'), 'never for one that is offline');
assert.match(h, /Desk rover[\s\S]*battery 80%/);
assert.match(h, /openvibe\.services\/projects/);
assert.match(h, /Last 7 days: <b>\$0\.0012<\/b>, 2 tasks/, 'the week: what the two tasks spent today');