Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
5 changes: 1 addition & 4 deletions desk/sys.kelvin
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
[%zuse 416]
[%zuse 415]
[%zuse 414]
[%zuse 413]
[%zuse 409]
2 changes: 2 additions & 0 deletions ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Buffer from './Buffer';
import { DEFAULT_SESSION, SESSION_ID_REGEX } from './constants';
import { showSlog } from './lib/blit';
import { InfoButton } from './InfoButton';
import { SpinInfoBar } from './SpinInfoBar';
import { scrySessions, pokeTask } from './lib/utils';

const initSessions = async () => {
Expand Down Expand Up @@ -107,6 +108,7 @@ export default function TermApp() {
return (
<>
<ThemeProvider theme={dark ? _dark : _light}>
<SpinInfoBar />
<div className="header">
<Tabs />
<InfoButton />
Expand Down
80 changes: 80 additions & 0 deletions ui/SpinInfoBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { useEffect, useState } from 'react';
import { useDark } from './lib/useDark';

export const SpinInfoBar = () => {
const [spinStack, setSpinStack] = useState<string[]>([]);
const dark = useDark();

useEffect(() => {
console.log('spin: setting up...');
let available = false;
const spin = new EventSource('/~_~/spin', { withCredentials: true });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting that, with this and the /~_~/slog endpoint, and of course the eyre channel for herm subscriptions, this page now opens three SSE connections to your ship's domain, which iirc browsers limit to some max amount per domain (not per tab/window).

Of course, multi-tab urbiters are already hurting because of this, but this will hurt them even more.

Wonder if it's necessary, or if there even is some way we could demux/unify these connections somehow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just make it toggleable and off by default?


spin.onopen = () => {
console.log('spin: opened stream');
available = true;
};

spin.onmessage = (e) => {
console.log('spin message:', e.data);
// The data is expected to be a path like /stack3/stack2/stack1/stack0
// We need to parse it into an array of stack names
if (e.data && typeof e.data === 'string') {
// Remove leading slash if present and split by slash
const stackPath = e.data.startsWith('/') ? e.data.substring(1) : e.data;
const stackArray = stackPath.split('/').filter(Boolean);
setSpinStack(stackArray);
}
};

spin.onerror = (e) => {
console.error('spin: eventsource error:', e);
if (available) {
window.setTimeout(() => {
if (spin.readyState !== EventSource.CLOSED) {
return;
}
console.log('spin: reconnecting...');
// We would call the setup function again here, but we don't want to
// create multiple event listeners in this effect
}, 10000);
}
};

return () => {
spin.close();
};
}, []);

if (spinStack.length === 0) {
return null;
}
Comment on lines +37 to +40
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes it to not render until we've heard something from the spin endpoint. Should be nearly instant usually, but you can imagine cases (problematic cases) where that takes a hot second or longer. This causes a rough "pop-in" effect, especially given that styling was updated so that the terminal window doesn't hit the bottom of the viewport until this element comes into existence.

Should just render it unconditionally.


return (
<div className="spin-info-bar" style={{
backgroundColor: dark ? 'rgb(42, 42, 42)' : '#f0f0f0',
color: dark ? 'rgba(255, 255, 255, 0.9)' : 'black',
padding: '4px 10px',
fontSize: '12px',
fontFamily: 'monospace',
borderBottom: `1px solid ${dark ? 'rgba(255, 255, 255, 0.2)' : '#ccc'}`,
display: 'flex',
alignItems: 'center',
height: '24px',
}}>
<span style={{ marginRight: '5px', fontWeight: 'bold' }}>Spin Stack:</span>
{spinStack.map((stack, index) => (
<React.Fragment key={index}>
{index > 0 && <span style={{ margin: '0 5px' }}>&gt;</span>}
<span style={{
padding: '2px 6px',
backgroundColor: dark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.05)',
borderRadius: '3px',
}}>
{stack}
</span>
</React.Fragment>
))}
</div>
);
};
6 changes: 5 additions & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
}

.buffer-container {
height: calc(100% - 40px);
height: calc(100% - 40px - 24px);
position: relative;
}

.spin-info-bar {
width: 100%;
}

.terminal-container {
position: absolute;
top: 0;
Expand Down