Skip to content

Commit e8ccb4e

Browse files
committed
refactor(app): translate SSE stream comments to English
1 parent 115328c commit e8ccb4e

3 files changed

Lines changed: 41 additions & 41 deletions

File tree

‎packages/app/e2e/regression/android-sse-stall-recovery.spec.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { mockOpenCodeServer } from "../utils/mock-server"
44
import { installSseTransport } from "../utils/sse-transport"
55
import { expectSessionTitle } from "../utils/waits"
66

7-
// Mobil emülasyon: Android Chrome fetch yığını + dokunmatik viewport.
8-
// Arka plan lifecycle event'leri (visibilitychange/pageshow/online)
9-
// BİLEREK hiç ateşlenmiyor — in-stream watchdog'un bunlara bağımlı
10-
// olmadan ölü (half-open) stream'i toparladığı kanıtlanıyor.
7+
// Mobile emulation: Android Chrome fetch stack + touch viewport.
8+
// Background lifecycle events (visibilitychange/pageshow/online)
9+
// DELIBERATELY never fire — proving the in-stream watchdog recovers the
10+
// dead (half-open) stream without depending on them.
1111
test.use({ ...devices["Pixel 7"] })
1212

1313
const directory = "C:/OpenCode/AndroidStall"
@@ -27,18 +27,18 @@ test("recovers a silently dead (half-open) event stream without lifecycle events
2727
const first = await transport.waitForConnection()
2828
await expectSessionTitle(page, title)
2929

30-
// Son görülen chunk: bundan sonra sunucu tek bayt bile göndermiyor
31-
// (half-open soket). Lifecycle event'i yok — watchdog tek başına
32-
// ~30sn sonra abort edip 250ms içinde reconnect etmeli.
30+
// Last seen chunk: after this the server sends not a single byte
31+
// (half-open socket). No lifecycle events — the watchdog alone must
32+
// abort after ~30s and reconnect within 250ms.
3333
await transport.heartbeat()
3434
const second = await transport.waitForConnection({ after: first.id, timeout: 90_000 })
3535
expect(second.id).toBeGreaterThan(first.id)
3636

37-
// Ölü deneme watchdog tarafından abort edildi (hata/kapanma değil).
37+
// The dead attempt was aborted by the watchdog (not an error/close).
3838
const connections = await transport.connections()
3939
expect(connections.find((connection) => connection.id === first.id)?.endedBy).toBe("abort")
4040

41-
// Yeni stream canlı: gönderilen olay UI'ya düşüyor.
41+
// The new stream is live: the sent event reaches the UI.
4242
await transport.send({
4343
directory,
4444
payload: {

‎packages/app/src/context/server-sdk.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe("createStreamStallGuard", () => {
4444
const guard = createStreamStallGuard({ onStall: () => aborts++ })
4545

4646
guard.markChunk(0)
47-
// 6dk arka plan: heartbeat (10sn) çoktan kesilmiş
47+
// 6min in background: heartbeat (10s) long gone
4848
expect(guard.onVisible("visible", 360_000)).toBe(true)
4949
expect(aborts).toBe(1)
5050
})
@@ -84,7 +84,7 @@ describe("createStreamStallGuard onOnline", () => {
8484
const guard = createStreamStallGuard({ onStall: () => aborts++ })
8585

8686
guard.markChunk(0)
87-
// 6dk sessizlik: online sahte değil, gerçekten ölü stream
87+
// 6min of silence: online isn't spurious, the stream is truly dead
8888
expect(guard.onOnline(360_000)).toBe(true)
8989
expect(aborts).toBe(1)
9090
})

‎packages/app/src/context/server-sdk.tsx‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,17 @@ function currentDeltaFragment(event: CurrentDelta) {
160160
}
161161

162162
export function resumeStreamAfterPageShow(_event: PageTransitionEvent, start: () => unknown) {
163-
// Açık fetch() event stream bfcache'i engeller → pageshow'da persisted
164-
// çoğunlukla false gelir, gate'li start hiç çalışmazdı (#47258).
165-
// Gate kaldırıldı: start() idempotent (started ise mevcut run'ı döner).
163+
// An open fetch() event stream blocks bfcache, so `persisted` is mostly
164+
// false on pageshow and the gated start() never ran (#47258).
165+
// Gate removed: start() is idempotent (returns the current run when started).
166166
start()
167167
}
168168

169-
// Server her 10sn'de `server.heartbeat` gönderir (global.ts/event.ts) —
170-
// sağlıklı stream'de chunk aralığı ~10-15sn'yi geçmez. Arka planda ölen
171-
// (half-open) stream ne hata verir ne veri üretir; `start()` idempotent
172-
// guard'a takılıp no-op döndüğü için reconnect de tetiklenmez (#47258'in
173-
// devamı: Android'de pageshow çoğu zaman hiç ateşlenmez).
169+
// The server sends `server.heartbeat` every 10s (global.ts/event.ts), so a
170+
// healthy stream never goes ~10-15s without a chunk. A stream that dies in
171+
// the background (half-open) neither errors nor yields data, and the
172+
// idempotent `start()` guard degrades to a no-op, so no reconnect fires
173+
// either (follow-up to #47258: on Android, pageshow often never fires).
174174
export const STREAM_STALL_MS = 30_000
175175

176176
export function shouldForceReconnect(opts: {
@@ -180,15 +180,15 @@ export function shouldForceReconnect(opts: {
180180
}): boolean {
181181
if (opts.visible === false) return false
182182
const now = opts.now ?? Date.now()
183-
// Hiç chunk gelmediyse (bağlantı kurulurken background'a düşüldü vb.)
184-
// görünür sekmeye dönüşte zorla — abort zararsız, loop 250ms sonra dener.
183+
// No chunk ever arrived (e.g. backgrounded while connecting): force on
184+
// return to a visible tab — abort is harmless, the loop retries in 250ms.
185185
if (opts.lastChunkAt === undefined) return true
186186
return now - opts.lastChunkAt > STREAM_STALL_MS
187187
}
188188

189-
// Stall bekçisi: proot'ta (Android lifecycle olmadan) test edilebilen
190-
// ince katman. Gerçek DOM wiring'i (visibilitychange → onVisible,
191-
// online → onOnline) altta.
189+
// Stall guard: thin layer that stays testable in proot (no Android
190+
// lifecycle). The real DOM wiring (visibilitychange → onVisible,
191+
// online → onOnline) lives below.
192192
export function createStreamStallGuard(opts: { onStall: () => void }) {
193193
let lastChunkAt: number | undefined
194194
return {
@@ -201,8 +201,8 @@ export function createStreamStallGuard(opts: { onStall: () => void }) {
201201
opts.onStall()
202202
return true
203203
},
204-
// Ağ geri geldiğinde: görünürlükten bağımsız stall kontrolü.
205-
// `online` sahte de gelebilir — sağlıklı stream'e dokunulmaz.
204+
// On network return: stall check independent of visibility.
205+
// `online` can be spurious — a healthy stream is left alone.
206206
onOnline(now: number = Date.now()): boolean {
207207
if (!shouldForceReconnect({ lastChunkAt, now, visible: true })) return false
208208
opts.onStall()
@@ -299,10 +299,10 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
299299

300300
let streamErrorLogged = false
301301
const stallGuard = createStreamStallGuard({ onStall: () => attempt?.abort() })
302-
// In-stream watchdog (openchamber event-pipeline parity): hiçbir lifecycle
303-
// event'i (visibility/pageshow/online) ateşlenmese bile half-open stream
304-
// STREAM_STALL_MS'tan fazla yaşayamaz. Her chunk'ta resetlenir, süre
305-
// dolunca mevcut denemeyi abortlar — loop 250ms sonra reconnect dener.
302+
// In-stream watchdog (openchamber event-pipeline parity): a half-open
303+
// stream cannot outlive STREAM_STALL_MS even when no lifecycle event
304+
// (visibility/pageshow/online) ever fires. Reset on every chunk; on
305+
// expiry it aborts the current attempt — the loop reconnects in 250ms.
306306
let stallTimer: ReturnType<typeof setTimeout> | undefined
307307
const clearStallTimer = () => {
308308
if (stallTimer === undefined) return
@@ -321,8 +321,8 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
321321
let run: Promise<void> | undefined
322322
let started = false
323323
let generation = 0
324-
// offline'ta stop() edildiyse online'da start() ile devam et; pagehide
325-
// ile duran stream'i online diriltmesin diye ayrı bayrak tutulur.
324+
// If stop()ped while offline, resume with start() on online; a separate
325+
// flag so online doesn't resurrect a stream stopped via pagehide.
326326
let offlineStopped = false
327327

328328
const start = () => {
@@ -335,8 +335,8 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
335335
// oxlint-disable-next-line no-unmodified-loop-condition -- `started` is set to false by stop() which also aborts; both flags are checked to allow graceful exit
336336
while (!abort.signal.aborted && started && generation === active) {
337337
attempt = new AbortController()
338-
// Bağlantı kurulurken takılmaya karşı da kurulu başla (ilk chunk
339-
// gelmeden asılı kalan subscribe 30sn'de abort olur, loop dener).
338+
// Arm while connecting too, against a stuck subscribe (one hanging
339+
// before the first chunk aborts after STREAM_STALL_MS, the loop retries).
340340
armStallTimer()
341341
const onAbort = () => {
342342
attempt?.abort()
@@ -400,17 +400,17 @@ function createServerSdkContextBase(server: ServerConnection.Any, scope: ServerS
400400
onMount(() => {
401401
makeEventListener(window, "pagehide", stop)
402402
makeEventListener(window, "pageshow", (event) => resumeStreamAfterPageShow(event, start))
403-
// Android'de arka plan → ön plan dönüşünde pageshow çoğunlukla
404-
// ateşlenmez; ölü (half-open) stream `started` guard'a takılıp
405-
// sessizce asılı kalır. Görünürlüğe dönüşte stall varsa mevcut
406-
// denemeyi abortla — loop'un doğal 250ms reconnect yoluna girer.
403+
// On Android, background → foreground usually fires no pageshow; the
404+
// dead (half-open) stream stays silently stuck on the `started` guard.
405+
// On return to visibility, abort the current attempt when stalled —
406+
// the loop then takes its natural 250ms reconnect path.
407407
makeEventListener(document, "visibilitychange", () => {
408408
if (!started) return
409409
stallGuard.onVisible(document.visibilityState)
410410
})
411-
// Ağ kesilince 250ms retry spin'ine girme — loop'u durdur, timer'ı
412-
// temizle. Ağ dönünce: offline'ta durduysa `start()` ile devam et
413-
// (idempotent), çalışıyorsa sadece stall varsa abortla.
411+
// On network loss don't spin the 250ms retry loop — stop the loop and
412+
// clear the timer. On return: if stopped while offline, continue with
413+
// `start()` (idempotent); if running, abort only when stalled.
414414
makeEventListener(window, "offline", () => {
415415
if (!started) return
416416
offlineStopped = true

0 commit comments

Comments
 (0)