Skip to content

%spin hint bar #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
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
69 changes: 69 additions & 0 deletions ui/SpinInfoBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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) => {
// 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.substring(1);
const stackArray = stackPath.split('/');
setSpinStack(stackArray);
}
};

spin.onerror = (e) => {
console.error('spin: eventsource error:', e);
};

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

if (spinStack.length === 0) {
return null;
}

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>
);
};
8 changes: 6 additions & 2 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
<style>
body, #root {
height: 99vh; /* prevent scrollbar on outer frame */
height: 97vh; /* prevent scrollbar on outer frame */
margin: 0;
padding: 0;
}

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

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

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