Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jobs:
matrix:
os:
- ubuntu-24.04
- windows-latest
- macos-15

steps:
Expand Down
13 changes: 13 additions & 0 deletions docs/architecture/2026-09-19-ios-topic-detail-local-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@

日期:2026-09-19

Rust `layout_checksum` and `interaction_checksum` hash server fields only. The Swift builder folds local chrome onto those checksums: reply shortcut, reply-thread expansion, reaction-picker expansion, and text expansion go into the layout token; search highlight and `canWriteInteractions` join the in-place token with the local layout chrome. Do not set `contentToken` or `inPlaceUpdateToken` to the bare Rust checksum. Topic detail data comes from `TopicDetailSession` snapshots. Swift does not merge pages.

详情页小操作不再为了刷新计数而 bump collection revision。实现是真相源:单测跟落地行为走,不为过期断言改产品幅度。

## 页面骨架

详情页按四块刷新,正文和评论仍在同一条滚动列表里:

| 区域 | 组成 | 刷新 |
| --- | --- | --- |
| 标题栏 | 系统返回、中间标题、右侧图标 | 标题和右侧图标各比一次,没变的槽不重画 |
| 头部正文 | 标题和标签、摘要、正文、表情图标、数值统计 | 标题和统计是独立 cell。原帖 cell 内作者、正文、操作图标、表情、楼层线按 `messageBands` 只刷变化的一块 |
| 评论列表 | 楼层头、消息 item、楼层尾 | 一条评论再拆成引用入口、图片、文案、展示更多。引用正文仍在文案段里。展开正文或楼层只刷展示更多,不重建图片 |
| 底部输入 | 正在输入、回复目标、输入框、校验文案 | 只改正在输入时不重写输入框 |

## 三档管道

`FireTopicDetailFeedUpdatePipeline` 仍按 token 选档:
Expand Down
1,203 changes: 1,203 additions & 0 deletions docs/architecture/2026-09-22-ios-topic-detail-session.md

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions docs/architecture/fire-native-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
| Session state | iOS Store holds extensive `@Published` state | Rust remains the source of truth for session snapshots; platforms consume pushed snapshot copies plus explicit command results |
| Pagination / cache policy | iOS Store orchestrates logic | Rust fully orchestrates, platforms receive paginated results |
| Error handling | Platforms classify errors and decide retries | Rust classifies and auto-retries, platforms only receive final outcomes |
| State updates | Platforms pull after refresh/message events | `FireAppCore` pushes immutable snapshots on the current stable boundaries (`session`, `topic_list`, `topic_detail_feed`, `notification_center`) while explicit pagination and screen commands remain platform-owned |
| State updates | Platforms pull after refresh/message events | `FireAppCore` pushes immutable snapshots on the stable global boundaries (`session`, `topic_list`, `notification_center`). Topic detail is a per-topic session observer, not a fourth `StateObserver` method |

---

Expand Down Expand Up @@ -151,6 +151,8 @@ The pushed boundaries are intentionally explicit and finite:
- `TopicListState`
- `NotificationCenterState`

Topic detail is not one of these global boundaries. Each open topic has its own `TopicDetailSession` and `TopicDetailObserver`. The host keeps one snapshot per topic and does not merge pages, cursors, or post trees.

