# Source structure Old Fella uses SwiftUI views, plain domain types, and a small service boundary. The app keeps Bluesky library types out of its views. XcodeGen reads `project.yml` and includes Swift files under `Sources/OldFella`. ## Responsibilities - `App` owns the app shell, navigation destinations, and composer presentation. - `Domain` contains posts, accounts, feeds, notifications, and moderation rules. - `State` owns observable app state, prepared row state, image caches, drafts, and timeline selection. - `Services` contains the Bluesky service boundary, its implementation, response parsing, network failures, and predictable test responses. - `Features` groups UI by user task, such as feeds, notifications, profiles, posts, media, and composing. - `Shared` contains UI and utilities that serve several features. The app entry point is `OldFellaApp.swift`. `AppModel` coordinates session state and asynchronous requests. Session generations and request identifiers prevent old responses from replacing newer state. ## Post presentation `PostRow` composes a full post from `PostAuthorHeader`, `PostText`, `PostMedia`, quote context, and `PostActions`. `PostListItem` adds repost attribution and reply context for feed and profile lists. Post detail and notifications reuse the same post parts. `ContextCard` owns the header, avatar placement, content spacing, indentation, and colored bar for compact post context. `ReplyContextRow` and `QuoteContextRow` supply content and behavior. Thread roots, replies, quotes, and notification post context use this layout. Tap actions do not determine the visible header layout. Text width can change when a quote appears inside another card. The bar follows the card content, so different line wrapping can change its total height. `PostText` owns text rendering and link handling. `PostMedia` selects existing image, GIF, and video views. Content and media warnings stay with the post or quote that owns them. Inline images use shared caches before showing placeholders. Newly loaded images fade in unless Reduce Motion is enabled. Cached inline images appear immediately. Posts and quotes retain separate thumbnail and full-size URLs. Inline views use the thumbnail when one is available. Local attachment previews also use reduced images. The image viewer shows a loading indicator before it fades in the full-size image. It never displays an inline thumbnail. The decoder preserves the source pixel dimensions for viewing and zooming. Reduce Motion disables the fade. Looping GIF videos pause offscreen and retain their player for five seconds. Inactive scenes release the player immediately. `NotificationActivityHeader` owns the notification icon, unread dot, and timestamp layout. Notification rows supply the author and action text. `AuthorAvatar` applies the same avatar moderation rule across post and notification headers. ## UIKit boundaries Thread detail uses SwiftUI scrolling and stable post identifiers. Its selected section reserves enough height to align the selected post below the navigation bar. Avoid adding a separate hosting controller inside a UIKit view for post content. That pattern detached the thread controller from the app and put browser presentation outside the normal controller hierarchy. The remaining bridges have different purposes. Safari, the full-screen video player, and the share extension connect to system controllers. The image viewer uses native zooming and gesture coordination. Animated image and inline video views supply media layers without additional playback controls. The composer uses UIKit for caret geometry, media paste, and input that is still being composed. Text styling alone does not require this bridge. Highlighting caches the text, font, and resolved colors across view updates. Text edits still reapply styles, including when pasted text replaces the same characters. Inline GIF videos use SwiftUI visibility callbacks. They do not install UIKit observers for scroll offset or bounds. Focused tests cover visibility in lists, scroll views, and threads without network access. The refresh probe caches its attached scroll view, control, and container. It discards the cache when attachment, visibility, or geometry changes. It retains the native initial loading spinner and its tint. SwiftUI owns pull-to-refresh. Post rows create the system share sheet when the person taps Share. The sheet provides the Copy action. The iPad size reader reports the physical screen size when its view enters a window. It does not perform repeated layout work. These findings identify extra work and fragile controller handling. They do not establish a measured performance loss for every UIKit bridge. Measure scrolling and typing before claiming a speed improvement. ## State and services `TimelinePolicy` selects visible feed rows without sorting them. The phone feed and iPad feeds use the same policy. `PostViewState` and `NotificationGroupState` keep updates local to affected rows. `AppModel` publishes resolved `PostViewState` objects after filtering. Each feed row receives an object directly. Row collections change only when their IDs or order change. Post updates change the existing objects. Reply context is prepared in the same state object. Preparation updates posts before it resolves their parent context. Unrelated cached posts do not invalidate that context. Parent changes still update the affected replies. `BlueskyService` defines the operations that the app needs. `ATProtoBlueskyService` owns authentication, session refresh, request dispatch, and Bluesky responses. `MockBlueskyService` supplies deterministic data for tests. Photo uploads normalize orientation and resize in pixels before JPEG encoding. Each image embed includes the final pixel width and height. The aspect-ratio metadata therefore matches the uploaded image. `AppModel` and `ATProtoBlueskyService` remain the largest units. Their request ownership and session state stay together in this refactor. Pure timeline selection and facet decoding live outside these coordinators. Feeds request 70 posts per page and stop loading when a page adds visible rows. Empty or filtered pages use a bounded fallback. Further pages load through the visible load-more control. Profile and moderation callers share pending requests in the app's injected `AppModel`. Account changes cancel this work and reject old responses. Notifications load related posts with at most three requests at once and preserve the server's notification order. Keep session refresh and request ownership together when changing service code. Keep moderation checks before visible content. Do not turn an unsuccessful network action into a successful local update. ## Changes and tests Use a shared component when content has the same presentation rules. Keep a separate component when its visible role or behavior differs. Add a variant only for a visible product difference, not for a caller's implementation detail. Run `just build` after a source move. Run `just test-agent OldFellaTests` for domain, state, and service changes. Select focused UI tests for the affected flows instead of running the whole UI suite.