summaryrefslogtreecommitdiff
path: root/HutchTests
Commit message (Collapse)AuthorAgeFilesLines
* Update test fixtures to [email protected] emailChristian Cleberg43 hours2-5/+5
|
* fix: move the S1186 empty-block comments inside the bracesChristian Cleberg2026-07-161-1/+1
| | | | | | Trailing // comments after {} left the block lexically empty, so SonarCloud kept flagging stopLoading (and would have re-flagged the two Cancel buttons). S1186 wants a *nested* comment; use /* ... */ inside.
* chore: clear the actionable SonarCloud code smellsChristian Cleberg2026-07-161-1/+2
| | | | | | | | | | | | | | | | | | | - S1871: merge the identical .home / .recentActivity deep-link cases in RootView — recent activity is a section of Home, not its own screen. - S1186: comment the two intentionally-empty Cancel buttons (PatchsetDetailView, TicketDetailView) and the empty URLProtocol stopLoading override in APICacheTests. - S108: comment the expected-miss catch block in APICacheTests. - S1172: rename the unused url parameter in mimeType(for:) to _. - S4624: extract the nested template literal in the deep-link builders (background.js, content.js) to a pathSegment variable. Left as Won't Fix, with reasons: the 35 hardcoded-URI warnings (a one-forge client and its literal-URL tests), executeCached's 8 params (38 call sites, no benefit), the forceRefresh S1172 pair (fixed as a real bug instead), S1481 on ArtifactsView (false positive — $vm.error is used), and S7785 (top-level await would break a classic content script).
* Merge pull request #5 from zerolabsco/inbox-unread-baselineChristian Cleberg2026-07-152-0/+181
|\ | | | | Start a new account at zero unread
| * fix: derive inbox activity from mail, not thread.updatedChristian Cleberg2026-07-151-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thread.updated is the root email's insert time. It never advances when a reply arrives, despite the name and despite the schema describing threads as ordered "most recently bumped". sr.ht returns updated seven seconds after root.date on a thread carrying four replies: subject: "Re: test post" updated: 2026-07-16T03:44:55Z replies: 4 root: { date: 2026-07-15T22:44:48-05:00 } The app fed that field into lastActivityAt everywhere, so a reply to an old thread was invisible: it did not mark the thread unread, did not raise it in the list, and did not update the timestamp beside it. This was inert until the unread baseline landed, because an absent view record returned unread unconditionally and the date was never compared to anything. The baseline did not break unread; it was the first code to depend on that field meaning what it says. Use MailingList.emails instead, which is real reverse-chronological arrival data, keyed by thread root id. The scan stops once it is older than the cutoff, so a quiet list costs one page and a busy one costs only what is new. Threads with nothing in the window keep the root timestamp and stay read, which they already were. Failure returns empty activity rather than throwing: unread is a decoration and should not take the thread list down with it. Uses Email.received rather than Email.date — received is server-side and non-null, date comes from the sender's header and is neither.
| * fix: start a new account at zero unreadChristian Cleberg2026-07-151-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An absent view record read as unread, so on first sign-in every thread a list had ever carried was unread. On a busy list that is thousands of threads the user never intended to read, inflating the Home dashboard, the needs-attention snapshot, and the widget with a number that means nothing. Record a baseline when an account is activated: mail that predates it is read, mail after it is not. activate() is the single funnel for launch validation, account switching, and adding an account, so one call covers every sign-in path. Accounts that already carry read state have been in use, so they get a distantPast baseline and keep every unread thread they had — upgrading must not silently mark a real backlog as read. markUnread now records an explicit distantPast marker instead of deleting the entry. Deleting would drop the thread back to the baseline rule, so marking an old thread unread would appear to do nothing.
* | feat: review patchsetsChristian Cleberg2026-07-151-0/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patchsets are how contributions reach sourcehut, and Hutch had no reference to them anywhere. This adds review and triage: read a series, see its checks and version chain, and set its status. Two schema facts shaped the design. MailingList exposes no patchsets field, so a list's patchsets cannot be queried directly. They are reachable only through thread roots, so the existing threads query now also selects root.patchset — no extra request — and the Patches tab is derived from that. It appears only on lists that actually carry patches. Patch carries no diff. index, count, version, prefix, subject, and trailers are all it has; the diff exists only inside the email body. Patch bodies are split with the same InboxThreadUtilities.segmentMessageBody the inbox uses and rendered through the existing DiffView. Patches are ordered by their [PATCH n/m] index rather than receipt order, since mail arrives out of sequence. Patches with no index are kept at the end rather than dropped, because a one-off patch has no prefix. updatePatchset is nullable, so a null response is treated as a declined change and the local status is left alone rather than advanced optimistically. UNKNOWN and SUPERSEDED are not offered: the first is a sentinel, the second is set by the server when a newer version lands. Patch submission stays out of scope. It is a git send-email flow, not a GraphQL mutation.
* | refactor: share the email body diff splitterChristian Cleberg2026-07-151-1/+1
|/ | | | | | | | | | | | | segmentMessageBody and its helpers were private to ThreadViewModel, reachable from tests only through a segmentMessageBodyForTesting shim. Patchset review needs the same splitting, because sr.ht's Patch type carries no diff — the diff only exists inside the email body — so this has to be shared rather than duplicated. Moved to InboxThreadUtilities. The shim is gone; the existing test calls the real function directly now. Also adds the Patchset model layer that the coming views build on.
* Phase 1: close the write gaps (#3)v3.6.0Christian Cleberg2026-07-151-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor: collapse duplicated request paths in SRHTClient Five request paths each repeated the token guard, header setup, status-code handling, and a ~35-line #if DEBUG logging block. The file carried that block five times over. Extract makeAuthorizedRequest, send, and encodedGraphQLBody, and route execute, executeAndCache, executeMultipartFiles, and performGraphQLRequest through them. executeMultipart is now the single-file case of executeMultipartFiles, which it already was byte for byte. 938 lines to 612, with one copy of the logging block. fetchText keeps its own guard: it is a GET to an allowlisted URL and must not run GraphQL error checks over what is usually a plain-text build log. One behavior change falls out. executeAndCache wrote the raw response to the cache before decoding, so a 200 carrying GraphQL errors was cached and then thrown. Routing it through performGraphQLRequest surfaces those errors first, so error payloads are no longer cached. * feat: edit and delete tickets updateTicket and deleteTicket both existed in todo.sr.ht's API but were never called, so a ticket could be filed and its status changed but its subject and body were frozen from the moment it was created, and it could never be removed. Edit opens a sheet seeded with the current subject and body. The input carries only fields that actually changed, so an edit cannot clobber a field the user did not touch, and Save stays disabled until something differs. Clearing the body sends an explicit null via updateValue rather than a nil subscript assignment, which would drop the key and silently leave the old body in place — the same trap fixed for repository descriptions in 7ffef07. Delete is destructive and irreversible, so it sits behind a confirmation dialog naming the ticket and pops the detail view on success. * feat: subscribe to and unsubscribe from tickets ticketSubscribe and ticketUnsubscribe existed in the API but were never called, so email notifications for a ticket could only be managed on the web. Ticket.subscription is null when the user is not subscribed, so the detail query now reads it and the menu reflects real server state rather than guessing. The toggle updates optimistically and reverts on failure, so the control never claims a subscription that did not take. Decoded into the private payload rather than TicketDetail, which is Codable and cached — adding a field there would have changed the cached shape and touched every optimistic-update construction site. * feat: subscribe to and unsubscribe from trackers trackerSubscribe and trackerUnsubscribe existed in the API but were never called. Tracker.subscription is null when not subscribed, so the state can be read rather than guessed. The read is a separate uncached query. The tickets query it sits beside is paginated and cached, and a per-user subscription has no business riding along in page payloads or being served stale from disk. Unsubscribe passes tickets: false, so leaving a tracker does not silently drop subscriptions to individual tickets the user opted into. * feat: unsubscribe from mailing lists mailingListUnsubscribe existed in the API but was never called, so the list of subscriptions was readable and nothing more. Scoped to unsubscribe. MailingList has no subscription field, unlike Ticket and Tracker, so per-list state is only knowable from the subscriptions query — which is exactly what builds this view. Subscribing would need a list the user is by definition not subscribed to, and sr.ht exposes no discovery API to find one (see SCOPE.md on hub.sr.ht), so there is nowhere honest to put that action yet. The row is removed optimistically and restored if the mutation fails. The confirmation says plainly that Hutch cannot resubscribe, since it cannot. * feat: manage todo and lists email preferences updatePreferences existed on both services but was never called, so these were web-only settings. The two services expose preferences/updatePreferences under identical names but with different fields — notifySelf on todo, copySelf on lists — and there is no shared preferences service, so both are read and written side by side. They load concurrently and one service being unreachable does not hide the other's toggle. These are server-side and apply beyond Hutch, unlike the @AppStorage toggles above them in Settings, so the footer says so and each toggle reverts if its mutation fails. * refactor: drop the memory-only cache path Two executeCached overloads existed with different return types and semantics: one doing stale-while-revalidate against the persistent cache with TTLs, the other only consulting the in-memory responseCache. The second was an easy thing to reach for by mistake, since the compiler picked it purely on argument labels. It turned out to be dead. All 38 call sites already used the TTL-aware overload, and the memory-only one was the sole caller of executeAndCache, so both are removed. Its doc comment promised refresh "via the onRefresh callback", which the signature has not had for some time. SRHTClient is now 569 lines, down from 938 before this branch. responseCache stays as the in-memory layer behind cachedPayload and the three view models that read it directly. * chore: bump to 3.6.0 and record Phase 1 MARKETING_VERSION 3.5.0 -> 3.6.0, build 87 -> 88. * fix: decode preferences responses on the main actor The module sets SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor, so the response types are implicitly main-actor isolated and their Decodable conformances are too. Decoding straight from an `async let` used those conformances from a nonisolated context, which warns today and is an error in the Swift 6 language mode. Move each fetch into its own method and `async let` over those instead, so decoding stays on the main actor. This is what HomeViewModel.loadDashboard already does, and the concurrency is unaffected — the network work still overlaps, since execute suspends and frees the actor.
* test: match cached incident fixture to its RSS sourceChristian Cleberg2026-07-151-1/+1
| | | | | | | The expected incident declared url: nil while the cachedIncidentRSS it stands in for carries <link>https://status.sr.ht/issues/1/</link>, so the fixture contradicted its own input. The repository parses and persists the link correctly.
* test: assert image URLs are not double-escapedChristian Cleberg2026-07-151-1/+4
| | | | | | | | | | markdownImageQueryStringPreservesAmpersands rejected any "amp;metric" in the rendered HTML, but `&amp;` is the correct encoding for `&` in an attribute value and is what a browser needs to request a literal `&`. The assertion conflated the URL with its HTML encoding. Target the real failure mode instead: double-escaping, which would send "&amp;" through as part of the query string and break badge images.
* test: repair stale expectations and request-body captureChristian Cleberg2026-07-153-6/+28
| | | | | | | | | | | | | | | These tests drifted from the code and went unnoticed because CI never ran them. All four are test-side errors; no app behavior is involved. - TicketListViewModelTests asserted lowercase "resolved"/"fixed"/"reported" against TicketStatus/TicketResolution rawValues, which are uppercase to match the todo.sr.ht GraphQL enums. - HomeViewModelTests expected failedBuilds in ascending id order. Ordering moved to newest-first when sortBuildItemsForTriage landed in 5f6d545; the filtering the test covers is unchanged. - SettingsViewModelTests read request.httpBody inside a URLProtocol, where it is always nil because URLSession moves the body onto httpBodyStream. The stub now reads the body off the stream at capture time.
* feat: add App Intents for Hutch navigationChristian Cleberg2026-05-143-0/+23
| | | | | | | | | | - add read-only App Intents for core Hutch workflows - route intents through the existing Hutch navigation/deep-link model - expose Work Queue, Recent Activity, System Status, pinned resources, projects, failed builds, assigned tickets, saved searches, and search where supported - keep App Intents non-mutating for the initial implementation - preserve existing widget, Safari extension, and hutch:// routing behavior References: https://todo.sr.ht/~ccleberg/hutch/71
* feat: add Safari extension for sourcehut deep linksv3.4.0Christian Cleberg2026-05-143-1/+83
|
* feat: add persistent stale-while-revalidate API cacheChristian Cleberg2026-05-062-0/+310
| | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an actor-backed persistent cache layer at the SRHTClient boundary for read-only SourceHut data. Cache entries now store stable metadata including key, resource type, fetched/expires/access timestamps, payload hash, schema version, and payload size, with bounded memory and disk usage. Add centralized cache key builders and TTL defaults for repository, file, ticket, build, log, profile, status, and list-style resources. Support networkOnly, cacheOnly, cacheFirstThenRefresh, and refreshIgnoringCache policies, plus request coalescing for duplicate in-flight cache keys. Integrate first-pass caching into high-value low-risk read paths: - build detail and completed/active build logs - ticket detail - README lookup - repository tree, blob, and linked file reads Keep mutation paths network-only and add simple prefix invalidation after ticket and build mutations. Add compact cached/stale UI status rows and a Settings action to clear the persistent cache. Add focused cache tests covering round trips, expiration, stale fallback, policy behavior, request coalescing, prefix invalidation, size limits, LRU pruning, expired pruning, and mutation bypass behavior. Document storage, key, TTL, invalidation, limitations, and next recommended targets.
* fix: profile loading error and user-timeline prefs updatev3.2.1Christian Cleberg2026-04-232-5/+108
|
* fix: collapse work inbox messages into thread summariesv3.2.0Christian Cleberg2026-04-202-52/+55
|
* fix: add mark all read actions and avoid resending unchanged repo metadataChristian Cleberg2026-04-201-0/+33
|
* feat: user-defined time period for recent builds cardChristian Cleberg2026-04-201-0/+71
| | | | | | | | | - limit Home failed-build counts to a configurable lookback window and add the setting under Behavior. - make the Recent and Builds rows fully tappable across the entire cell and add coverage for the new failed-build filtering. Fixes: https://todo.sr.ht/~ccleberg/hutch/67
* fix: change failed builds card on home tab to navigate to builds tab instead ↵Christian Cleberg2026-04-201-0/+11
| | | | | | of implementing its own view Fixes: https://todo.sr.ht/~ccleberg/hutch/66
* fix: Sonar issues in BundleUserAgentTests and accept README URL path joinv3.1.11Christian Cleberg2026-04-191-4/+6
|
* fix: finish half-completed storekit implementationChristian Cleberg2026-04-191-0/+22
|
* fix: fixes dead relative links in md/org with a new single-file viewer when ↵Christian Cleberg2026-04-151-0/+101
| | | | | | tapped Fixes: https://todo.sr.ht/~ccleberg/hutch/63
* feat: add custom hutch user-agent to api callsChristian Cleberg2026-04-151-0/+130
| | | | Implements: https://todo.sr.ht/~ccleberg/hutch/64
* fix: sonarqube code smell fixesv3.1.4Christian Cleberg2026-04-137-54/+64
|
* fix: centralize URLs, tighten models, and polish SwiftUI bindingsv3.1.3Christian Cleberg2026-04-136-133/+171
| | | | | | | | | | | | | | | | | | | | - Add shared HutchDeepLinkURL constants for app, widgets, and tests. - Bump marketing version to 3.1.2 and build to 70 (app + widget extension). - Point Hutch stats default base URL at HutchStatsAPI; add SRHTWebURL status incident feed and reuse it from SystemStatusService. - Group Project into Metadata and Resources; split ContributionStatsResponse into StatsWindow and StatsTotals with updated decoding and tests. - Replace @Bindable usage with explicit Bindings in Profile, Projects list, and repository ACL flows; simplify Home pinned-item helper; add no-op bodies on cancel alert buttons where the compiler requires a statement. - Move repository row build-status indicator next to the relative-updated caption and reserve a fixed 8×8 slot so the row does not jump when status loads. - Use NSString.lastPathComponent for build artifact filenames; collapse duplicate ACL error branches; minor HutchStats HTTP and XMLParserDelegate cleanups. - Point widgets at HutchDeepLinkURL helpers; align tests with the new response and URL types.
* fix: mercurial parity and graphql handlingv3.0.4Christian Cleberg2026-04-131-0/+29
| | | | | | | | | | - implements consistent UX between repo types - ensures centralized services and routes are used between repo types - graphql error handling is centralized - error messages are consistent Implements: https://todo.sr.ht/~ccleberg/hutch/58 Implements: https://todo.sr.ht/~ccleberg/hutch/59
* feat: add power user actionsChristian Cleberg2026-04-131-0/+34
| | | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/52 Implements: https://todo.sr.ht/~ccleberg/hutch/53 Implements: https://todo.sr.ht/~ccleberg/hutch/54
* feat: add multi-account supportChristian Cleberg2026-04-122-0/+60
| | | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/49 Implements: https://todo.sr.ht/~ccleberg/hutch/50 Implements: https://todo.sr.ht/~ccleberg/hutch/51
* feat: add search and recent queriesChristian Cleberg2026-04-124-13/+126
| | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/47 Implements: https://todo.sr.ht/~ccleberg/hutch/48
* feat: add ticket label management and bulk actionsChristian Cleberg2026-04-122-0/+73
| | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/45 Implements: https://todo.sr.ht/~ccleberg/hutch/46
* feat: add repo settings managementChristian Cleberg2026-04-121-0/+26
| | | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/42 Implements: https://todo.sr.ht/~ccleberg/hutch/43 Implements: https://todo.sr.ht/~ccleberg/hutch/44
* feat: add repository acl managementChristian Cleberg2026-04-122-3/+176
| | | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/39 Implements: https://todo.sr.ht/~ccleberg/hutch/40 Implements: https://todo.sr.ht/~ccleberg/hutch/41
* feat: polish read-only project views and home integrationChristian Cleberg2026-04-122-0/+34
| | | | | | Refs: https://todo.sr.ht/~ccleberg/hutch/36 Refs: https://todo.sr.ht/~ccleberg/hutch/37 Refs: https://todo.sr.ht/~ccleberg/hutch/38
* feat: add ticket saved filters and label filteringChristian Cleberg2026-04-122-24/+136
| | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/32 Implements: https://todo.sr.ht/~ccleberg/hutch/33
* feat: add build log search and jump-to-error navigationChristian Cleberg2026-04-121-0/+30
| | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/29 Implements: https://todo.sr.ht/~ccleberg/hutch/30
* feat: add projects list, detail view, and home pinningChristian Cleberg2026-04-121-0/+28
| | | | | | Implements: https://todo.sr.ht/~ccleberg/hutch/26 Implements: https://todo.sr.ht/~ccleberg/hutch/27 Implements: https://todo.sr.ht/~ccleberg/hutch/28
* feat: add prioritization of polling hutch-stats for logged in userChristian Cleberg2026-04-121-0/+24
|
* add shortcuts widgets and power-user workflowsv2.15.0Christian Cleberg2026-04-123-0/+238
|
* improve home attention flows and cross-linkingv2.14.0Christian Cleberg2026-04-124-2/+122
|
* harden system status and app reliabilityv2.13.1Christian Cleberg2026-04-123-0/+221
|
* Fix stale tests for current Swift concurrency modelChristian Cleberg2026-04-114-4/+19
|
* Add SourceHut system status screen and home disruption bannerChristian Cleberg2026-04-112-0/+141
|
* feat: add contribution calendar to user profilesv2.11.0Christian Cleberg2026-04-111-0/+388
| | | | | | Add a trailing 365-day contribution heatmap to user profile views, backed by HutchStatsService. Includes calendar model, view model, SwiftUI calendar view, app configuration, and unit tests.
* Implement search history for Look Up pageChristian Cleberg2026-04-021-0/+75
|
* Add tracker management (delete/update, ACLs, labels)v2.7.0Christian Cleberg2026-04-011-0/+36
| | | | | | | | | | | | | - Add swipe actions (delete/edit) to tracker list - Add tracker settings menu on detail screen - Implement updateTracker and deleteTracker mutations - Implement ACL management (updateUserACL, updateTrackerACL, deleteACL) - Implement label management (createLabel, updateLabel, deleteLabel) - Add dedicated UI flows for ACLs and labels - Ensure state refresh after mutations - Handle loading, errors, and destructive confirmations Implements: https://todo.sr.ht/~ccleberg/Hutch/12
* fix(org): improve org-mode rendering supportv2.5.1Christian Cleberg2026-03-301-0/+102
|
* feat(markdown): finalize migration to apple/swift-markdown rendererv2.5.0Christian Cleberg2026-03-301-0/+10
|
* Migrate README markdown rendering to swift-markdown and fix badge imagesChristian Cleberg2026-03-301-54/+53
| | | | | | | | | | - replace the hand-rolled markdown parser with a MarkupVisitor renderer - keep the org-mode rendering path and shared sanitization helpers intact - update WKWebView styling and height measurement for README content - fix linked image and query-string badge rendering in markdown output - expand README rendering tests and add markdown syntax coverage Implements: https://todo.sr.ht/~ccleberg/Hutch/2
* partial extended support for markdown and org-modeChristian Cleberg2026-03-301-0/+211
|