```
Rust Core Platform
│ │
Expand Down Expand Up @@ -178,8 +180,8 @@ Rust automatically handles retries, backoff, and session refresh. Platforms only
Rust FireCoreError → FireUniFfiError → Platform behavior
───────────────────────────────────────────────────────────────────────────────────
Network → Network → Show network error
LoginRequired → LoginRequired → Surface request failure; no automatic logout/reset
StaleSessionResponse → StaleSessionResponse → Rust auto-retry, platform unaware
LoginRequired → LoginRequired → Topic detail publishes `ReadPathLoginRequest` on the session snapshot. The host runs cookie resync, then headless reauth, then `complete_read_path_login`. Failure stays on the topic snapshot as `LoginRequired`; there is no automatic logout
StaleSessionResponse → (not surfaced) → The topic-detail session retries once with `force_load = true` and the original `track_visit`. The platform does not see this error
CloudflareChallenge → CloudflareChallenge → Foreground-capable hosts may complete a platform-owned challenge WebView and let Rust retry once; otherwise surface the request failure
HttpStatus(429) → HttpStatus → Rust auto-backoff-retry
Storage → Storage → Degrade to no-cache mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,66 +45,6 @@ class TopicRepository(private val sessionStore: FireSessionStore) {
)
}

suspend fun fetchTopicDetailSourceSnapshot(
topicId: ULong,
targetPostNumber: UInt? = null,
forceLoad: Boolean = true,
trackVisit: Boolean = true,
allowSuggestedUnreadRoot: Boolean = false,
initialBatchSize: UShort = 40u,
loadMoreBatchSize: UShort = 40u,
maxAutoBatchesPerGesture: UByte = 3u,
maxAutoPostsPerGesture: UShort = 120u,
): TopicDetailSourceSnapshotState = withContext(Dispatchers.Default) {
sessionStore.fetchTopicDetailSourceSnapshot(
TopicDetailSourceQueryState(
topicId = topicId,
targetPostNumber = targetPostNumber,
allowSuggestedUnreadRoot = allowSuggestedUnreadRoot,
trackVisit = trackVisit,
forceLoad = forceLoad,
initialBatchSize = initialBatchSize,
loadMoreBatchSize = loadMoreBatchSize,
maxAutoBatchesPerGesture = maxAutoBatchesPerGesture,
maxAutoPostsPerGesture = maxAutoPostsPerGesture,
),
)
}

suspend fun fetchTopicDetailPage(
topicId: ULong,
targetPostNumber: UInt? = null,
forceLoad: Boolean = true,
trackVisit: Boolean = true,
allowSuggestedUnreadRoot: Boolean = false,
initialBatchSize: UShort = 40u,
loadMoreBatchSize: UShort = 40u,
maxAutoBatchesPerGesture: UByte = 3u,
maxAutoPostsPerGesture: UShort = 120u,
): TopicDetailPageState = withContext(Dispatchers.Default) {
sessionStore.fetchTopicDetailPage(
TopicDetailSourceQueryState(
topicId = topicId,
targetPostNumber = targetPostNumber,
allowSuggestedUnreadRoot = allowSuggestedUnreadRoot,
trackVisit = trackVisit,
forceLoad = forceLoad,
initialBatchSize = initialBatchSize,
loadMoreBatchSize = loadMoreBatchSize,
maxAutoBatchesPerGesture = maxAutoBatchesPerGesture,
maxAutoPostsPerGesture = maxAutoPostsPerGesture,
),
)
}

suspend fun loadMoreTopicPosts(
cursor: TopicSourceCursorState,
): TopicLoadMoreOutcomeState = withContext(Dispatchers.Default) {
sessionStore.loadMoreTopicPosts(
LoadMoreTopicPostsQueryState(cursor = cursor),
)
}

suspend fun fetchTopicAiSummary(
topicId: ULong,
skipAgeCheck: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,22 +739,15 @@ class FireSessionStore(
response
}

suspend fun fetchTopicDetailSourceSnapshot(
query: TopicDetailSourceQueryState,
): TopicDetailSourceSnapshotState = withContext(Dispatchers.IO) {
core.topics().fetchTopicDetailSourceSnapshot(query)
fun openTopicDetail(
request: uniffi.fire_uniffi_topics.TopicDetailOpenRequestState,
observer: uniffi.fire_uniffi_topics.TopicDetailObserver,
): uniffi.fire_uniffi_topics.TopicDetailSessionHandle {
return core.topics().openTopicDetail(request, observer)
}

suspend fun fetchTopicDetailPage(
query: TopicDetailSourceQueryState,
): TopicDetailPageState = withContext(Dispatchers.IO) {
core.topics().fetchTopicDetailPage(query)
}

suspend fun loadMoreTopicPosts(
query: LoadMoreTopicPostsQueryState,
): TopicLoadMoreOutcomeState = withContext(Dispatchers.IO) {
core.topics().loadMoreTopicPosts(query)
fun completeReadPathLogin(generation: ULong, succeeded: Boolean) {
core.session().completeReadPathLogin(generation, succeeded)
}

suspend fun startMessageBus(handler: MessageBusEventHandler): String = withContext(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package com.fire.app.ui.home

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import uniffi.fire_uniffi_topics.TopicDetailState
import uniffi.fire_uniffi_topics.TopicHomeRowCountPatchState
import uniffi.fire_uniffi_topics.TopicHomeUnreadDecisionState
import uniffi.fire_uniffi_types.TopicRowState

data class HomeTopicDetailPatch(
Expand All @@ -12,16 +13,18 @@ data class HomeTopicDetailPatch(
val views: UInt,
val lastReadPostNumber: UInt?,
val highestPostNumber: UInt,
val unread: TopicHomeUnreadDecisionState = TopicHomeUnreadDecisionState.STILL_UNREAD,
) {
companion object {
fun from(detail: TopicDetailState): HomeTopicDetailPatch {
fun from(patch: TopicHomeRowCountPatchState): HomeTopicDetailPatch {
return HomeTopicDetailPatch(
topicId = detail.id,
postsCount = detail.postsCount,
replyCount = detail.replyCount,
views = detail.views,
lastReadPostNumber = detail.lastReadPostNumber,
highestPostNumber = detail.highestPostNumber,
topicId = patch.topicId,
postsCount = patch.postsCount,
replyCount = patch.replyCount,
views = patch.views,
lastReadPostNumber = patch.lastReadPostNumber,
highestPostNumber = patch.highestPostNumber,
unread = patch.unread,
)
}
}
Expand All @@ -31,8 +34,8 @@ object HomeTopicDetailPatchRepository {
private val _patches = MutableStateFlow<Map<ULong, HomeTopicDetailPatch>>(emptyMap())
val patches = _patches.asStateFlow()

fun publish(detail: TopicDetailState) {
publishPatch(HomeTopicDetailPatch.from(detail))
fun publish(patch: TopicHomeRowCountPatchState) {
publishPatch(HomeTopicDetailPatch.from(patch))
}

fun publishPatch(patch: HomeTopicDetailPatch) {
Expand All @@ -46,11 +49,31 @@ object HomeTopicDetailPatcher {
return null
}
val topic = row.topic
val nextHasUnreadPosts = patch.lastReadPostNumber
?.let { it < patch.highestPostNumber }
?: row.hasUnreadPosts
val nextUnreadPosts = if (nextHasUnreadPosts) topic.unreadPosts else 0u
val nextNewPosts = if (nextHasUnreadPosts) topic.newPosts else 0u
val nextUnreadPosts: UInt
val nextNewPosts: UInt
val nextHasUnreadPosts: Boolean
when (patch.unread) {
TopicHomeUnreadDecisionState.WHEN_LAST_READ_MISSING -> {
nextHasUnreadPosts = row.hasUnreadPosts
if (row.hasUnreadPosts) {
nextUnreadPosts = topic.unreadPosts
nextNewPosts = topic.newPosts
} else {
nextUnreadPosts = 0u
nextNewPosts = 0u
}
}
TopicHomeUnreadDecisionState.CAUGHT_UP -> {
nextUnreadPosts = 0u
nextNewPosts = 0u
nextHasUnreadPosts = false
}
TopicHomeUnreadDecisionState.STILL_UNREAD -> {
nextUnreadPosts = topic.unreadPosts
nextNewPosts = topic.newPosts
nextHasUnreadPosts = true
}
}
if (topic.postsCount == patch.postsCount &&
topic.replyCount == patch.replyCount &&
topic.views == patch.views &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ class TopicDetailActivity : AppCompatActivity() {
vm.detail.collectLatest { detail ->
headerAdapter.detail = detail
if (detail != null) {
HomeTopicDetailPatchRepository.publish(detail)
pinnedTopicTitle = detail.title.trim()
if (toolbarTitlePinned) {
binding.topicDetailToolbar.title = pinnedTopicTitle
Expand Down
Loading
Loading