Compare commits

...
Author SHA1 Message Date
spark 6e8d81a0cb fix(metadata): stop sending «…, em , no» captions without city/venue
ci / rust (pull_request) Successful in 7m19s
ci / typescript (pull_request) Failing after 10m24s
The newsroom template left Portuguese prepositions when city and venue were empty, so Cofina got unusable Description/Headline text.
2026-11-06 20:25:13 +00:00
spark f8731553c1 fix(desktop): 0.3.29 — CropBias without Prisma for app build
ci / rust (push) Successful in 9m13s
ci / typescript (push) Failing after 11m16s
desktop-release / build (deb,appimage, linux-x86_64, ubuntu-latest) (push) Successful in 26m29s
desktop-release / build (--target universal-apple-darwin, dmg,app, darwin-universal, macos) (push) Successful in 30m16s
BIT-190 follow-up. desktop-v0.3.28 failed because planFrame pulled learning.ts/Prisma into the app tsc.
2026-11-06 14:25:09 +00:00
spark 1d96c38640 fix(desktop): 0.3.29 — keep CropBias out of Prisma for app build
ci / rust (pull_request) Successful in 9m22s
ci / typescript (pull_request) Failing after 11m19s
planFrame only needs the CropBias type; importing it from learning.ts pulled db/Prisma into the desktop app tsc and broke desktop-v0.3.28.
2026-11-06 14:24:42 +00:00
8 changed files with 69 additions and 21 deletions

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import type { Box } from "../composition/compose.js";
/** Soft crop after folding develop commands (autopilot or human). */
export interface FoldedCrop {
rect: Box;
angle: number;
}
/**
* Soft crop geometry of a correction: final minus autopilot (centre shift, size, straighten).
* Kept out of `learning.ts` so the desktop app can typecheck `planFrame` without Prisma.
*/
export interface CropBias {
dx: number;
dy: number;
/** Linear size: 1 = same area, >1 looser, <1 tighter. */
scale: number;
dAngle: number;
scene: "ball" | "group" | "person" | null;
}
+2 -15
View File
@@ -1,8 +1,10 @@
import type { EditCommand } from "@photoreport/contracts";
import type { Db } from "../db.js";
import type { Box } from "../composition/compose.js";
import type { CropBias, FoldedCrop } from "./cropBias.js";
import { TONE_KEYS, WB_KEYS } from "./look.js";
export type { CropBias, FoldedCrop } from "./cropBias.js";
export { TONE_KEYS, WB_KEYS };
/**
@@ -40,26 +42,11 @@ const CROP_SCENE = "__crop.scene";
const SCENE_CODE: Record<"ball" | "group" | "person", number> = { ball: 1, group: 2, person: 3 };
const SCENE_FROM: Record<number, "ball" | "group" | "person"> = { 1: "ball", 2: "group", 3: "person" };
export interface FoldedCrop {
rect: Box;
angle: number;
}
export interface FoldedEdits {
values: Record<string, number>;
crop: FoldedCrop | null;
}
/** Soft crop geometry of a correction: final minus autopilot (centre shift, size, straighten). */
export interface CropBias {
dx: number;
dy: number;
/** Linear size: 1 = same area, >1 looser, <1 tighter. */
scale: number;
dAngle: number;
scene: "ball" | "group" | "person" | null;
}
/** Settings after these commands, as far as the autopilot's controls go (merges of whole presets are ignored). */
export function fold(commands: EditCommand[]): FoldedEdits {
let values: Record<string, number> = {};
+1 -1
View File
@@ -2,7 +2,7 @@ import type { EditCommand } from "@photoreport/contracts";
import { type Box, type Detections, type FocusHint, clipsBall, compose, minCropWidth, planCrop } from "./compose.js";
import { biasCrop, constrainRotated, tighter } from "./geometry.js";
import { type Look, WB_KEYS, TONE_KEYS, detailForCrop, lookValues, toneApplied } from "../autopilot/look.js";
import type { CropBias } from "../autopilot/learning.js";
import type { CropBias } from "../autopilot/cropBias.js";
/** Straightening beyond this is more likely a creative tilt than a crooked horizon (matches the engine's band). */
const MAX_LEVEL = 8;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@photoreport/desktop",
"version": "0.3.28",
"version": "0.3.29",
"private": true,
"type": "module",
"scripts": {
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "photoreport-desktop"
version = "0.3.28"
version = "0.3.29"
edition = "2024"
publish = false
description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine."
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "PhotoReport",
"version": "0.3.28",
"version": "0.3.29",
"identifier": "pt.photoreport.desktop",
"build": {
"devUrl": "http://localhost:5173",
+19 -2
View File
@@ -197,12 +197,29 @@ function fill(template: string, vars: TemplateVars, codes: CodeList | undefined,
return expanded.text;
}
/** Collapse the spaces an empty variable leaves behind. Missing variables are always reported as issues. */
/**
* Collapse the holes an empty variable leaves behind. Missing variables are always reported as issues.
* The newsroom caption is "{event}, em {city}, no {venue}": without city/venue that must not become
* "AFS x FC Vizela, em , no" on a client delivery.
*/
function tidy(value: string): string {
// A match template on an event without an away team: "Gala x , em Braga" → "Gala, em Braga".
return value
.replace(/\s{2,}/g, " ")
// Match template on an event without an away team: "Gala x , em Braga" → "Gala, em Braga".
.replace(/\s+x\s*(?=,|$)/g, "")
// City missing, venue kept: ", em , no Estádio" → ", no Estádio" (keep the article).
.replace(/,\s*em\s*,\s*(n[oa]s?\s+)/gi, ", $1")
// Both city and venue missing: trailing ", em , no" / ", em , na".
.replace(/,\s*em\s*,\s*n[oa]s?\s*$/gi, "")
// Leftover empty city slot: ", em ,".
.replace(/,\s*em\s*,/gi, ",")
// Venue missing at the end: ", em Braga, no" → ", em Braga".
.replace(/,\s*n[oa]s?\s*$/gi, "")
// Orphan "em" at the end: ", em".
.replace(/,\s*em\s*$/gi, "")
.replace(/\s{2,}/g, " ")
.replace(/,\s*$/g, "")
.replace(/^\s*,\s*/g, "")
.trim();
}
+24
View File
@@ -99,6 +99,30 @@ describe("IPTC template", () => {
expect(old.event).toBe("Conferência de imprensa do FC Porto");
});
it("does not send a broken Portuguese caption when city and venue are missing", () => {
// Delivered to Cofina as "AFS x FC Vizela, em , no" — unusable in the newsroom.
const game = { home: "AFS", away: "FC Vizela", venue: "", city: "", sport: "futebol", startsAt: new Date("2026-11-04T20:00:00Z") };
const { values, issues } = applyTemplate(NEWSROOM_TEMPLATE, buildVars(game, { players: ["Rodrigo Pinho"] }, "MovePhoto"));
expect(values.caption).toBe("AFS x FC Vizela");
expect(values.headline).toBe("AFS x FC Vizela");
expect(values.event).toBe("AFS x FC Vizela");
expect(values.city).toBeUndefined();
expect(values.location).toBeUndefined();
expect(issues.filter((i) => i.kind === "missing_variable").map((i) => i.detail).sort()).toEqual([
"city",
"city",
"city",
"venue",
"venue",
"venue",
]);
// Only one of city / venue filled: keep the clause that still makes sense.
expect(applyTemplate(NEWSROOM_TEMPLATE, buildVars({ ...game, city: "Vizela" }, {}, "P")).values.caption).toBe("AFS x FC Vizela, em Vizela");
expect(applyTemplate(NEWSROOM_TEMPLATE, buildVars({ ...game, venue: "Estádio do FC Vizela" }, {}, "P")).values.caption).toBe(
"AFS x FC Vizela, no Estádio do FC Vizela",
);
});
it("expands codes typed by an editor and keeps long venues whole", () => {
const { values, issues } = applyTemplate({ title: "\\v7\\", location: "{venue}" }, buildVars(braga), codeList({ v7: "Miguel Silva (VSC)" }));
expect(values.title).toBe("Miguel Silva (VSC)");