Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
6a8a1f4
feat(annotate): dual-color shapes, text wrap handles, smart mosaic, e…
hubo1989 Oct 22, 2026
ed860a2
feat(experience): beautify rendering, cloud upload, scroll capture, h…
hubo1989 Oct 22, 2026
757e23b
chore(ci): Developer ID release signing, dmg packaging, app icon refresh
hubo1989 Oct 22, 2026
c168d8a
feat(annotate): in-place results drawer, line tool, ⌘ constraints, te…
hubo1989 Oct 22, 2026
624a4c0
test(annotate): PRD acceptance suite + deterministic E2E harness
hubo1989 Oct 22, 2026
dce286e
fix(interaction): toolbar hit areas, inert outside-clicks, merged res…
hubo1989 Oct 23, 2026
0d9569f
fix(interaction): restore toolbar hover tooltips and clicks, separate…
hubo1989 Oct 23, 2026
260033d
feat(translation): bilingual overlay strips inside selection, cross-l…
hubo1989 Oct 24, 2026
8b3094b
perf(ocr): downsample VLM uploads, slim continuations, JSON-forced ou…
hubo1989 Oct 24, 2026
31362ce
ci(review): add opencode PR auto-review workflow
hubo1989 Oct 25, 2026
167261f
ci(review): replace opencode with alibaba open-code-review (ocr)
hubo1989 Oct 25, 2026
b1aac71
ci(review): point OCR at Z.ai coding endpoint with GLM-4.6
hubo1989 Oct 26, 2026
0d256bf
ci(review): switch OCR model to glm-5.3-flash
hubo1989 Oct 26, 2026
157a30e
ci(review): trigger OCR via pull_request so branch-hosted workflow runs
hubo1989 Oct 26, 2026
e6eea80
fix(review): address 53 of 60 OpenCodeReview findings on PR #81
hubo1989 Oct 27, 2026
4cc89d4
fix(upload): probe Keychain existence before reading secrets
hubo1989 Oct 27, 2026
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
39 changes: 39 additions & 0 deletions .github/workflows/ocr-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 阿里开源 OpenCodeReview — PR 自动行级审查
# https://github.com/alibaba/open-code-review
#
# 前置条件(一次性):仓库 Settings → Secrets and variables → Actions
# 添加 OCR_LLM_AUTH_TOKEN = Z.ai API Key
# 换其它 provider 时改下面三行明文(url / model / llm_use_anthropic)即可。
name: OpenCodeReview PR Review

concurrency:
group: ocr-pr-review-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
# pull_request 使 PR 分支上的 workflow 立即生效;same-repo PR 同样可读 secrets。
# 将来若需 fork PR 触发,改回 pull_request_target 并先把本文件合入 main。
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
pull-requests: write

jobs:
code-review:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Run OpenCodeReview
# pinned to the v1.13.3 tag commit (annotated tag dereferenced) to
# keep the token-bearing step immune to tag hijacking
uses: alibaba/open-code-review@375f64cd6f67a48a135da83cfcf59c52669a09cb # v1.13.3
with:
llm_url: https://api.z.ai/api/coding/paas/v4/chat/completions
llm_auth_token: ${{ secrets.OCR_LLM_AUTH_TOKEN }}
llm_model: glm-5.3-flash
llm_use_anthropic: 'false'
# GLM 关闭思考输出(上游 action 默认格式)
llm_extra_body: '{"thinking": {"type": "disabled"}}'
language: Chinese
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
CODE_SIGN_IDENTITY="-" \
CODE_SIGN_STYLE=Automatic \
MACOSX_DEPLOYMENT_TARGET=26.0 \
ONLY_ACTIVE_ARCH=NO \
ARCHS=arm64 \
clean build

- name: Sign App & Create DMG
Expand Down Expand Up @@ -220,12 +220,17 @@ jobs:

VERSION=${{ steps.vars.outputs.version }}
DMG_FILE="${{ env.PROJECT_NAME }}-${VERSION}.dmg"
ARM64_DMG_FILE="${{ env.PROJECT_NAME }}-${VERSION}-arm64.dmg"

hdiutil create -volname "${{ env.PROJECT_NAME }}" \
-srcfolder dmg_temp \
-ov -format UDZO \
"$DMG_FILE"

# arm64-only build; keep the un-suffixed name for backward compatibility,
# but release notes state this is an arm64-only artifact (see Create Release body).
cp "$DMG_FILE" "$ARM64_DMG_FILE"
Comment on lines +230 to +232

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performance · low
无后缀 DMG 与 -arm64.dmg 是同一文件的完整副本,Release assets 将上传两份几十/上百 MB 的相同二进制,下载体积与存储翻倍。若仅为兼容旧链接,可考虑只保留无后缀文件(说明中注明 arm64-only 即可),或用 hard link/上传说明替代重复上传。


# Get file size
DMG_SIZE=$(stat -f%z "$DMG_FILE")
echo "dmg_size=$DMG_SIZE" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -341,6 +346,8 @@ jobs:
${{ env.PROJECT_NAME }}-*.dmg
appcast.xml
generate_release_notes: true
body: |
> **注意**:本次构建为 **arm64-only**。`$NAME-$VERSION.dmg` 与 `$NAME-$VERSION-arm64.dmg` 为同一 arm64 产物(无后缀名为向后兼容保留),不含 x86_64 切片。
Comment on lines +349 to +350

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
body: 位于 with: 块内,由 action 解析,不会经过 shell 展开——$NAME 和 $VERSION 将以字面量出现在 Release 说明中,而非实际的 TransFrame-1.5.1.dmg 等文件名。应使用 GitHub 表达式或先在前面 run 步骤中生成 body 文件后用 body_path 引用。

Suggestion:

Suggested change
body: |
> **注意**:本次构建为 **arm64-only**。`$NAME-$VERSION.dmg` 与 `$NAME-$VERSION-arm64.dmg` 为同一 arm64 产物(无后缀名为向后兼容保留),不含 x86_64 切片。
body: |
> **注意**:本次构建为 **arm64-only**。`${{ env.PROJECT_NAME }}-${{ steps.vars.outputs.version }}.dmg` 与同名 `-arm64.dmg` 为同一 arm64 产物(无后缀名为向后兼容保留),不含 x86_64 切片。

Comment on lines +349 to +350

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
body: | 是传给 softprops/action-gh-release 的 YAML 字面输入,不会经过 shell 展开。$NAME 和 $VERSION 在此上下文中既不会被替换、也从未定义,用户在 Release 页面看到的是字面文本 "$NAME-$VERSION.dmg",无法起到说明产物命名的作用。建议改用运行步骤生成 body(用 heredoc + 唯一分隔符写入 GITHUB_OUTPUT,如上方 tag_message 步骤的做法),或直接写死实际项目名/在 env 中通过 GitHub Actions 表达式 ${{ env.PROJECT_NAME }} 与 ${{ steps.vars.outputs.version }} 拼进字面值。

Suggestion:

Suggested change
body: |
> **注意**:本次构建为 **arm64-only**。`$NAME-$VERSION.dmg` 与 `$NAME-$VERSION-arm64.dmg` 为同一 arm64 产物(无后缀名为向后兼容保留),不含 x86_64 切片。
body: >-
> **注意**:本次构建为 **arm64-only**。`${{ env.PROJECT_NAME }}-${{ steps.vars.outputs.version }}.dmg`
与 `${{ env.PROJECT_NAME }}-${{ steps.vars.outputs.version }}-arm64.dmg` 为同一 arm64 产物(无后缀名为向后兼容保留),不含 x86_64 切片。

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ build_artifacts/
.omc/
.omd/
*.dmg
scripts/e2e/eventsynth
16 changes: 10 additions & 6 deletions TransFrame.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -euo pipefail\n# Sign embedded frameworks with ad-hoc signature to match main app\nFRAMEWORKS_DIR=\"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks\"\nif [ -d \"$FRAMEWORKS_DIR\" ]; then\n for FRAMEWORK in \"$FRAMEWORKS_DIR\"/*.framework; do\n if [ -d \"$FRAMEWORK\" ]; then\n echo \"Re-signing framework with ad-hoc: $(basename \"$FRAMEWORK\")\"\n codesign --force --sign - --deep \"$FRAMEWORK\"\n fi\n done\nfi\nmkdir -p \"${DERIVED_FILE_DIR}\"\ntouch \"${DERIVED_FILE_DIR}/TransFrameFrameworkResign.stamp\"\n";
shellScript = "set -euo pipefail\n# Thin and sign embedded frameworks\nFRAMEWORKS_DIR=\"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks\"\nif [ -d \"$FRAMEWORKS_DIR\" ]; then\n TARGET_ARCH=\"${ARCHS:-arm64}\"\n if [ \"$TARGET_ARCH\" = \"arm64\" ] || [ \"$TARGET_ARCH\" = \"x86_64\" ]; then\n if [ -d \"$FRAMEWORKS_DIR/Sparkle.framework\" ]; then\n SPARKLE=\"$FRAMEWORKS_DIR/Sparkle.framework\"\n for b in \"Versions/B/Sparkle\" \"Versions/B/Autoupdate\" \"Versions/B/Updater.app/Contents/MacOS/Updater\" \"Versions/B/XPCServices/Downloader.xpc/Contents/MacOS/Downloader\" \"Versions/B/XPCServices/Installer.xpc/Contents/MacOS/Installer\"; do\n if [ -f \"$SPARKLE/$b\" ]; then\n lipo -thin \"$TARGET_ARCH\" \"$SPARKLE/$b\" -output \"$SPARKLE/$b.thin\" 2>/dev/null && mv \"$SPARKLE/$b.thin\" \"$SPARKLE/$b\" || true\n strip -x \"$SPARKLE/$b\" 2>/dev/null || true\n fi\n done\n fi\n fi\n SIGN_ID=\"${EXPANDED_CODE_SIGN_IDENTITY:-}\"\n if [ -z \"$SIGN_ID\" ] || [ \"$SIGN_ID\" = \"-\" ]; then\n SIGN_ID=$(security find-identity -v -p codesigning | grep -m1 \"Developer ID Application\" | awk -F '\"' '{print $2}' || true)\n fi\n if [ -z \"$SIGN_ID\" ]; then\n SIGN_ID=\"-\"\n fi\n for FRAMEWORK in \"$FRAMEWORKS_DIR\"/*.framework; do\n if [ -d \"$FRAMEWORK\" ]; then\n echo \"Re-signing framework with $SIGN_ID: $(basename \"$FRAMEWORK\")\"\n codesign --force --sign \"$SIGN_ID\" --timestamp=none --deep \"$FRAMEWORK\"\n fi\n done\nfi\nmkdir -p \"${DERIVED_FILE_DIR}\"\ntouch \"${DERIVED_FILE_DIR}/TransFrameFrameworkResign.stamp\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -382,11 +382,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "TransFrame/Supporting Files/TransFrame.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 27LU47J28S;
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -416,15 +416,17 @@
SC000015 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "TransFrame/Supporting Files/TransFrame.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = "";
DEAD_CODE_STRIPPING = YES;
DEPLOYMENT_POSTPROCESSING = YES;
DEVELOPMENT_TEAM = 27LU47J28S;
ENABLE_APP_SANDBOX = NO;
ENABLE_HARDENED_RUNTIME = NO;
ENABLE_PREVIEWS = YES;
Expand All @@ -445,6 +447,8 @@
PRODUCT_MODULE_NAME = TransFrame;
PRODUCT_NAME = TransFrame;
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = YES;
STRIP_STYLE = all;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
Expand Down
81 changes: 80 additions & 1 deletion TransFrame/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: - Other Properties

private var menuBarController: MenuBarController?
private let settings = AppSettings.shared
private var settings: AppSettings { AppSettings.shared }

private lazy var updaterController: SPUStandardUpdaterController = {
let controller = SPUStandardUpdaterController(
Expand Down Expand Up @@ -210,8 +210,87 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
HistoryWindowController.shared.showHistory()
}

// MARK: - Color Picker & Image Editing Actions

/// Triggers the native macOS color picker to copy a hex color code
@objc func pickScreenColor() {
NSColorSampler().show { selectedColor in
guard let color = selectedColor else { return }
guard let rgbColor = color.usingColorSpace(.sRGB) else { return }
let r = Int(round(rgbColor.redComponent * 255))
let g = Int(round(rgbColor.greenComponent * 255))
let b = Int(round(rgbColor.blueComponent * 255))
let hex = String(format: "#%02X%02X%02X", r, g, b)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(hex, forType: .string)
NotificationCenter.default.post(name: .colorDidPick, object: hex)
}
}

/// Opens an image file from disk and launches the annotation editor
@objc func openImageForEditing() {
let panel = NSOpenPanel()
panel.allowedContentTypes = [.image, .png, .jpeg, .tiff]
panel.allowsMultipleSelection = false
panel.canChooseDirectories = false
panel.canCreateDirectories = false
if panel.runModal() == .OK, let url = panel.url {
openImageURL(url)
}
}

/// Loads an image file URL and shows the preview editor window
func openImageURL(_ url: URL) {
guard let nsImage = NSImage(contentsOf: url) else {
showImageLoadFailure(url)
return
}
var proposedRect = NSRect(origin: .zero, size: nsImage.size)
guard let cgImage = nsImage.cgImage(forProposedRect: &proposedRect, context: nil, hints: nil) else {
showImageLoadFailure(url)
return
}

guard let screen = NSScreen.main ?? NSScreen.screens.first else {
showImageLoadFailure(url)
return
}
let displayInfo = DisplayInfo(
id: CGMainDisplayID(),
name: screen.localizedName,
frame: screen.frame,
scaleFactor: screen.backingScaleFactor,
isPrimary: true
)
let screenshot = Screenshot(
image: cgImage,
sourceDisplay: displayInfo,
format: AppSettings.shared.defaultFormat
)
PreviewWindowController.shared.showPreview(for: screenshot)
}

func application(_ application: NSApplication, open urls: [URL]) {
if let first = urls.first {
openImageURL(first)
}
}

// MARK: - Error Handling

/// Shows an alert when an image file cannot be loaded for editing
private func showImageLoadFailure(_ url: URL) {
Logger.general.error("Failed to load image for editing: \(url.path, privacy: .public)")

let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = String(
format: NSLocalizedString("error.image.load.failed", comment: ""),
url.lastPathComponent
)
alert.runModal()
}

/// Shows an error alert for capture failures
func showCaptureError(_ error: TransFrameError) {
Logger.general.error("Capture error: \(error.localizedDescription)")
Expand Down
16 changes: 8 additions & 8 deletions TransFrame/App/Coordinators/CaptureCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ final class CaptureCoordinator {
private func setupSessionCallbacks() {
let session = CaptureSessionController.shared

session.onCaptureComplete = { [weak self] document in
session.onCaptureComplete = { document in
PreviewWindowController.shared.showPreview(for: document.toLegacyScreenshot())
}

session.onTranslationRequested = { [weak self] document in
let scale = document.sourceDisplay?.scaleFactor ?? 2.0
TranslationFlowController.shared.startTranslation(
document: document,
scaleFactor: scale
session.onTranslationRequested = { document in
// Route into the preview window's embedded side panel — no external window
PreviewWindowController.shared.showPreview(
for: document.toLegacyScreenshot(),
autoTriggerTranslate: true
)
}

session.onOCRRequested = { [weak self] document in
PreviewWindowController.shared.showPreview(for: document.toLegacyScreenshot())
session.onOCRRequested = { document in
PreviewWindowController.shared.showPreview(for: document.toLegacyScreenshot(), autoTriggerOCR: true)
}
}

Expand Down
14 changes: 7 additions & 7 deletions TransFrame/Errors/TransFrameError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ enum TransFrameError: LocalizedError, Sendable {
/// Failed to encode the image to the specified format
case exportEncodingFailed(format: ExportFormat)

/// Image upload to the configured host failed (network/HTTP/provider error)
case imageUploadFailed(reason: String)

// MARK: - Clipboard Errors

/// Failed to write the screenshot to the system clipboard
Expand All @@ -44,9 +47,6 @@ enum TransFrameError: LocalizedError, Sendable {

// MARK: - OCR Errors

/// OCR operation is currently in progress
case ocrOperationInProgress

/// The image provided for OCR is invalid
case ocrInvalidImage

Expand Down Expand Up @@ -74,14 +74,14 @@ enum TransFrameError: LocalizedError, Sendable {
return NSLocalizedString("error.disk.full", comment: "")
case .exportEncodingFailed:
return NSLocalizedString("error.export.encoding.failed", comment: "")
case .imageUploadFailed(let reason):
return String(format: NSLocalizedString("error.image.upload.failed", comment: ""), reason)
case .clipboardWriteFailed:
return NSLocalizedString("error.clipboard.write.failed", comment: "")
case .hotkeyRegistrationFailed:
return NSLocalizedString("error.hotkey.registration.failed", comment: "")
case .hotkeyConflict:
return NSLocalizedString("error.hotkey.conflict", comment: "")
case .ocrOperationInProgress:
return NSLocalizedString("error.ocr.in.progress", comment: "")
case .ocrInvalidImage:
return NSLocalizedString("error.ocr.invalid.image", comment: "")
case .ocrRecognitionFailed:
Expand All @@ -107,14 +107,14 @@ enum TransFrameError: LocalizedError, Sendable {
return NSLocalizedString("error.disk.full.recovery", comment: "")
case .exportEncodingFailed:
return NSLocalizedString("error.export.encoding.failed.recovery", comment: "")
case .imageUploadFailed:
return NSLocalizedString("error.image.upload.failed.recovery", comment: "")
case .clipboardWriteFailed:
return NSLocalizedString("error.clipboard.write.failed.recovery", comment: "")
case .hotkeyRegistrationFailed:
return NSLocalizedString("error.hotkey.registration.failed.recovery", comment: "")
case .hotkeyConflict:
return NSLocalizedString("error.hotkey.conflict.recovery", comment: "")
case .ocrOperationInProgress:
return NSLocalizedString("error.ocr.in.progress.recovery", comment: "")
case .ocrInvalidImage:
return NSLocalizedString("error.ocr.invalid.image.recovery", comment: "")
case .ocrRecognitionFailed:
Expand Down
Loading
Loading