refactor: split oversized files along responsibility seams#63
Open
rafiki270 wants to merge 8 commits into
Open
refactor: split oversized files along responsibility seams#63rafiki270 wants to merge 8 commits into
rafiki270 wants to merge 8 commits into
Conversation
Extract cookie read/write/delete operations, the CDP-then-JS fallback machinery, and the cookieInjectionScript builder out of CEFRenderer.swift into CEFRenderer+Cookies.swift. CEFRenderer.swift now stays under the 500-line limit. CEFHostView, CookieContinuationState, bridge, containerView, pendingCookies, and pendingDeleteAllCookies are now internal so the extension in a sibling file can reach them. Pure code motion. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pulled cookie operations, screenshot/resize, and browser-handle introspection into category and helper files. CEFBridge.mm now holds core lifecycle, navigation, and console/eval routing only. Public @interface in CEFBridge.h is unchanged. Shared private ivars and helper declarations live in CEFBridge_Internal.h. before: CEFBridge.mm 947 lines after: CEFBridge.mm 474 CEFBridge_Internal.h 59 CEFBridge+Cookies.mm 92 CEFBridge+Screenshot.mm 223 CEFBridgeIntrospection.mm 147 Pure code motion. No behavior change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Moved the 800-line 3D-inspector script blobs out of Swift string literals and into `Resources/Snapshot3D/*.js`. The enter script is split along the phase comments that the original author already used (setup/collect/ apply/input), each under 500 lines. Concatenation is byte-identical to the previous single string, so the running script and its shared IIFE closure scope are unchanged. before: Snapshot3DBridge.swift 802 lines after: Snapshot3DBridge.swift 70 Resources/Snapshot3D/enter-setup.js 108 Resources/Snapshot3D/enter-collect.js 141 Resources/Snapshot3D/enter-apply.js 111 Resources/Snapshot3D/enter-input.js 342 Resources/Snapshot3D/exit.js 65 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ry headers The previous CEFBridge.mm split moved implementations of these methods into Obj-C categories while leaving the declarations in the primary @interface in CEFBridge.h. Clang correctly warned (-Wincomplete- implementation, -Wobjc-protocol-method-implementation) because methods declared on the primary class were being implemented in a category. Move the declarations to CEFBridge+Cookies.h and CEFBridge+Screenshot.h matching the implementation files, and import both via the Swift bridging header so Swift call-sites stay unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pulled the inference flow (infer + native-model resolution + page-context preload + screenshot capture) into AIHandler+Inference.swift and the Ollama HTTP transport (chat/generate clients + reachability probe + URL helpers + capability inference) into AIHandler+Ollama.swift. The main file now owns the type, request dispatch, status/load/unload/record handlers, and the small error-mapping utilities shared by every backend. The `AIBackendStore` actor was widened from `private` to module-internal so the extensions can read its snapshot; it is still scoped to the AI handler files and not used elsewhere. before: AIHandler.swift 701 lines after: AIHandler.swift 273 AIHandler+Inference.swift 282 AIHandler+Ollama.swift 177 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mirrors the macOS Snapshot3DBridge split: the long 3D-inspector script bodies move from Kotlin raw-string constants into JS files under `app/src/main/assets/snapshot3d/`. The enter script lives as four phase files (setup, collect, apply, input), concatenated at first access so each individual source file stays within the project's 500-line limit. The phases share closure state inside one IIFE, so the concatenation is what runs. before: Snapshot3DBridge.kt 749 lines after: Snapshot3DBridge.kt 67 assets/snapshot3d/enter-setup.js 101 assets/snapshot3d/enter-collect.js 133 assets/snapshot3d/enter-apply.js 93 assets/snapshot3d/enter-input.js 333 assets/snapshot3d/exit.js 57 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ge with renamed CopyBrowserHost HandlerContext.swift was 515 lines after rebase on the parallel HandlerContext+Cookies split that landed via #62. Move the free error/response helpers and the HandlerError enum into HandlerResponses.swift, bringing HandlerContext to 455. CEFBridge.mm in closeBrowser/setHidden was still calling the pre-split name CopyBrowserHost; the introspection split renamed it to CEFBridgeCopyBrowserHost. Update both call sites so the post-rebase tree compiles. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The 3-arg startForeground(id, notification, serviceType) overload was added in Android 10 (API 29 / Q); minSdk is 28. Branch on Build.VERSION.SDK_INT so API 28 uses the 2-arg call, while API 29+ still gets the connectedDevice service type. The manifest still declares foregroundServiceType=connectedDevice for runtime grant. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits files that exceeded the project's 500-line limit along cohesive responsibility seams. Pure code motion plus the import/header adjustments required by the move — no behavior change.
Per-file results
apps/macos/Kelpie/Handlers/HandlerContext.swiftHandlerContext+Cookies.swiftapps/macos/Kelpie/Renderer/CEFRenderer.swiftCEFRenderer+Cookies.swiftapps/macos/Kelpie/Renderer/CEFBridge.mmCEFBridge+Cookies.mm(93),CEFBridge+Screenshot.mm(224),CEFBridgeIntrospection.mm(147),CEFBridge_Internal.h(59),CEFBridge+Cookies.h(57),CEFBridge+Screenshot.h(19)apps/macos/Kelpie/Handlers/Snapshot3DBridge.swiftapps/macos/Kelpie/Resources/Snapshot3D/(5 files)apps/macos/Kelpie/Handlers/AIHandler.swiftAIHandler+Inference.swift(282),AIHandler+Ollama.swift(177)apps/android/.../handlers/Snapshot3DBridge.ktapp/src/main/assets/snapshot3d/(5 files)Concatenation order of phase JS files is enforced in the Swift/Kotlin bridge code. Concatenated output verified byte-identical with the original embedded string via
diff.Notes
@interfaceinto matching category headers to silence-Wincomplete-implementation/-Wobjc-protocol-method-implementation.AIBackendStorewidened fromprivate actortoactorsoAIHandler+Inference.swiftcan reference it.Snapshot3DBridge.ktafter the split.Test plan
make lint-swift— 0 violationstuist generate --no-opensucceedsxcodebuild ... Kelpie ... Debug build— BUILD SUCCEEDED./gradlew assembleDebug— BUILD SUCCESSFUL./gradlew ktlintMainSourceSetCheck— clean🤖 Generated with Claude Code