GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into fix/preserve-pre-wake… · pingdotgg/t3code@06ad0e4
File treeExpand file treeCollapse file tree Open diff view settings provider-opencode/src/server source-control-bitbucket/src/server source-control-forgejo/src/server
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopObservability.test.ts +75Lines changed: 75 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,7 @@ import * as ConfigProvider from "effect/ConfigProvider"; | 6 | 6 | import * as Effect from "effect/Effect"; | 7 | 7 | import * as FileSystem from "effect/FileSystem"; | 8 | 8 | import * as Layer from "effect/Layer"; | | 9 | +import * as PlatformError from "effect/PlatformError"; | 9 | 10 | import * as Schema from "effect/Schema"; | 10 | 11 | import * as HttpClient from "effect/http/HttpClient"; | 11 | 12 | import * as HttpClientResponse from "effect/http/HttpClientResponse"; | @@ -302,6 +303,80 @@ describe("DesktopObservability", () => { | 302 | 303 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), | 303 | 304 | ); | 304 | 305 |
| | 306 | + it.effect("keeps earlier backups while the active log cannot be renamed", () => | | 307 | + Effect.gen(function* () { | | 308 | + const fileSystem = yield* FileSystem.FileSystem; | | 309 | + const directory = yield* fileSystem.makeTempDirectoryScoped({ | | 310 | + prefix: "t3-desktop-rotating-locked-test-", | | 311 | + }); | | 312 | + const filePath = `${directory}/server-child.log`; | | 313 | + yield* fileSystem.writeFileString(`${filePath}.1`, "previous"); | | 314 | + yield* fileSystem.writeFileString(`${filePath}.2`, "oldest"); | | 315 | + const writer = yield* DesktopObservability.makeRotatingLogFileWriter({ | | 316 | + filePath, | | 317 | + maxBytes: 4, | | 318 | + maxFiles: 2, | | 319 | + }).pipe( | | 320 | + Effect.provideService(FileSystem.FileSystem, { | | 321 | + ...fileSystem, | | 322 | + rename: (source, target) => | | 323 | + source === filePath | | 324 | + ? Effect.fail( | | 325 | + PlatformError.systemError({ | | 326 | + _tag: "PermissionDenied", | | 327 | + module: "FileSystem", | | 328 | + method: "rename", | | 329 | + pathOrDescriptor: source, | | 330 | + }), | | 331 | + ) | | 332 | + : fileSystem.rename(source, target), | | 333 | + }), | | 334 | + ); | | 335 | + | | 336 | + for (let attempt = 0; attempt < 3; attempt += 1) { | | 337 | + yield* writer.writeText("12345\n"); | | 338 | + } | | 339 | + | | 340 | + assert.deepEqual( | | 341 | + [ | | 342 | + yield* fileSystem.readFileString(`${filePath}.1`), | | 343 | + yield* fileSystem.readFileString(`${filePath}.2`), | | 344 | + ], | | 345 | + ["previous", "oldest"], | | 346 | + ); | | 347 | + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), | | 348 | + ); | | 349 | + | | 350 | + it.effect("keeps a log left staged by an interrupted rotation as a backup", () => | | 351 | + Effect.gen(function* () { | | 352 | + const fileSystem = yield* FileSystem.FileSystem; | | 353 | + const directory = yield* fileSystem.makeTempDirectoryScoped({ | | 354 | + prefix: "t3-desktop-rotating-staged-test-", | | 355 | + }); | | 356 | + const filePath = `${directory}/server-child.log`; | | 357 | + yield* fileSystem.writeFileString(filePath, "active"); | | 358 | + yield* fileSystem.writeFileString(`${filePath}.rotating`, "staged"); | | 359 | + yield* fileSystem.writeFileString(`${filePath}.1`, "previous"); | | 360 | + const writer = yield* DesktopObservability.makeRotatingLogFileWriter({ | | 361 | + filePath, | | 362 | + maxBytes: 8, | | 363 | + maxFiles: 3, | | 364 | + }); | | 365 | + | | 366 | + yield* writer.writeText("12345\n"); | | 367 | + | | 368 | + assert.deepEqual( | | 369 | + [ | | 370 | + yield* fileSystem.readFileString(`${filePath}.1`), | | 371 | + yield* fileSystem.readFileString(`${filePath}.2`), | | 372 | + yield* fileSystem.readFileString(`${filePath}.3`), | | 373 | + yield* fileSystem.exists(`${filePath}.rotating`), | | 374 | + ], | | 375 | + ["active", "staged", "previous", false], | | 376 | + ); | | 377 | + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), | | 378 | + ); | | 379 | + | 305 | 380 | it.effect("stops every export when the OpenTelemetry SDK is disabled", () => { | 306 | 381 | const requests: Array<ExportedRequest> = []; | 307 | 382 | return Effect.gen(function* () { | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopObservability.ts +14-6Lines changed: 14 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -271,7 +271,8 @@ export const makeRotatingLogFileWriter = Effect.fn("makeRotatingLogFileWriter")( | 271 | 271 | } | 272 | 272 | }); | 273 | 273 |
| 274 | | - const rotate = Effect.gen(function* () { | | 274 | + const staged = `${input.filePath}.rotating`; | | 275 | + const publishStaged = Effect.gen(function* () { | 275 | 276 | yield* fileSystem.remove(withSuffix(maxFiles), { force: true }).pipe(Effect.ignore); | 276 | 277 | for (let index = maxFiles - 1; index >= 1; index -= 1) { | 277 | 278 | const source = withSuffix(index); | @@ -280,11 +281,18 @@ export const makeRotatingLogFileWriter = Effect.fn("makeRotatingLogFileWriter")( | 280 | 281 | yield* fileSystem.rename(source, withSuffix(index + 1)); | 281 | 282 | } | 282 | 283 | } | 283 | | - const currentExists = yield* fileSystem | 284 | | - .exists(input.filePath) | 285 | | - .pipe(Effect.orElseSucceed(() => false)); | 286 | | - if (currentExists) { | 287 | | - yield* fileSystem.rename(input.filePath, withSuffix(1)); | | 284 | + yield* fileSystem.rename(staged, withSuffix(1)); | | 285 | + }); | | 286 | + | | 287 | + const rotate = Effect.gen(function* () { | | 288 | + const exists = (filePath: string) => | | 289 | + fileSystem.exists(filePath).pipe(Effect.orElseSucceed(() => false)); | | 290 | + // A log left staged by an interrupted rotation becomes a backup first. | | 291 | + if (yield* exists(staged)) yield* publishStaged; | | 292 | + // Move the active log aside before touching backups: while it cannot move, none is aged out. | | 293 | + if (yield* exists(input.filePath)) { | | 294 | + yield* fileSystem.rename(input.filePath, staged); | | 295 | + yield* publishStaged; | 288 | 296 | } | 289 | 297 | yield* Ref.set(currentSize, 0); | 290 | 298 | }).pipe( | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/preview/BrowserSession.test.ts +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -809,6 +809,27 @@ describe("BrowserSession", () => { | 809 | 809 | }).pipe(Effect.provide(layer)), | 810 | 810 | ); | 811 | 811 |
| | 812 | + it.effect("cuts a long certificate name without splitting an emoji", () => | | 813 | + Effect.gen(function* () { | | 814 | + const browserSessions = yield* BrowserSession.BrowserSession; | | 815 | + const partition = yield* browserSessions.getPartition("scope-a"); | | 816 | + yield* browserSessions.getSession("scope-a"); | | 817 | + const browserSession = sessions.get(partition); | | 818 | + | | 819 | + showMessageBox.mockReset(); | | 820 | + showMessageBox.mockReturnValue(1); | | 821 | + const longName = `${"a".repeat(119)}\u{1F600} dev certificate`; | | 822 | + const prompt = certificateError(browserSession, { | | 823 | + url: "https://localhost:18443/", | | 824 | + certificate: { ...selfSignedCertificate, subjectName: longName }, | | 825 | + }); | | 826 | + assert.isFalse(yield* prompt.trusted); | | 827 | + const detail = showMessageBox.mock.calls[0]?.[0].detail ?? ""; | | 828 | + const issuedTo = detail.split("\n").find((line) => line.startsWith("Issued to: ")); | | 829 | + assert.strictEqual(issuedTo, `Issued to: ${"a".repeat(119)}…`); | | 830 | + }).pipe(Effect.provide(layer)), | | 831 | + ); | | 832 | + | 812 | 833 | it.effect("asks before trusting an untrusted certificate and remembers the approval", () => | 813 | 834 | Effect.gen(function* () { | 814 | 835 | const browserSessions = yield* BrowserSession.BrowserSession; | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/preview/BrowserSession.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -163,7 +163,7 @@ const CERTIFICATE_APPROVALS_FILE = "t3code-certificate-approvals.json"; | 163 | 163 | /** Server-chosen certificate names must not add lines or flood the prompt. */ | 164 | 164 | const promptCertificateName = (name: string): string => { | 165 | 165 | const flat = name.replace(/\s+/g, " ").trim(); | 166 | | - return flat.length > 120 ? `${flat.slice(0, 120)}…` : flat; | | 166 | + return flat.length > 120 ? `${flat.slice(0, 120).replace(/\p{Surrogate}$/u, "")}…` : flat; | 167 | 167 | }; | 168 | 168 |
| 169 | 169 | const promptCertificateDate = (seconds: number): string => | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/thread-list-v2-items.tsx +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,6 +100,24 @@ interface StatusLabel { | 100 | 100 | readonly iconTintClassName: string; | 101 | 101 | } | 102 | 102 | const STATUS_LABEL_BY_STATUS: Partial<Record<ThreadListV2Status, StatusLabel>> = { | | 103 | + connecting: { | | 104 | + label: msg("Connecting", { $context: "connection status" }), | | 105 | + icon: "wifi.slash", | | 106 | + className: "text-foreground-muted", | | 107 | + iconTintClassName: "accent-foreground-muted", | | 108 | + }, | | 109 | + reconnecting: { | | 110 | + label: msg("Reconnecting", { $context: "connection status" }), | | 111 | + icon: "wifi.slash", | | 112 | + className: "text-foreground-muted", | | 113 | + iconTintClassName: "accent-foreground-muted", | | 114 | + }, | | 115 | + offline: { | | 116 | + label: msg("Offline", { $context: "connection status" }), | | 117 | + icon: "wifi.slash", | | 118 | + className: "text-foreground-muted", | | 119 | + iconTintClassName: "accent-foreground-muted", | | 120 | + }, | 103 | 121 | approval: { | 104 | 122 | label: msg("Approval", { $context: "thread status, waiting for approval" }), | 105 | 123 | icon: "exclamationmark.shield", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/threadListV2.test.ts +82Lines changed: 82 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -153,6 +153,74 @@ describe("layoutThreadListV2RowMenuActions", () => { | 153 | 153 | }); | 154 | 154 |
| 155 | 155 | describe("resolveThreadListV2Status", () => { | | 156 | + it.each(["preparing", "queued", "starting", "running", "waiting"] as const)( | | 157 | + "qualifies a cached %s runtime while reconnecting", | | 158 | + (status) => { | | 159 | + const thread = presentThreadShell( | | 160 | + environmentId, | | 161 | + makeRawThreadShell({ | | 162 | + status, | | 163 | + activeRunId: RunId.make("run-disconnected"), | | 164 | + latestRunId: RunId.make("run-disconnected"), | | 165 | + }), | | 166 | + ); | | 167 | + expect(resolveThreadListV2Status({ ...thread, connectionPhase: "reconnecting" })).toBe( | | 168 | + "reconnecting", | | 169 | + ); | | 170 | + }, | | 171 | + ); | | 172 | + | | 173 | + it.each(["failed", "completed", "cancelled", "interrupted"] as const)( | | 174 | + "preserves a cached %s outcome while disconnected", | | 175 | + (status) => { | | 176 | + const thread = presentThreadShell( | | 177 | + environmentId, | | 178 | + makeRawThreadShell({ | | 179 | + status, | | 180 | + latestRunId: RunId.make("run-ended"), | | 181 | + latestRunCompletedAt: DateTime.makeUnsafe(NOW), | | 182 | + lastVisitedAt: DateTime.makeUnsafe("2026-06-01T23:59:00.000Z"), | | 183 | + }), | | 184 | + ); | | 185 | + const disconnected = { ...thread, connectionPhase: "reconnecting" as const }; | | 186 | + expect(resolveThreadListV2Status(disconnected)).toBe( | | 187 | + status === "failed" ? "failed" : "ready", | | 188 | + ); | | 189 | + expect(threadHasUnseenCompletion(disconnected)).toBe(threadHasUnseenCompletion(thread)); | | 190 | + }, | | 191 | + ); | | 192 | + | | 193 | + it.each([ | | 194 | + ["connecting", "connecting"], | | 195 | + ["reconnecting", "reconnecting"], | | 196 | + ["offline", "offline"], | | 197 | + ["error", "offline"], | | 198 | + ["unsupported", "offline"], | | 199 | + ["available", "offline"], | | 200 | + ["connected", "working"], | | 201 | + [undefined, "working"], | | 202 | + ] as const)( | | 203 | + "presents cached running work with connection phase %s", | | 204 | + (connectionPhase, expected) => { | | 205 | + const thread = makeThread({ | | 206 | + id: ThreadId.make("disconnected"), | | 207 | + title: "Disconnected", | | 208 | + runtime: { | | 209 | + status: "running", | | 210 | + activeRunId: RunId.make("run-disconnected"), | | 211 | + providerInstanceId: ProviderInstanceId.make("codex"), | | 212 | + providerName: "Codex", | | 213 | + lastError: null, | | 214 | + updatedAt: NOW, | | 215 | + }, | | 216 | + connectionPhase, | | 217 | + }); | | 218 | + expect(resolveThreadListV2Status(thread)).toBe(expected); | | 219 | + expect(resolveThreadListV2Status({ ...thread, hasPendingApprovals: true })).toBe("approval"); | | 220 | + expect(resolveThreadListV2Status({ ...thread, hasPendingUserInput: true })).toBe("input"); | | 221 | + }, | | 222 | + ); | | 223 | + | 156 | 224 | it("presents decoded thread waits as Waiting while preserving requests and older servers", () => { | 157 | 225 | const raw = makeRawThreadShell({ | 158 | 226 | status: "running", | @@ -1781,6 +1849,20 @@ describe("Working section beta", () => { | 1781 | 1849 | expect(off.workingCount).toBe(0); | 1782 | 1850 | }); | 1783 | 1851 |
| | 1852 | + it("preserves pins and Working membership across connection loss and recovery", () => { | | 1853 | + const before = build({ workingShelfExpanded: true }); | | 1854 | + for (const connectionPhase of ["reconnecting", "offline", "connected"] as const) { | | 1855 | + const layout = build({ | | 1856 | + workingShelfExpanded: true, | | 1857 | + threads: threads.map((thread) => ({ ...thread, connectionPhase })), | | 1858 | + }); | | 1859 | + expect(ids(layout)).toEqual(ids(before)); | | 1860 | + expect(layout.workingCount).toBe(before.workingCount); | | 1861 | + expect(layout.items[0]?.thread.id).toBe("pinned-working"); | | 1862 | + expect(layout.items[0]?.thread.runtime?.status).toBe("running"); | | 1863 | + } | | 1864 | + }); | | 1865 | + | 1784 | 1866 | it("keeps an inactive row in Working during the shared grace and returns it on expiry", () => { | 1785 | 1867 | vi.useFakeTimers(); | 1786 | 1868 | vi.setSystemTime(new Date(NOW)); | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/threadListV2.ts +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,6 +14,7 @@ import { | 14 | 14 | type SnoozePreset, | 15 | 15 | } from "@t3tools/client-runtime/state/thread-settled"; | 16 | 16 | import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; | | 17 | +import { resolveThreadConnectionStatus } from "@t3tools/client-runtime/state/models"; | 17 | 18 | import { | 18 | 19 | threadSearchMatchKey, | 19 | 20 | threadSearchSubject, | @@ -51,6 +52,9 @@ import { | 51 | 52 | export const threadListInboxReturns = createInboxReturnTracker(); | 52 | 53 |
| 53 | 54 | export type ThreadListV2Status = | | 55 | + | "connecting" | | 56 | + | "reconnecting" | | 57 | + | "offline" | 54 | 58 | | "approval" | 55 | 59 | | "input" | 56 | 60 | | "request" | @@ -262,6 +266,8 @@ export function resolveThreadListV2Status( | 262 | 266 | | "pendingGuestMessageCount" | 263 | 267 | | "runtime" | 264 | 268 | | "blockedOnThreadWait" | | 269 | + | "connectionPhase" | | 270 | + | "pendingBackgroundTasks" | 265 | 271 | >, | 266 | 272 | ): ThreadListV2Status { | 267 | 273 | if (thread.hasPendingApprovals || thread.pendingSubagentRequest === "approval") { | @@ -274,6 +280,8 @@ export function resolveThreadListV2Status( | 274 | 280 | if ((thread.pendingGuestMessageCount ?? 0) > 0) { | 275 | 281 | return "request"; | 276 | 282 | } | | 283 | + const connectionStatus = resolveThreadConnectionStatus(thread); | | 284 | + if (connectionStatus !== null) return connectionStatus; | 277 | 285 | if (thread.runtime?.status === "running" && thread.blockedOnThreadWait === true) { | 278 | 286 | return "waiting"; | 279 | 287 | } | |
|