Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ jobs:
# from a local page and drives the model and aspect pickers against it (#1772).
# A tenth, test_closed_page_after_click_bdd.py, serves a composer whose submit button closes
# the page, and checks a page closed after the click is not a retryable closed browser (#1761).
# The project title readback test intercepts creation and drops the rename reply (#1784).
- name: E2E (hermetic subset — route-intercepted, $0, no profile)
if: matrix.shard == 'e2e'
run: >
Expand All @@ -416,6 +417,7 @@ jobs:
tests/e2e/test_no_spend_e2e.py
tests/e2e/test_config_e2e.py
tests/e2e/test_catalog_aliases_e2e.py
tests/e2e/test_unconfirmed_project_title_bdd.py
--junitxml=pytest-e2e-hermetic.xml

- name: E2E-count guard (an empty e2e run is not a passing e2e run)
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- On `flow.google.com`, a new project can keep its saved title when Flow's
rename reply is missing and readback confirms the project. Generation uses that
project and warns about the title: `image t2i`/`i2i --json` and the MCP image,
extend and edit tasks, and video tasks given `project_name`, carry a
`project_title_unconfirmed` warning naming the saved title. If readback fails, the rename error explains
how to reuse the project and reports no generation charge. A browser error during that rename
(a timeout as well as a closed browser) now also ends in that error (exit 7, not retried),
so a retry cannot create a second project ([#1784](https://github.com/ffroliva/gflow-cli/issues/1784)).
- The storyboard tool now sends the requested panel count to the model for inline `--tool`,
standalone `tools run --panels`, and MCP generation requests. It accepts 1 to 20 panels
and defaults to 4 (#1754).
Expand Down
5 changes: 5 additions & 0 deletions docs/ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ place today:
`no` / `retry` where nothing was written: a `gflow project create` whose browser closes
before Create is clicked, and a standalone `gflow project rename` (renaming again sets the
same title).
- When Flow confirms project creation but the title reply is lost, gflow can keep
the saved title after verifying the project. If it cannot verify the project, or
a standalone rename's title remains unconfirmed, `RpcResponseUnavailableError`
reads `no` / `reconcile` and points to the project to check. No generation was
submitted ([#1784](https://github.com/ffroliva/gflow-cli/issues/1784)).
- Sites that provably submitted nothing read `no`: the flow.google.com extend editor
guard (`none`), the `/about` landing (`reauth`), and both balance-read failures.
- On flow.google.com, a gflow error raised before the generation's submit click reads
Expand Down
5 changes: 5 additions & 0 deletions docs/MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ is [BROWSER_MODES](BROWSER_MODES.md).

CLI↔MCP parity is enforced programmatically: `tests/mcp/test_cli_parity.py` walks every CLI leaf command and fails when one has neither a mapped MCP tool nor an explicit exemption with a stated reason. Note the deliberate asymmetry: `gflow_generate_video` has **no** `instructions` param (unlike `gflow_generate_image`) because the video pipeline (`GenerateVideoRequest` / the worker) has no instructions support — agentic-video is a typed divergence, and a dead parameter would be silently dropped. Both `gflow_generate_image` and `gflow_generate_video` support an `out_file` parameter mirroring the CLI `--out-file` flag (#414, #415, #1158), decoding explicit output destinations in the worker path (legacy `output` parameter removed in #1158). Both tools refuse an output path that names a directory (including the output directory itself) with a 400 `Invalid Output` envelope before anything is queued, as the CLI's `--out-file` refuses one ([#1114](https://github.com/ffroliva/gflow-cli/issues/1114)). Unlike the CLI's `--out-file`, an MCP `out_file` — and the `out_dir` of `gflow_download_media`, `gflow_upscale_image` and `gflow_upscale_video` — must resolve **inside the configured output directory** ([`GFLOW_CLI_OUTPUT_DIR`](CONFIGURATION.md#gflow_cli_output_dir)): a relative value is taken relative to it, and a value that resolves outside it (`..`, an absolute path elsewhere, a link leading out) is refused with a 400 `Invalid Output` / `Invalid out_dir` envelope before anything runs. An MCP client may be steered by untrusted content, so it cannot choose where on disk the server writes; for the same reason a tool that opens a browser profile takes `profile` only as a plain name, never a path ([GHSA-hqfj-4jww-76f2](https://github.com/ffroliva/gflow-cli/security/advisories/GHSA-hqfj-4jww-76f2)). `gflow update` is a considered exemption, not a backlog item: the package manager would replace the venv under a live `gflow mcp run` and write its output onto the JSON-RPC stdout channel — the operator runs it and restarts the server. A read-only twin of `gflow update --check` would be harmless; it is the upgrade path if agents ever need version awareness beyond the `initialize` handshake.

When an image, extend or edit task, or a video task given `project_name`, creates a
project on `flow.google.com` and Flow keeps a different saved title, its reply includes a warning
`{"type": "project_title_unconfirmed", "project_id": ..., "saved_title": ..., "message": ...}`.
The generation uses that project.

### Prompts (Orchestration templates)
* `expand_prompt`: Helps the agent structure simple ideas into Google's official 5-component prompt formula (Subject + Action + Location + Composition + Style) before sending them to the generation tools.
* `create_character`: Assists agents in defining face, body, and voice parameters for consistent subject generation.
Expand Down
10 changes: 9 additions & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,13 @@ gflow project show PROJ123 [--json]
gflow project rename PROJ123 "Storyboard v2" [--json]
```

On `flow.google.com`, a newly created project can keep its saved title when the
rename reply is unavailable and gflow can still verify that project. The command
warns about the title and continues with the same project ID; `image t2i` and
`image i2i` add `{"type": "project_title_unconfirmed", "project_id": ...,
"saved_title": ..., "message": ...}` to their `--json` `warnings`. A standalone `project rename`
still requires confirmation of the requested title.

## Batch video generation (shell loop)

`gflow video` has no `batch` subcommand — a manifest-driven video runner
Expand Down Expand Up @@ -2792,7 +2799,8 @@ use. When set:
aspect (`{"type": "aspect_mismatch", "requested": "16:9", "width": 1024, "height": 768}`),
a result byte-identical to a local reference image (`{"type": "echoed_reference"}`),
and a file under 8 KB (`{"type": "tiny_file", "bytes": 512, "min_bytes": 8192}`). Each
entry carries the image's `media_name` and joins the same `warnings` list; without
entry carries the image's `media_name` and joins the same `warnings` list, after a
`project_title_unconfirmed` entry when a project gflow created kept another title; without
`--json` it is a yellow line under the table, and `gflow run` / `gflow image batch`
add it to the row. A check never fails the run and never moves or deletes the file.
Single-prompt only — `--json` rejects
Expand Down
19 changes: 18 additions & 1 deletion src/gflow_cli/api/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass, replace
from dataclasses import dataclass, field, replace
from typing import TYPE_CHECKING, Any, Literal, cast

if TYPE_CHECKING:
Expand Down Expand Up @@ -109,6 +109,23 @@ class ProjectInfo:

project_id: str
title: str
title_unconfirmed: bool = field(default=False, repr=False, compare=False)

def title_warnings(self) -> list[dict[str, str]]:
"""#1784: the result warning for a project Flow saved under another title, else none."""
if not self.title_unconfirmed:
return []
return [
{
"type": "project_title_unconfirmed",
"project_id": self.project_id,
"saved_title": self.title,
"message": (
"Flow did not confirm the requested title; "
f"the project is saved as {self.title!r}."
),
}
]

@classmethod
def from_create_response(cls, data: dict[str, Any]) -> ProjectInfo:
Expand Down
2 changes: 2 additions & 0 deletions src/gflow_cli/api/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def describe_result_warning(warning: Mapping[str, Any]) -> str:
return f"Warning: {media} is {got}, not the requested {warning['requested']}."
if kind == "echoed_reference":
return f"Warning: {media} is byte-identical to a reference image."
if kind == "project_title_unconfirmed":
return f"Warning: {warning['message']}"
return f"Warning: {media} is only {warning.get('bytes')} bytes; it may be a placeholder."


Expand Down
14 changes: 10 additions & 4 deletions src/gflow_cli/api/transports/_mc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,9 @@ async def _project_snapshot(
"""Read persisted project state in a fresh tab without resetting the composer."""
probe = await page.context.new_page()
try:
target = MIGRATED_PROJECT_URL.format(project_id=project_id)
await probe.goto(
MIGRATED_PROJECT_URL.format(project_id=project_id),
target,
wait_until="domcontentloaded",
timeout=45_000,
)
Expand Down Expand Up @@ -1198,7 +1199,11 @@ async def _project_snapshot(
await probe.wait_for_timeout(1000)
await probe.reload(wait_until="domcontentloaded", timeout=15_000)
await field.wait_for(state="visible", timeout=15_000)
return await field.input_value(), tiles
title = await field.input_value()
if not is_at(probe.url, target):
msg = "Project readback did not stay on the requested project."
raise WireFormatError(detail=msg, charged="no") # a readback bills nothing (#1784)
return title, tiles
finally:
await probe.close()
await page.bring_to_front() # the composer's typing and `@` picker need focus
Expand Down Expand Up @@ -1650,9 +1655,10 @@ def _write_outcome_unknown(
error: TransportTimeoutError | RpcResponseUnavailableError, rpcid: str, hint: str
) -> RpcResponseUnavailableError:
"""A write whose request was sent but whose result nobody saw: exit 7, never retried
(the class is outside ``RETRYABLE_ERRORS``)."""
(the class is outside ``RETRYABLE_ERRORS``). Only project writes use it, and they bill
nothing (#1784)."""
return RpcResponseUnavailableError(
detail=error.detail, route=f"batchexecute:{rpcid}", remediation_hint=hint
detail=error.detail, route=f"batchexecute:{rpcid}", remediation_hint=hint, charged="no"
)


Expand Down
132 changes: 100 additions & 32 deletions src/gflow_cli/api/transports/migrated_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ async def create_project(
``timeout_s`` bounds the create reply; the selector wait stays at ``ANCHOR_TIMEOUT_S``.
Once Create is clicked, a failure never reads as retryable: a lost or late reply is
recovered from Flow's navigation to the new project, or is "outcome unknown" (#1037).
If only the rename was unconfirmed, a verified new project can keep its saved title.
Leaves ``page`` on the new project, which is where every caller goes next."""
try:
await page.goto(MIGRATED_ROOT_URL, wait_until="domcontentloaded", timeout=45_000)
Expand Down Expand Up @@ -891,6 +892,7 @@ async def create_project(
detail="The browser closed during the project create attempt.",
route=f"batchexecute:{CREATE_PROJECT_RPC}",
remediation_hint=_CREATE_RECOVERY_HINT,
charged="no",
) from exc
reply = _as_list_any(payload)
project_id: object = reply[0] if reply else None
Expand All @@ -904,26 +906,99 @@ async def create_project(
created: object = names[0] if names else None
if title and created != title:
try:
await rename_project(page, project_id, title, timeout_s=timeout_s)
created = await rename_project(
page, project_id, title, timeout_s=timeout_s, allow_saved_title=True
)
except retryable_engine_errors() as exc:
if not _is_target_closed(exc):
raise
# The project exists: a retry would create a second one, so always reconcile.
closed = _is_target_closed(exc)
raise RpcResponseUnavailableError(
detail="Flow created the project before the browser closed during rename.",
detail=(
"Flow created the project before the browser closed during rename."
if closed
else "Flow created the project, then the browser failed during rename "
f"({type(exc).__name__})."
),
route=f"batchexecute:{RENAME_PROJECT_RPC}",
remediation_hint=f"Reuse the existing project with --project {project_id}.",
charged="no",
) from exc
created = title
return ProjectInfo(project_id=project_id, title=str(created or ""))
return ProjectInfo(
project_id=project_id,
title=str(created or ""),
title_unconfirmed=bool(title and created != title),
)


def _require_rename_page(page: Page, target: str, project_id: str) -> None:
if not is_at(page.url, target):
raise WireFormatError(
detail="Flow left the requested project before its title could be saved.",
route=f"batchexecute:{RENAME_PROJECT_RPC}",
charged="no",
remediation_hint=f"Check the title at {target} and reuse --project {project_id}.",
)


async def _recover_rename(
page: Page,
project_id: str,
title: str,
original_error: RpcResponseUnavailableError | TransportTimeoutError,
*,
allow_saved_title: bool,
) -> str:
"""Settle a lost rename reply by reading the saved title back (#992, #1037, #1784).
Returns the saved title: the requested one, or, when ``allow_saved_title``, the one Flow
kept. Anything unproven raises the outcome-unknown error."""
target = MIGRATED_PROJECT_URL.format(project_id=project_id)
unknown = _write_outcome_unknown(
original_error,
RENAME_PROJECT_RPC,
f"The rename was sent but not confirmed. Check the title at {target} "
f"and reuse the project with --project {project_id}.",
)
try:
persisted_title, _ = await _project_snapshot(page, project_id)
except Exception: # noqa: BLE001 - no readback means the outcome stays unknown
raise unknown from original_error
project_page_unavailable = allow_saved_title and (
page.is_closed() or not is_at(page.url, target)
)
title_unconfirmed = persisted_title != title
if project_page_unavailable or (
title_unconfirmed and (not allow_saved_title or not persisted_title.strip())
):
raise unknown from original_error
if title_unconfirmed:
log.warning(
"migrated.project_title_unconfirmed",
project_id=project_id,
message="The new project is available under its saved title.",
)
else:
log.info(
"migrated.project_rename_recovered",
project_id=project_id,
after=type(original_error).__name__,
)
return persisted_title


async def rename_project(
page: Page, project_id: str, title: str, *, timeout_s: float = PAGE_RPC_TIMEOUT_S
) -> None:
page: Page,
project_id: str,
title: str,
*,
timeout_s: float = PAGE_RPC_TIMEOUT_S,
allow_saved_title: bool = False,
) -> str:
"""Rename a project through its header title on flow.google.com.
``timeout_s`` bounds the rename reply; the selector wait stays at ``ANCHOR_TIMEOUT_S``.
A lost or late reply is settled by reading the saved title back (#992, #1037)."""
A lost or late reply is settled by reading the saved title back (#992, #1037).
Only creation may keep the saved title instead of confirming the requested name."""
target = MIGRATED_PROJECT_URL.format(project_id=project_id)
if not is_at(getattr(page, "url", ""), target):
await page.goto(target, wait_until="domcontentloaded", timeout=45_000)
Expand All @@ -936,16 +1011,21 @@ async def rename_project(
at="migrated.rename_project",
timeout_s=min(timeout_s, ANCHOR_TIMEOUT_S),
)
_require_rename_page(page, target, project_id)

if await field.input_value() == title:
persisted_title, _ = await _project_snapshot(page, project_id)
if persisted_title == title:
log.info("migrated.project_title_unchanged", project_id=project_id)
return
if (
await field.input_value() == title
and (await _project_snapshot(page, project_id))[0] == title
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
):
_require_rename_page(page, target, project_id)
log.info("migrated.project_title_unchanged", project_id=project_id)
return title

async def submit() -> None:
try:
_require_rename_page(page, target, project_id)
await field.fill(title, timeout=15_000)
_require_rename_page(page, target, project_id)
await field.press("Enter", timeout=15_000)
except PlaywrightTimeoutError as e:
raise UiSelectorDriftError(
Expand All @@ -959,25 +1039,12 @@ async def submit() -> None:
try:
payload = await rpc_reply(page, RENAME_PROJECT_RPC, submit, timeout_s=timeout_s, write=True)
except (RpcResponseUnavailableError, TransportTimeoutError) as original_error:
unknown = _write_outcome_unknown(
original_error,
RENAME_PROJECT_RPC,
f"The rename was sent but not confirmed. Project {project_id} exists; open it "
"on https://flow.google.com/ to check its title, and reuse it with "
f"--project {project_id} rather than creating another.",
)
try:
persisted_title, _ = await _project_snapshot(page, project_id)
except Exception: # noqa: BLE001 - no readback means the outcome stays unknown
raise unknown from original_error
if persisted_title != title:
raise unknown from original_error
payload = [persisted_title]
log.info(
"migrated.project_rename_recovered",
project_id=project_id,
after=type(original_error).__name__,
saved = await _recover_rename(
page, project_id, title, original_error, allow_saved_title=allow_saved_title
)
if saved != title:
return saved
payload = [saved]
echo = _as_list_any(payload)
echoed: object = echo[0] if echo else None
if echoed != title:
Expand All @@ -986,6 +1053,7 @@ async def submit() -> None:
route=f"batchexecute:{RENAME_PROJECT_RPC}",
)
log.info("migrated.project_renamed", project_id=project_id)
return title


#: The app's own balance read: no arguments, fired on every load of the app (#795).
Expand Down
10 changes: 8 additions & 2 deletions src/gflow_cli/cli_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,10 @@ async def _run_t2i(
operation_kind="t2i",
undownloaded=undownloaded,
)
checks = saved_images_warnings(req, images, saved_paths) # #1534
checks = [ # #1534, #1784
*project.title_warnings(),
*saved_images_warnings(req, images, saved_paths),
]

if output_format == OutputFormat.ID.value:
for img in images[: len(saved_paths)]:
Expand Down Expand Up @@ -1825,7 +1828,10 @@ async def _generate(
project=project,
generate=_generate,
)
checks = saved_images_warnings(req, images, saved_paths, local_refs) # #1534
checks = [ # #1534, #1784
*project.title_warnings(),
*saved_images_warnings(req, images, saved_paths, local_refs),
]

if output_format == OutputFormat.ID.value:
for img in images[: len(saved_paths)]:
Expand Down
Loading