Updated todos and notes

This commit is contained in:
2025-08-05 17:01:05 +03:00
parent 274dee5b25
commit 7b1ee08d61
9 changed files with 22 additions and 66 deletions

View File

@@ -11,8 +11,6 @@
The Discord alternative for Terminal nerds. The Discord alternative for Terminal nerds.
TODO(kyren): replace screenshot with tape (or have both?)
<p> <p>
<img src="./assets/eko-screenshot.png" width="100%" alt="Eko Showcase"> <img src="./assets/eko-screenshot.png" width="100%" alt="Eko Showcase">
</p> </p>

View File

@@ -98,8 +98,8 @@ ___] | |__] | \| | | \|`)
) )
func init() { func init() {
// HACK: to avoid a circular dependency, so core can transition to this // HACK(kyren): to avoid a circular dependency
// I don't like how go has this issue, I would rather slower compilations // so core can transition to this model
ui.NewAuth = func() tea.Model { ui.NewAuth = func() tea.Model {
return New() return New()
} }
@@ -159,7 +159,7 @@ func New() Model {
m.SetSignup(false) m.SetSignup(false)
m.Update(nil) // HACK: force an update m.Update(nil) // HACK(kyren): force an update
return m return m
} }

View File

@@ -180,7 +180,6 @@ func (m Model) View() string {
return m.tos.View() return m.tos.View()
case ConnectedAcceptedTos: case ConnectedAcceptedTos:
// TODO(kyren): auth
return m.loading.View() return m.loading.View()
case Authenticated: case Authenticated:

View File

@@ -212,7 +212,7 @@ func UpdateMessages(info *packet.MessagesInfo) {
Users: unknownUsers, Users: unknownUsers,
}) })
// Note: this is a naive approach // NOTE(kyren): this is a naive approach
// Ideally we check each message that was added/removed // Ideally we check each message that was added/removed
// For the frequency/receiver/sender id and only remove that // For the frequency/receiver/sender id and only remove that
// But it can be very slow when there are thousands of messages // But it can be very slow when there are thousands of messages
@@ -340,7 +340,7 @@ func UpdateNotifications(info *packet.NotificationsInfo) []snowflake.ID {
// When someone messages you, and you don't have a signal with him // When someone messages you, and you don't have a signal with him
// already, add a signal with him so you see his messages // already, add a signal with him so you see his messages
// PERF: IsFrequency is expensive so contains is checked first // PERF(kyren): IsFrequency is expensive so contains is checked first
if !slices.Contains(Data.Signals, source) && !IsFrequency(source) { if !slices.Contains(Data.Signals, source) && !IsFrequency(source) {
signals = append(signals, source) signals = append(signals, source)
} }
@@ -402,42 +402,6 @@ func SendFinalData() {
case <-done: case <-done:
log.Println("All final writes completed successfully") log.Println("All final writes completed successfully")
} }
// HACK: Give a small grace period for the writes to be processed
// Tweak this value as needed
// time.Sleep(20 * time.Millisecond)
// TODO:
// I think the issue is that it's random which of these 2 requests goes
// first (bcz it only does the first request after the client disconnects)
// I could fix it server side but eh maybe not
// this should instead use a method that blocks until a response was
// received, which may need a new gateway method to do that as currently
// it just always sends to the prograg
// If this is tedious enough it might be worth it to just do it on the
// server side
// Also later on I should probably remove the calculate notifs in core
// it can be replaced with just diff-ing incoming notifs
// this will most likely work fine although there are some issues with
// scopes like becoming an admin/no longer being admin or gaining
// or losing access to frequencies and of course msg deletions
// But it's probably the right approach (also WAYYYYYY faster)
// Then there is also the issue of when switching to a frequency
// not yet receiving the history so it says "no keep" bcz it's not loaded
// but with history it would've said "yes keep" so the solutin would
// be to rework it quite a bit to make it stateless or smthing
// Then that should be most issues when it comes to notifications
// just need to make sure local/remote notifs reset properly when
// reaching the bottom
// log.Println("BLOCKING...")
// <-ctx.Done()
// log.Println("CTX DANZO")
// TODO: remove this before release
// assert.NoError(ctx.Err(), "context has ran out of time!")
} }
func UpdateBlockedUsers(info *packet.BlockInfo) { func UpdateBlockedUsers(info *packet.BlockInfo) {

View File

@@ -128,10 +128,10 @@ func (m *Model) updateContent() {
glamour.WithWordWrap(lineWidth), glamour.WithWordWrap(lineWidth),
) )
content := m.content content := m.content
content = strings.ReplaceAll(content, "@", "") // HACK: workaround to remove mailto links content = strings.ReplaceAll(content, "@", "") // HACK(kyren): workaround to remove mailto links
content, err := r.Render(content) content, err := r.Render(content)
assert.NoError(err, "this should never error") assert.NoError(err, "this should never error")
content = strings.ReplaceAll(content, "", "@") // HACK: workaround to remove mailto links content = strings.ReplaceAll(content, "", "@") // HACK(kyren): workaround to remove mailto links
m.vp.SetContent(content) m.vp.SetContent(content)
} }

View File

@@ -405,7 +405,7 @@ func (m *Model) handleKeys(key tea.KeyMsg) {
m.handleNormalModeKeys(key) m.handleNormalModeKeys(key)
m.Save() m.Save()
case InsertMode: case InsertMode:
// Note: we don't want to save on insert mode // NOTE(kyren): we don't want to save on insert mode
// That'd mean it'd save on every keystroke which will // That'd mean it'd save on every keystroke which will
// be very annoying // be very annoying
m.handleInsertModeKeys(key) m.handleInsertModeKeys(key)
@@ -582,7 +582,7 @@ func (m *Model) handleNormalModeKeys(key tea.KeyMsg) {
runeLines = append(runeLines, []rune(line)) runeLines = append(runeLines, []rune(line))
} }
// Note: caps to line length, needed for len=0 col=0 // NOTE(kyren): caps to line length, needed for len=0 col=0
splittingCol := min(m.cursorColumn+1, len(line)) splittingCol := min(m.cursorColumn+1, len(line))
line := m.lines[m.cursorLine] line := m.lines[m.cursorLine]
after := line[splittingCol:] after := line[splittingCol:]
@@ -696,12 +696,12 @@ func (m *Model) handleInsertModeKeys(key tea.KeyMsg) {
return return
} }
// Note: commented out because enter is used to send a message // NOTE(kyren): commented out because enter is used to send a message
// even in insert mode, an alternative that discord uses is // even in insert mode, an alternative that discord uses is
// to use Shift+Enter for this functionality but unfortunately // to use Shift+Enter for this functionality but unfortunately
// this is not supported in bubbletea (probably due to terminal limitations) // this is not supported in bubbletea (probably due to terminal limitations)
// If there is a way to add this for Shift+Enter please notify me // If there is a way to add this for Shift+Enter please open an issue
// at Kyren223@proton.me // or a pull request and notify me, or email Kyren223@proton.me
// if key.Type == tea.KeyEnter { // if key.Type == tea.KeyEnter {
// line := m.lines[m.cursorLine] // line := m.lines[m.cursorLine]
@@ -1946,7 +1946,7 @@ func (m *Model) handleVisualModeKeys(key tea.KeyMsg) {
if motion == "p" { if motion == "p" {
m.Yank(copyOfPaste) // Restore m.Yank(copyOfPaste) // Restore
} }
// Note: we don't restore for "P" because we use it like // NOTE(kyren): we don't restore for "P" because we use it like
// <leader>p (we paste over and keep what we had) // <leader>p (we paste over and keep what we had)
// Shift+P in visual mode is pretty useless/uncommon // Shift+P in visual mode is pretty useless/uncommon
// So using that instead of adding <leader>p makes more sense // So using that instead of adding <leader>p makes more sense
@@ -2066,7 +2066,7 @@ func (m *Model) handleVisualLineModeKeys(key tea.KeyMsg) {
if motion == "p" { if motion == "p" {
m.Yank(copyOfPaste) // Restore m.Yank(copyOfPaste) // Restore
} }
// Note: we don't restore for "P" because we use it like // NOTE(kyren): we don't restore for "P" because we use it like
// <leader>p (we paste over and keep what we had) // <leader>p (we paste over and keep what we had)
// Shift+P in visual mode is pretty useless/uncommon // Shift+P in visual mode is pretty useless/uncommon
// So using that instead of adding <leader>p makes more sense // So using that instead of adding <leader>p makes more sense

View File

@@ -589,7 +589,7 @@ func DeleteNetwork(ctx context.Context, sess *session.Session, request *packet.D
return &ErrInternalError return &ErrInternalError
} }
// NOTE: important check, make sure they are the owner (authorized) // NOTE(kyren): important check, make sure they are the owner (authorized)
if network.OwnerID != sess.ID() { if network.OwnerID != sess.ID() {
return &ErrPermissionDenied return &ErrPermissionDenied
} }
@@ -1148,7 +1148,7 @@ func EditMessage(ctx context.Context, sess *session.Session, request *packet.Edi
return &ErrInternalError return &ErrInternalError
} }
// Note: it is possible to edit your messages in any context // NOTE(kyren): it is possible to edit your messages in any context
// regardless if you are in the network or if you have access to // regardless if you are in the network or if you have access to
// the frequency (or a user signal), as long as you know the message ID // the frequency (or a user signal), as long as you know the message ID
// This should be fine but may be changed later to be more strict // This should be fine but may be changed later to be more strict
@@ -1640,7 +1640,7 @@ func Authenticate(ctx context.Context, sess *session.Session, request *packet.Au
sess.Manager().AddSession(sess, user.ID, request.PubKey) sess.Manager().AddSession(sess, user.ID, request.PubKey)
// NOTE: as per the protocol, this must be the first message after auth // NOTE(kyren): as per the protocol, this must be the first message after auth
payload := &packet.UsersInfo{Users: []data.User{user}} payload := &packet.UsersInfo{Users: []data.User{user}}
ok := sess.Write(ctx, payload) ok := sess.Write(ctx, payload)
if !ok { if !ok {

View File

@@ -362,7 +362,7 @@ func (server *server) handleConnection(conn net.Conn) {
slog.InfoContext(ctx, "processor done") slog.InfoContext(ctx, "processor done")
}() }()
// NOTE: IMPROTANT LEGAL STUFF // NOTE(kyren): IMPROTANT LEGAL STUFF
// Sending this first thing, before client sends us any data // Sending this first thing, before client sends us any data
sendTosInfo(ctx, sess) sendTosInfo(ctx, sess)
@@ -552,15 +552,10 @@ func timeout[T packet.Payload](
apiRequest func(context.Context, *session.Session, T) packet.Payload, apiRequest func(context.Context, *session.Session, T) packet.Payload,
ctx context.Context, sess *session.Session, request T, ctx context.Context, sess *session.Session, request T,
) packet.Payload { ) packet.Payload {
// TODO(kyren): Remove the channel and just wait directly? // NOTE(kyren): We need to use a channel so timeout works properly
// No - We need to use a channel so timeout works properly
responseChan := make(chan packet.Payload) responseChan := make(chan packet.Payload)
// TODO: Check if this is now fixed after the rewrite: ctx, cancel := context.WithTimeout(ctx, timeoutDuration)
// currently just ignoring the given context
// this fixes the issue where the client disconnects so the server
// doesn't bother and cancels the request
ctx, cancel := context.WithTimeout(ctx, timeoutDuration) // no longer ignoring
defer cancel() defer cancel()
go func() { go func() {
@@ -607,7 +602,7 @@ func TokensPerRequest(requestType packet.PacketType) float64 {
case packet.PacketDeviceAnalytics: case packet.PacketDeviceAnalytics:
return 0.2 // arbitrary return 0.2 // arbitrary
// TODO: once I get more data for these, add them // TODO(kyren): once I get more data for these, add them
case packet.PacketBlockUser: case packet.PacketBlockUser:
case packet.PacketCreateFrequency: case packet.PacketCreateFrequency:
case packet.PacketCreateNetwork: case packet.PacketCreateNetwork:

View File

@@ -27,7 +27,7 @@ import (
const ( const (
// Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds
// TODO: change this to eko epoch when eko is production ready // TODO(kyren): change this to eko epoch when eko is production ready
Epoch int64 = 1288834974657 Epoch int64 = 1288834974657
nodeBits = 10 nodeBits = 10
stepBits = 12 stepBits = 12