-
Notifications
You must be signed in to change notification settings - Fork 0
%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
mopfel-winrux
wants to merge
5
commits into
master
Choose a base branch
from
mw/spin_bar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
[%zuse 416] | ||
[%zuse 415] | ||
[%zuse 414] | ||
[%zuse 413] | ||
[%zuse 409] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
|
||
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' }}>></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> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?