From fbe9fa0f644accb3ee24b748b9d66a117aca0e20 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Mon, 30 Nov 2026 20:19:42 +0000 Subject: [PATCH 1/2] fix(character): wait for this character's Trash echo and tell agents about Trash (#1663) trash_character now passes an accept filter to rpc_reply, so an rzMKMb echo for another character is skipped instead of being read as a failed removal. The gflow_character_list and gflow_character_show descriptions say that characters in Trash are omitted, and the list_characters docstring no longer claims it returns every character. --- CHANGELOG.md | 4 ++++ src/gflow_cli/api/_flow_characters.py | 2 +- .../api/transports/migrated_character.py | 11 ++++++++++- src/gflow_cli/mcp/tools.py | 6 ++++-- tests/api/transports/test_migrated_character.py | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8109a04f2..5d803ebfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **`character rm` on flow.google.com waits for its own Trash confirmation ([#1663](https://github.com/ffroliva/gflow-cli/issues/1663)).** + A `rzMKMb` reply for another character no longer reads as a failed removal. The MCP + `gflow_character_list` and `gflow_character_show` descriptions now say that characters in + Trash are omitted. - **`character rm` moves a character to Trash on flow.google.com (#1445).** Flow keeps it in the project's Trash, where it can be restored; trashed characters are excluded from `character list` and `character show`. Contract changes on an account served flow.google.com: `--json` reports the diff --git a/src/gflow_cli/api/_flow_characters.py b/src/gflow_cli/api/_flow_characters.py index adc152773..9747ea1b5 100644 --- a/src/gflow_cli/api/_flow_characters.py +++ b/src/gflow_cli/api/_flow_characters.py @@ -86,7 +86,7 @@ async def _read_migrated_project(self, project_id: str) -> ProjectRead: async def list_characters( self, project_id: str, *, migrated_read: bool = True ) -> list[Character]: - """Return all CHARACTER entities in *project_id*. + """Return the CHARACTER entities in *project_id* (on flow.google.com, not those in Trash). Maps to ``GET .../trpc/flow.projectInitialData?input=…``, and to ``flow.google.com``'s ``Zzl0ze`` project read when that route refuses diff --git a/src/gflow_cli/api/transports/migrated_character.py b/src/gflow_cli/api/transports/migrated_character.py index 818fc68e4..cbf102266 100644 --- a/src/gflow_cli/api/transports/migrated_character.py +++ b/src/gflow_cli/api/transports/migrated_character.py @@ -663,11 +663,20 @@ async def _open_editor(page: Page, project_id: str, entity_id: str) -> None: async def trash_character(page: Page, project_id: str, entity_id: str) -> None: """Use Flow's character editor to move one character to the project Trash.""" + + def accept(payload: object) -> bool: + # Skip rzMKMb echoes for another character; an unparseable frame goes to the drift check. + rows = _list(payload) or [] + row = _list(rows[0]) if rows else None + if row is None or len(row) < 2: + return True + return _str(row[0]) == project_id and _str(row[1]) == entity_id + try: await _open_editor(page, project_id, entity_id) button = page.locator("flow-character-edit-header button:has(mat-icon:text-is('delete'))") reply = await migrated_composer.rpc_reply( - page, PATCH_RPC, button.click, timeout_s=45.0, write=True + page, PATCH_RPC, button.click, timeout_s=45.0, write=True, accept=accept ) except PlaywrightError as exc: raise _browser_error(exc, "while moving the character to Trash") from exc diff --git a/src/gflow_cli/mcp/tools.py b/src/gflow_cli/mcp/tools.py index f3a6a2d8d..6de7e3d3d 100644 --- a/src/gflow_cli/mcp/tools.py +++ b/src/gflow_cli/mcp/tools.py @@ -1665,7 +1665,8 @@ def _character_to_dict(char: Any) -> dict[str, Any]: description=( "List the saved Flow CHARACTER entities in a project. Read-only, spends no credits. " "On flow.google.com, returns each character's entity_id, display_name, voice, " - "personality, workflow_ids and thumbnail_media_id. Pass entity_id in " + "personality, workflow_ids and thumbnail_media_id; characters moved to the " + "project's Trash are omitted. Pass entity_id in " "reference_entities paired with display_name in reference_entity_names (image and " "video r2v). On flow.google.com, an image @Name still attaches the first word " "after @ by name via the @ picker without reading the character catalog, while " @@ -1736,7 +1737,8 @@ async def gflow_character_voices() -> dict[str, Any]: description=( "Show one saved Flow CHARACTER entity by id or by exact display name. " "Read-only, spends no credits. On flow.google.com, returns the character's " - "entity_id, display_name, voice, personality, workflow_ids and thumbnail_media_id. " + "entity_id, display_name, voice, personality, workflow_ids and thumbnail_media_id; a " + "character in the project's Trash is not found (character-not-found, exit 11). " "Exactly one of entity_id or name is required; ambiguous names fail. Drives a browser." ), ) diff --git a/tests/api/transports/test_migrated_character.py b/tests/api/transports/test_migrated_character.py index 84c089ad4..ce1cc0a5c 100644 --- a/tests/api/transports/test_migrated_character.py +++ b/tests/api/transports/test_migrated_character.py @@ -51,7 +51,7 @@ async def test_trash_character_with_no_reply_requires_reconciliation( page.locator.return_value.click = click monkeypatch.setattr(migrated_character, "_open_editor", AsyncMock()) - async def no_reply(_page, rpcid, action, *, timeout_s, write): + async def no_reply(_page, rpcid, action, *, timeout_s, write, accept): assert rpcid == migrated_character.PATCH_RPC assert write is True await action() @@ -76,6 +76,19 @@ def _trash_with_reply(monkeypatch: pytest.MonkeyPatch, reply: object) -> Mock: return page +async def test_trash_character_waits_past_echoes_for_another_character( + monkeypatch: pytest.MonkeyPatch, +) -> None: + page = _trash_with_reply(monkeypatch, [[_PROJECT, _ENTITY, None, [1, "Zoro", [], None, True]]]) + await migrated_character.trash_character(page, _PROJECT, _ENTITY) + accept = migrated_composer.rpc_reply.await_args.kwargs["accept"] # type: ignore[attr-defined] + archived = [1, "Zoro", [], None, True] + assert accept([[_PROJECT, _ENTITY, None, archived]]) + assert not accept([[_PROJECT, _PORTRAIT_WF, None, archived]]) + assert not accept([[_BODY_WF, _ENTITY, None, archived]]) + assert accept(["unparseable"]) # left to the drift check + + async def test_trash_character_accepts_the_archived_echo(monkeypatch: pytest.MonkeyPatch) -> None: page = _trash_with_reply(monkeypatch, [[_PROJECT, _ENTITY, None, [1, "Zoro", [], None, True]]]) await migrated_character.trash_character(page, _PROJECT, _ENTITY) From 0dbe9a07ffa87894369938ab8fc70aa88f5b2208 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Mon, 30 Nov 2026 20:29:49 +0000 Subject: [PATCH 2/2] fix(character): mark an unconfirmed Trash echo for reconciliation; move entries to Unreleased A reply for the requested character that does not confirm the archive is now WireFormatError with next_action=reconcile and the Trash hint, since Flow may have trashed it anyway. The accept filter rejects a frame only when its id cells are strings that differ, so a changed wire shape still reaches the drift check. The #1445 and #1663 CHANGELOG entries move from the released 0.110.0 section to Unreleased. --- CHANGELOG.md | 23 ++++++++++--------- .../api/transports/migrated_character.py | 19 +++++++++------ .../api/transports/test_migrated_character.py | 13 +++++------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d803ebfa..0a54715a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **The selector-drift check reads the video model picker more reliably ([#1643](https://github.com/ffroliva/gflow-cli/issues/1643)).** It decides the picker is open from the picker itself rather than from any overlay on the page, keeps a good read when only the final close fails (reported as `migrated.model_menu.close`), and grades the model entries as not evaluated when the read fails, instead of reporting every model missing. Contributed by @deepslit. - **`gflow auth status` no longer reports a held profile as signed out on an account served flow.google.com ([#1640](https://github.com/ffroliva/gflow-cli/issues/1640)).** When the flow.google.com session probe meets a profile held by another gflow process, or one Chrome refuses as already in use, `gflow auth status` and `gflow_auth_status` now report it as profile-locked (exit 11), and a browser that cannot start or read as `profile_unavailable`, instead of "Signed in to Google, but not to the Flow app." Contributed by @deepslit. - **A bonus-credit promo that opens after a project page loads no longer blocks the next click ([#1641](https://github.com/ffroliva/gflow-cli/issues/1641)).** On an account that shows Flow's bonus-credit promo, the dialog opens about a second after every project page load, after the editor gate's one-shot dialog check has already looked, and its backdrop intercepted the next click (`video extend` ended at exit 23, `image i2i --ref ` at exit 1). The editor gate, and `video extend`'s direct entry into the clip editor, now install a handler for the page's life that clicks the promo's own close button (`flow-g1-promo-dialog button.close-button`, the #1557 anchor) whenever it covers an action. It never clicks the claim or no-thanks buttons. +- **`character rm` moves a character to Trash on flow.google.com (#1445).** Flow keeps it in the + project's Trash, where it can be restored; trashed characters are excluded from `character list` + and `character show`. Contract changes on an account served flow.google.com: `--json` reports the + removed character under `trashed` instead of `deleted`; a `character show` miss (CLI and + `gflow_character_show`) has type `/character-not-found`, still exit 11; and a profile pinned to + `GFLOW_CLI_FLOW_HOST=labs.google` whose project Flow serves from flow.google.com exits 36 before + anything is removed. On labs.google, `character rm` still deletes through `flow:batchDeleteAssets`. +- **`character rm` on flow.google.com skips Flow replies about other characters ([#1663](https://github.com/ffroliva/gflow-cli/issues/1663)).** + A `rzMKMb` reply naming another character no longer reads as a failed removal, and a reply for + this character that does not confirm the move is marked `reconcile` (check the project's + Trash before running it again). The MCP `gflow_character_list` and `gflow_character_show` + descriptions now say that characters in Trash are omitted. ### Tests @@ -39,17 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- **`character rm` on flow.google.com waits for its own Trash confirmation ([#1663](https://github.com/ffroliva/gflow-cli/issues/1663)).** - A `rzMKMb` reply for another character no longer reads as a failed removal. The MCP - `gflow_character_list` and `gflow_character_show` descriptions now say that characters in - Trash are omitted. -- **`character rm` moves a character to Trash on flow.google.com (#1445).** Flow keeps it in the - project's Trash, where it can be restored; trashed characters are excluded from `character list` - and `character show`. Contract changes on an account served flow.google.com: `--json` reports the - removed character under `trashed` instead of `deleted`; a `character show` miss (CLI and - `gflow_character_show`) has type `/character-not-found`, still exit 11; and a profile pinned to - `GFLOW_CLI_FLOW_HOST=labs.google` whose project Flow serves from flow.google.com exits 36 before - anything is removed. On labs.google, `character rm` still deletes through `flow:batchDeleteAssets`. - **The flow.google.com image e2e tests assert the route each run took.** On an account served flow.google.com, text-to-image at measured settings now goes direct, so three tests diff --git a/src/gflow_cli/api/transports/migrated_character.py b/src/gflow_cli/api/transports/migrated_character.py index cbf102266..bc2d6c514 100644 --- a/src/gflow_cli/api/transports/migrated_character.py +++ b/src/gflow_cli/api/transports/migrated_character.py @@ -664,13 +664,16 @@ async def _open_editor(page: Page, project_id: str, entity_id: str) -> None: async def trash_character(page: Page, project_id: str, entity_id: str) -> None: """Use Flow's character editor to move one character to the project Trash.""" + check_trash = "Check the project's Trash on flow.google.com before running character rm again." + def accept(payload: object) -> bool: - # Skip rzMKMb echoes for another character; an unparseable frame goes to the drift check. + # Skip rzMKMb echoes that name another character; any other shape goes to the drift check. rows = _list(payload) or [] row = _list(rows[0]) if rows else None if row is None or len(row) < 2: return True - return _str(row[0]) == project_id and _str(row[1]) == entity_id + ids = ((_str(row[0]), project_id), (_str(row[1]), entity_id)) + return all(got is None or got == want for got, want in ids) try: await _open_editor(page, project_id, entity_id) @@ -685,9 +688,7 @@ def accept(payload: object) -> bool: detail="Flow did not confirm whether the character moved to Trash.", route=f"batchexecute:{PATCH_RPC}", charged="no", - remediation_hint=( - "Check the project's Trash on flow.google.com before running character rm again." - ), + remediation_hint=check_trash, ) from exc rows = _list(reply) or [] row = _list(rows[0]) if rows else None @@ -695,8 +696,12 @@ def accept(payload: object) -> bool: raise _drift(reply, "trash reply carries no character", PATCH_RPC) project, entity, info = _character_row_header(row, reply, PATCH_RPC) if project != project_id or entity != entity_id or info[0] != 1 or not _is_archived(info): - raise _drift( - reply, "trash reply did not confirm the requested character was archived", PATCH_RPC + # Flow may have trashed it anyway (#1663): never retry blindly. + raise _unsafe_to_retry( + _drift( + reply, "trash reply did not confirm the requested character was archived", PATCH_RPC + ), + check_trash, ) diff --git a/tests/api/transports/test_migrated_character.py b/tests/api/transports/test_migrated_character.py index ce1cc0a5c..aabc62c44 100644 --- a/tests/api/transports/test_migrated_character.py +++ b/tests/api/transports/test_migrated_character.py @@ -76,7 +76,7 @@ def _trash_with_reply(monkeypatch: pytest.MonkeyPatch, reply: object) -> Mock: return page -async def test_trash_character_waits_past_echoes_for_another_character( +async def test_trash_character_accepts_its_archive_echo_and_filters_other_characters( monkeypatch: pytest.MonkeyPatch, ) -> None: page = _trash_with_reply(monkeypatch, [[_PROJECT, _ENTITY, None, [1, "Zoro", [], None, True]]]) @@ -87,11 +87,7 @@ async def test_trash_character_waits_past_echoes_for_another_character( assert not accept([[_PROJECT, _PORTRAIT_WF, None, archived]]) assert not accept([[_BODY_WF, _ENTITY, None, archived]]) assert accept(["unparseable"]) # left to the drift check - - -async def test_trash_character_accepts_the_archived_echo(monkeypatch: pytest.MonkeyPatch) -> None: - page = _trash_with_reply(monkeypatch, [[_PROJECT, _ENTITY, None, [1, "Zoro", [], None, True]]]) - await migrated_character.trash_character(page, _PROJECT, _ENTITY) + assert accept([[_PROJECT, 7, None, archived]]) # a changed id shape is drift, not a wait @pytest.mark.parametrize( @@ -109,8 +105,11 @@ async def test_trash_character_refuses_an_echo_that_does_not_confirm_the_archive monkeypatch: pytest.MonkeyPatch, row: list[Any] ) -> None: page = _trash_with_reply(monkeypatch, [row]) - with pytest.raises(WireFormatError, match="archived"): + with pytest.raises(WireFormatError, match="archived") as exc: await migrated_character.trash_character(page, _PROJECT, _ENTITY) + assert not is_retryable(exc.value) + assert exc.value.to_problem_details()["next_action"] == "reconcile" + assert "Trash" in str(exc.value.remediation_hint) async def test_trash_character_types_a_browser_failure(monkeypatch: pytest.MonkeyPatch) -> None: