Skip to content

Conversation

@vekovius
Copy link

@vekovius vekovius commented Nov 12, 2025

  • Add comprehensive documentation to String+DJB2 explaining the hash algorithm and its use case
  • Add enhanced documentation to String+Nickname with usage examples
  • Add StringUtilsTests with 24 test cases covering:
    • DJB2 hash consistency, case sensitivity, unicode handling
    • Nickname suffix parsing edge cases and validation
  • Add ColorPeerTests with 20 test cases covering:
    • Color consistency and caching behavior
    • Dark/light mode color differentiation
    • Orange hue avoidance for mention highlighting
    • Real-world scenarios with Nostr pubkeys and edge cases

vekoLSU and others added 4 commits July 9, 2025 17:35
…lor+Peer

- Add comprehensive documentation to String+DJB2 explaining the hash algorithm and its use case
- Add enhanced documentation to String+Nickname with usage examples
- Add StringUtilsTests with 24 test cases covering:
  * DJB2 hash consistency, case sensitivity, unicode handling
  * Nickname suffix parsing edge cases and validation
- Add ColorPeerTests with 20 test cases covering:
  * Color consistency and caching behavior
  * Dark/light mode color differentiation
  * Orange hue avoidance for mention highlighting
  * Real-world scenarios with Nostr pubkeys and edge cases
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +17 to +28
@Test func peerColor_sameSeedProducesSameColor() {
let color1 = Color(peerSeed: "alice", isDark: false)
let color2 = Color(peerSeed: "alice", isDark: false)

// Since the cache is static, both should produce the same color
// We can't directly compare Color objects, but we can verify they produce consistent hashes
#expect(color1.description == color2.description, "Same seed should produce same color")
}

@Test func peerColor_differentSeedsProduceDifferentColors() {
let color1 = Color(peerSeed: "alice", isDark: false)
let color2 = Color(peerSeed: "bob", isDark: false)

Choose a reason for hiding this comment

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

P0 Badge Add missing Color(peerSeed:isDark:) initializer

The new tests call Color(peerSeed:isDark:) but the production module does not define such an initializer anywhere in the repository. Because SwiftUI’s Color has no initializer with this signature, the test suite will not even compile once this file is included in the build. Either the initializer should be implemented in the app target or the tests need to use an existing API.

Useful? React with 👍 / 👎.

Comment on lines +31 to +39
func splitSuffix() -> (String, String) {
let name = self.replacingOccurrences(of: "@", with: "")
guard name.count >= 5 else { return (name, "") }
let suffix = String(name.suffix(5))
if suffix.first == "#", suffix.dropFirst().allSatisfy({ c in
("0"..."9").contains(String(c)) || ("a"..."f").contains(String(c)) || ("A"..."F").contains(String(c))
}) {
let base = String(name.dropLast(5))
return (base, suffix)

Choose a reason for hiding this comment

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

P1 Badge splitSuffix accepts nicknames with double '#' suffix

The new splitSuffix() treats any string whose last five characters look like # plus four hex digits as a valid suffix. This means names such as "test##1234" are parsed into base "test#" and suffix "#1234", even though the extra # indicates the string does not follow the expected <name>#<hex> form. The accompanying tests expect such inputs to be rejected, so the implementation should also verify that the character before the suffix is not '#' (or otherwise validate that only one delimiter is present) before splitting.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants