Repository navigation
fix(translation): fix 15 root causes of low translation efficiency and success rate #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -238,6 +238,86 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf dmg_temp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Notarize & Staple App | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: notarize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+241
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APPLE_ID: ${{ secrets.APPLE_ID }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APP_PATH="build/Build/Products/Release/${{ env.PROJECT_NAME }}.app" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION=${{ steps.vars.outputs.version }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -z "$APPLE_ID" ] || [ -z "$APPLE_APP_SPECIFIC_PASSWORD" ] || [ -z "$APPLE_TEAM_ID" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Warning: Notarization secrets not configured, skipping notarization" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "notarized=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+252
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+251
to
+255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if codesign -dv "$APP_PATH" 2>&1 | grep -q "Signature=adhoc"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Warning: App is ad-hoc signed, skipping notarization" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "notarized=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Creating ZIP for notarization submission..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZIP_PATH="$RUNNER_TEMP/${{ env.PROJECT_NAME }}-${VERSION}-notarize.zip" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Submitting to Apple notarization service..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xcrun notarytool submit "$ZIP_PATH" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --apple-id "$APPLE_ID" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --password "$APPLE_APP_SPECIFIC_PASSWORD" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --team-id "$APPLE_TEAM_ID" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --wait \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --timeout 30m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+268
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
Comment on lines
+268
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Stapling notarization ticket to app..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xcrun stapler staple "$APP_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Verifying notarization..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xcrun stapler validate "$APP_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spctl --assess --type execute --verbose "$APP_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Notarization complete." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Recreating DMG with stapled app..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DMG_FILE="${{ env.PROJECT_NAME }}-${VERSION}.dmg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARM64_DMG_FILE="${{ env.PROJECT_NAME }}-${VERSION}-arm64.dmg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+284
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p dmg_temp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp -R "$APP_PATH" dmg_temp/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ln -sf /Applications dmg_temp/Applications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hdiutil create -volname "${{ env.PROJECT_NAME }}" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -srcfolder dmg_temp \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -ov -format UDZO \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$DMG_FILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+288
to
+295
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp "$DMG_FILE" "$ARM64_DMG_FILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Notarizing DMG..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DMG_ZIP="$RUNNER_TEMP/${{ env.PROJECT_NAME }}-${VERSION}-dmg.zip" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ditto -c -k --keepParent "$DMG_FILE" "$DMG_ZIP" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xcrun notarytool submit "$DMG_ZIP" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --apple-id "$APPLE_ID" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --password "$APPLE_APP_SPECIFIC_PASSWORD" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --team-id "$APPLE_TEAM_ID" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --wait \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --timeout 30m | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| xcrun stapler staple "$DMG_FILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp "$DMG_FILE" "$ARM64_DMG_FILE" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+310
to
+311
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf dmg_temp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -f "$ZIP_PATH" "$DMG_ZIP" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update DMG size for appcast (may have changed after notarization) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NEW_DMG_SIZE=$(stat -f%z "$DMG_FILE") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "dmg_size=$NEW_DMG_SIZE" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "notarized=true" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+313
to
+319
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Sign DMG for Sparkle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: sign_dmg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -301,7 +381,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BUILD_NUM="${{ steps.build_number.outputs.build_num }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DMG_URL="https://github.com/${{ github.repository }}/releases/download/${{ steps.vars.outputs.tag_name }}/${{ env.PROJECT_NAME }}-${VERSION}.dmg" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PUBDATE="${{ steps.pubdate.outputs.date }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DMG_SIZE="${{ steps.create_dmg.outputs.dmg_size }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DMG_SIZE="${{ steps.notarize.outputs.dmg_size || steps.create_dmg.outputs.dmg_size }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SIGNATURE="${{ steps.sign_dmg.outputs.signature }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Build enclosure tag with or without signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ final class CaptureSessionController: NSObject, SelectionOverlayDelegate { | |
| private var currentMode: CaptureMode = .region | ||
| private var currentSnapshotSet: FrozenSnapshotSet? | ||
| private var beautifyConfig: BeautifyConfig? | ||
| private var isStartingCapture = false | ||
|
|
||
| private var localKeyMonitor: Any? | ||
| private var globalKeyMonitor: Any? | ||
|
|
@@ -49,11 +50,12 @@ final class CaptureSessionController: NSObject, SelectionOverlayDelegate { | |
|
|
||
| /// Triggers screen capture session with instant freeze. | ||
| func startCapture(mode: CaptureMode = .region) { | ||
| // Prevent launching another session if overlays are active | ||
| guard activeOverlays.isEmpty else { | ||
| // Prevent launching another session if overlays are active or starting | ||
| guard activeOverlays.isEmpty, !isStartingCapture else { | ||
| logger.warning("Capture session already in progress, ignoring trigger") | ||
| return | ||
| } | ||
| isStartingCapture = true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a full-screen capture succeeds, execution returns at line 93 before Useful? React with 👍 / 👎. |
||
|
|
||
| self.currentMode = mode | ||
| let triggerTime = ContinuousClock.now | ||
|
|
@@ -88,6 +90,7 @@ final class CaptureSessionController: NSObject, SelectionOverlayDelegate { | |
| CaptureDocumentStore.shared.register(doc) | ||
| self.dispatchAction(.copy, for: doc) | ||
| self.onCaptureComplete?(doc) | ||
| self.isStartingCapture = false | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -122,9 +125,11 @@ final class CaptureSessionController: NSObject, SelectionOverlayDelegate { | |
| // Record freeze visible time | ||
| self.currentSnapshotSet?.freezeVisibleAt = .now | ||
| self.logger.info("All frozen overlays presented successfully") | ||
| self.isStartingCapture = false | ||
|
|
||
| } catch { | ||
| self.logger.error("Failed to start capture session: \(error.localizedDescription)") | ||
| self.isStartingCapture = false | ||
| self.closeAllOverlays() | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,8 +67,14 @@ extension PreviewViewModel { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| $0.offsetBy(dx: -originShift.x, dy: -originShift.y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Invalidate OCR cache for the previous crop area | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Invalidate OCR cache and translation results for the previous crop area | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ocrTask?.cancel() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| translationTask?.cancel() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| analysisGeneration &+= 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPerformingOCR = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isTranslating = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ocrResult = nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bilingualSegments = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
Comment on lines
+70
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| screenshot = Screenshot( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: screenshot.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,16 +12,22 @@ extension PreviewViewModel { | |||||||||||||||||||||||||||||||||||||||||||||
| isPerformingOCR = true | ||||||||||||||||||||||||||||||||||||||||||||||
| ocrTranslationError = nil | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Task { | ||||||||||||||||||||||||||||||||||||||||||||||
| await executeOCR() | ||||||||||||||||||||||||||||||||||||||||||||||
| ocrTask?.cancel() | ||||||||||||||||||||||||||||||||||||||||||||||
| analysisGeneration &+= 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| let generation = analysisGeneration | ||||||||||||||||||||||||||||||||||||||||||||||
| ocrTask = Task { | ||||||||||||||||||||||||||||||||||||||||||||||
| await executeOCR(generation: generation) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| func executeOCR() async { | ||||||||||||||||||||||||||||||||||||||||||||||
| defer { isPerformingOCR = false } | ||||||||||||||||||||||||||||||||||||||||||||||
| func executeOCR(generation: UInt64? = nil) async { | ||||||||||||||||||||||||||||||||||||||||||||||
| let currentGeneration = generation ?? analysisGeneration | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| defer { | ||||||||||||||||||||||||||||||||||||||||||||||
| if currentGeneration == analysisGeneration { | ||||||||||||||||||||||||||||||||||||||||||||||
| isPerformingOCR = false | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If translation starts while OCR is running, or a crop invalidates the analysis, the shared Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Recognize in the user's source language; auto (or an unsupported | ||||||||||||||||||||||||||||||||||||||||||||||
| // language) falls back to Vision's automatic language detection. | ||||||||||||||||||||||||||||||||||||||||||||||
| let languages = Set( | ||||||||||||||||||||||||||||||||||||||||||||||
| [AppSettings.shared.translationSourceLanguage] | ||||||||||||||||||||||||||||||||||||||||||||||
| .compactMap { OCREngine.RecognitionLanguage(translationLanguage: $0) } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,11 +38,13 @@ extension PreviewViewModel { | |||||||||||||||||||||||||||||||||||||||||||||
| image, | ||||||||||||||||||||||||||||||||||||||||||||||
| languages: languages | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| guard currentGeneration == analysisGeneration else { return } | ||||||||||||||||||||||||||||||||||||||||||||||
| ocrResult = result | ||||||||||||||||||||||||||||||||||||||||||||||
| if result.observations.isEmpty { | ||||||||||||||||||||||||||||||||||||||||||||||
| errorMessage = String(localized: "error.ocr.no.text") | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
| guard currentGeneration == analysisGeneration else { return } | ||||||||||||||||||||||||||||||||||||||||||||||
| let message = "\(String(localized: "error.ocr.failed")) \(error.localizedDescription)" | ||||||||||||||||||||||||||||||||||||||||||||||
| ocrTranslationError = message | ||||||||||||||||||||||||||||||||||||||||||||||
| errorMessage = message | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,9 +42,16 @@ enum BilingualOverlayLayout { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// TextSegment 使用左上角原点;译文从原文下边缘开始,按画布宽度换行。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static func translationAnchor(for boundingBox: CGRect, in displaySize: CGSize) -> Anchor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let x = max(0, min(boundingBox.minX * displaySize.width, displaySize.width)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let y = boundingBox.maxY * displaySize.height + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let belowY = boundingBox.maxY * displaySize.height + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let stripWidth = min(max(boundingBox.width * displaySize.width, 60), max(0, displaySize.width - x)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let fontSize = min(max(boundingBox.height * displaySize.height * 0.85, 10), 16) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let estimatedStripHeight = fontSize * 1.6 + 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let y: CGFloat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if belowY + estimatedStripHeight < displaySize.height { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| y = belowY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| y = max(0, boundingBox.minY * displaySize.height - estimatedStripHeight - 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
Comment on lines
+48
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return Anchor(x: x, y: y, maxWidth: stripWidth, fontSize: fontSize) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
release.yml 的 build job 未设置 timeout-minutes。新增的公证步骤包含两次 notarytool submit(--timeout 30m),加上构建、签名、发布,最坏情况下 job 可运行极长时间且无兜底上限,异常挂起时会持续占用 runner 资源。建议为 job 声明 timeout-minutes: 60 左右的合理上限。
Suggestion: