Skip to content

Add Preferences > History pane with CHATHISTORY page-size knob - #27

Merged
buggerman merged 1 commit into
mainfrom
preferences-history-pane
Apr 25, 2026
Merged

Add Preferences > History pane with CHATHISTORY page-size knob#27
buggerman merged 1 commit into
mainfrom
preferences-history-pane

Conversation

@buggerman

Copy link
Copy Markdown
Owner

Summary

  • Add a dedicated History pane in Preferences. Surfaces the otherwise-invisible CHATHISTORY feature (introduced in Surface CHATHISTORY at the top of the channel buffer #21) where users go to configure — and gives the first knob worth exposing: how many older messages to fetch per "Load earlier messages" round-trip.
  • Default 50 (matches the previous hardcoded value), with options 50 / 100 / 250 / 500. Clamped to 1–500 at the read site so a manual defaults write can't ask the server for an absurd batch.
  • Includes a short explainer that frames what CHATHISTORY does and why the affordance only shows on supporting servers — answers the "is something broken on this server?" question users would otherwise ask.

Changes

  • Sources/BryggaCore/PreferencesKeys.swift — new chathistoryPageSize key + chathistoryPageSizeFallback (50) constant.
  • Sources/BryggaCore/IRC/IRCSession.swift — new public static func chathistoryPageSize() -> Int that reads + clamps the value. requestMoreHistory(for:) now calls it instead of using a hardcoded 50.
  • Sources/Brygga/Views/PreferencesView.swift — new HistoryPane tab with a Picker for the page size and a server-support explainer. Uses clock.arrow.circlepath SF Symbol.
  • Tests/IRCSessionTests.swift — three unit tests: fallback when unset, configured value honored, out-of-range clamping.

Test plan

  • swift build — passes
  • swift test — 121 tests pass (+3 new)
  • swiftformat --lint . — clean
  • Manual:
    • Open Preferences (Cmd+,) → History tab. Picker defaults to 50.
    • Change to 250. Connect to a server with CHATHISTORY (soju / ergo). Click "Load earlier messages" — observe Brygga sends CHATHISTORY BEFORE <chan> <anchor> 250.
    • Restart the app — picker remembers the chosen value.
    • defaults write <bundle-id> brygga.chathistoryPageSize -int 99999 then click Load — request still uses 500 (clamped).
    • Existing CHATHISTORY behavior on supporting servers is unchanged at the default 50.

Risk / rollback

  • Pure additive change. requestMoreHistory semantics are unchanged for users who never visit the new pane (default = previous hardcode).
  • Clamping at the read site protects against bad UserDefaults values from any source.
  • Revert: this single commit.

@buggerman
buggerman force-pushed the preferences-history-pane branch from 94e13f4 to 94e02ab Compare April 25, 2026 14:18
@buggerman
buggerman merged commit 3620feb into main Apr 25, 2026
1 check passed
@buggerman
buggerman deleted the preferences-history-pane branch April 25, 2026 19:03
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.

1 participant