/* Desk UI Kit — interactive workspace shell (recreation of the real app). */
const { useState, useEffect, useRef } = React;
const D = window.DESK_DATA;
const DS = window.DeskDesignSystem_d7d84e || {};
const { Telemetry, Badge } = DS;
/* Lucide icon helper — renders and lets a global pass swap it. */
function Ico({ name, size = 16, color }) {
return ;
}
function useLucide(dep) {
useEffect(() => { try { window.lucide && window.lucide.createIcons(); } catch (e) {} });
}
function renderTerm(segs) {
const lines = []; let cur = [];
segs.forEach((s, i) => {
if (s[0] === 'br') { lines.push(cur); cur = []; return; }
if (s[0] === 'caret') { cur.push(); return; }
cur.push({s[1]});
});
lines.push(cur);
return lines.map((l, i) =>
{l}
);
}
/* ---------- Topbar ---------- */
function Topbar({ onKill }) {
return (
DESK
~/projects/desk · main
{[
['HOST', 'lin-deck', 'up 4d 02h', ''],
['CPU', '42%', '8 cores', ''],
['RAM', '11.4G', 'of 32G', 'warn'],
['GPU', '61%', 'RTX 4090', 'ok'],
['NET', '2.1MB/s', '↓ down', ''],
].map(([l, v, s, tone]) => Telemetry
?
:
{l}
{v}
{s}
)}
);
}
/* ---------- App rail ---------- */
const SUBSYSTEMS = [
{ id: 'terminals', icon: 'terminal' },
{ id: 'channels', icon: 'messages-square' },
{ id: 'editor', icon: 'folder-tree' },
{ id: 'git', icon: 'git-branch', compact: true },
{ id: 'projects', icon: 'kanban' },
{ id: 'notes', icon: 'notebook-pen' },
];
function AppRail({ view, setView }) {
return (
{SUBSYSTEMS.map((s) => (
))}
);
}
/* ---------- Sidebar tree ---------- */
function Sidebar({ selected, setSelected }) {
return (
Sessions
{D.projects.map((p) => (
{p.groups.map((g) => (
{g.name}{g.sessions.length}
{g.sessions.map((s) => (
setSelected(s.id)}>
{s.name}
))}
))}
))}
);
}
/* ---------- Terminals (multiplexer) ---------- */
function TerminalsView({ focus, setFocus }) {
const cells = D.projects[0].groups[0].sessions;
return (
web · multiplexer 2 × 2
{cells.map((s) => (
setFocus(s.id)}>
{s.agent} · {s.name}
{renderTerm(D.terminals[s.id] || [['d','idle'],['caret']])}
))}
);
}
/* ---------- Editor ---------- */
function FileTree({ nodes, depth = 0 }) {
return nodes.map((n, i) => (
{n.name}
{n.dir && n.children && n.open !== false ?
: null}
));
}
const CODE = [
['cm', '/* desk shell tokens */'],
['', ''],
['kw', ':root', ' {'],
['', ' --desk-bg: ', 'st', 'hsl(188, 45%, 4%)', '', ';'],
['', ' --desk-accent: ', 'st', 'hsl(48, 90%, 62%)', '', ';'],
['', ' --desk-line-strong: ', 'st', 'hsl(180, 95%, 58%)', '', ';'],
['', '}'],
['', ''],
['kw', '.deskCmd', ' {'],
['', ' clip-path: ', 'fn', 'octagon', '', '(6px);'],
['', ' box-shadow: inset 0 0 0 1px ', 'nm2', 'var(--desk-line)', '', ';'],
['', '}'],
];
function EditorView() {
return (
theme.ts
styles.css
README.md
{CODE.map((parts, i) => (
{i + 1}
{parts.length <= 2 ? {parts[1] || '\u00a0'} :
parts.reduce((acc, _, j) => j % 2 === 0 ? [...acc, {parts[j + 1]}] : acc, [])}
))}
);
}
/* ---------- Git ---------- */
function GitView() {
const { staged, unstaged } = D.changes;
return (
main{Badge ? ↑2 ↓0 : null}
Staged · {staged.length}
{staged.map((c, i) =>
{c.b.toUpperCase()}{c.n} {c.dir}
)}
Changes · {unstaged.length}
{unstaged.map((c, i) =>
{c.b.toUpperCase()}{c.n} {c.dir}
)}
History
{D.commits.map((c, i) => (
{c.h}
{c.s} {c.head ? HEAD : null}
{c.who} · {c.t}
))}
);
}
function Placeholder({ icon, label }) {
return {label}
{label} subsystem
;
}
/* ---------- Projects (GitHub Projects v2 — kanban) ---------- */
function ProjectsView() {
const b = D.board;
const total = b.columns.reduce((n, c) => n + c.cards.length, 0);
const [dragId, setDragId] = useState(null);
return (
{b.name}
{total} items
{b.columns.map((col) => (
{col.name} {col.cards.length}
{col.cards.map((c) => (
setDragId(c.id)} onMouseUp={() => setDragId(null)} onMouseLeave={() => setDragId(null)}>
{c.id}{c.est}pt
{c.t}
{c.tags.map((t) => {t})}
{c.who}
))}
add card
))}
);
}
/* ---------- Notes (sidebar + markdown) ---------- */
function renderNote(body) {
return body.map((blk, i) => {
const [k, t] = blk;
if (k === 'h') return {t}
;
if (k === 'h2') return {t}
;
if (k === 'li') return ▸{t}
;
if (k === 'code') return {t};
return {t}
;
});
}
function NotesView() {
const [active, setActive] = useState(D.notes.find((n) => n.active)?.id || D.notes[0].id);
const note = D.notes.find((n) => n.id === active) || D.notes[0];
return (
Notes
{D.notes.map((n) => (
setActive(n.id)}>
{n.title}{n.tag} · {n.edited}
))}
{note.title}
autosaved
{renderNote(note.body)}
);
}
/* ---------- Status bar ---------- */
function StatusBar({ view, selected }) {
const sess = D.projects.flatMap(p => p.groups.flatMap(g => g.sessions)).find(s => s.id === selected);
return (
{view}
{sess ? {sess.agent} · {sess.name} : null}
1 attention
muted
14:32
);
}
/* ---------- Shell ---------- */
function Workspace() {
const [view, setView] = useState('terminals');
const [selected, setSelected] = useState('s2');
const [focus, setFocus] = useState('s2');
useLucide([view, selected, focus]);
return (
{}} />
{view === 'terminals' ? (
{ setSelected(id); setFocus(id); }} />
{ setFocus(id); setSelected(id); }} />
) : view === 'channels' ?
: view === 'editor' ?
: view === 'git' ?
: view === 'projects' ?
: view === 'notes' ?
:
s.id===view).icon} label={view} /> }
);
}
ReactDOM.createRoot(document.getElementById('root')).render();