Skip to content

agency: deep-link glued to card + label adapts to spawn-topic mode#106

Merged
MagMueller merged 1 commit intomainfrom
agency-deeplink-on-card
May 8, 2026
Merged

agency: deep-link glued to card + label adapts to spawn-topic mode#106
MagMueller merged 1 commit intomainfrom
agency-deeplink-on-card

Conversation

@MagMueller
Copy link
Copy Markdown
Contributor

@MagMueller MagMueller commented May 8, 2026

Two UX wins on the spawn-topic flow.

1. Default-button labels reflect routing

Before: `✅ Yes` / `⏭ Skip` / `✏️ Edit` regardless of whether `--spawn-topic` was set. From the button alone you couldn't tell if tapping would run in-place or fork a topic.

After:

  • `--spawn-topic` OFF → `✅ Yes` / `⏭ Skip` / `✏️ Edit`
  • `--spawn-topic` ON → `🧵 Yes (new thread)` / `⏭ Skip` / `🧵 Edit (new thread)`

`agency-report` picks the variant at post time from `args.spawn_topic`.

2. Deep-link to the spawned topic is glued to the card

Before: when Yes/Edit spawned a fresh forum topic, the bot posted a separate "→ working in X" reply under the card with a `🧵 Open thread` URL-button. That reply got buried as more cards landed in the topic — by the time you scrolled back to the card, the link was several screens away.

After: the URL-button row gets appended to the card's own `inline_keyboard`. It scrolls with the card. You can jump to the worker topic from the card itself, even weeks later.

`_agency_mark_picked` grows an `append_url_row` parameter. It also strips any prior trailing URL-only rows before re-applying so the deep-link doesn't accumulate across re-taps. Re-applied on every tap so the link survives mid-mind-changes.

3. Multi-tap dedupes the worker thread

Tapping Yes twice no longer creates two topics. The first tap sets `worker_topic_id` in agency.db; subsequent action/refine taps reuse it and re-dispatch into the same thread. The URL-row on the card always points at that one worker topic.

Refactor

The worker-topic resolution moved before the keyboard mark in `_handle_agency_callback` so we know `new_thread_id` when computing the URL row to glue. The previous "mark first → spawn → reply with URL" ordering is replaced with "resolve-thread → mark with URL row → dispatch".

The standalone URL-reply block at the bottom of the action/refine handler is dropped — superseded by the on-card row.

Test plan

  • `agency-report --spawn-topic` posts a card with the `🧵 Yes (new thread)` label
  • `agency-report` (no flag) posts a card with the `✅ Yes` label
  • Tap Yes on a `--spawn-topic` card → fresh topic spawns AND a `🧵 Open thread` URL row appears as the last keyboard row
  • Re-tap Yes on the same card → no new topic; URL row keeps pointing to the same one
  • Tap Skip then Yes → URL row still points to the original spawned topic (Skip preserves `worker_topic_id`)
  • Tap a card with no `--spawn-topic` → no URL row appears (work runs in-place)

Summary by cubic

Makes the spawn-topic flow clearer and easier to navigate. Buttons now show if they fork a thread, and the deep-link to that thread stays attached to the card. Also prevents duplicate threads on multi-tap.

  • New Features

    • Button labels adapt to --spawn-topic at post time:
      • Off → ✅ Yes / ⏭ Skip / ✏️ Edit
      • On → 🧵 Yes (new thread) / ⏭ Skip / 🧵 Edit (new thread)
    • When a new thread is spawned, a "🧵 Open thread" URL row is added to the card’s inline_keyboard so the link scrolls with the card.
    • Multi-tap reuses the same worker thread via worker_topic_id; no duplicate topics.
  • Refactors

    • Resolve or create the worker thread before marking the keyboard; then mark (with optional URL row) and dispatch.
    • Removed the separate "→ working in X" reply; _agency_mark_picked now accepts append_url_row and cleans trailing URL-only rows to avoid duplicates.

Written for commit 7998a64. Summary will update on new commits.

Two improvements to the spawn-topic flow that survive across many
stacked cards.

1. Default-button labels reflect --spawn-topic
   ────────────────────────────────────────────────────
   Was: "✅ Yes" / "⏭ Skip" / "✏️ Edit" regardless of routing.
   Now: "🧵 Yes (new thread)" / "⏭ Skip" / "🧵 Edit (new thread)" when
   --spawn-topic is set; the original labels otherwise.

   The user can tell from the button alone whether tapping will fork
   a topic or run in-place. agency-report picks the variant via
   args.spawn_topic at post time.

2. Deep-link to the spawned topic glues to the card
   ────────────────────────────────────────────────────
   Was: after spawn, the bot posted a separate "→ working in X" reply
   under the card with a URL-button. That reply got buried as more
   cards landed in the topic.
   Now: the URL-button row ("🧵 Open thread") is appended to the
   card's own inline_keyboard. It scrolls with the card; you can jump
   to the worker topic from the card itself even weeks later.

   _agency_mark_picked grows append_url_row. It also strips any prior
   trailing URL-only rows before re-applying so the deep-link doesn't
   accumulate across re-taps.

   Multi-tap dedupes the worker thread: tapping Yes twice no longer
   creates two topics. The first tap sets worker_topic_id in the DB;
   subsequent action/refine taps reuse it and re-dispatch into the
   same thread.

The worker-topic resolution moved BEFORE the keyboard mark so we know
new_thread_id when computing the URL-row to glue. The dispatch-then-
deep-link-reply ordering of the previous shape is replaced with
resolve-thread-then-mark-then-dispatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MagMueller MagMueller merged commit 0a18fa6 into main May 8, 2026
6 checks passed
@MagMueller MagMueller deleted the agency-deeplink-on-card branch May 8, 2026 17:42
MagMueller added a commit that referenced this pull request May 8, 2026
Magnus's rule: if I'm already deep in one topic (sub-agent posting a
follow-up card inside a worker thread) Yes/Edit should run in-place;
if I'm in a multi-suggestion context (the main agency feed, a fresh
chat, the /agency loop) Yes/Edit should fork a new topic per card.

Encoded as code, not just docs, so the LLM agent doesn't have to
remember:

  agency_db.is_worker_topic(thread_id) — True iff the thread was
    spawned as worker_topic for some other suggestion. Excludes
    in-place bookkeeping (cards whose own tg_thread_id == the
    worker_topic_id).

  agency-report:
    --spawn-topic    → force spawn (existing flag, now explicit override)
    --no-spawn-topic → force in-place (new flag)
    neither          → auto-detect via is_worker_topic

The mutually-exclusive group + store_const trick keeps the auto path
distinguishable (args.spawn_topic is None) from explicit on/off.

Default-button labels and the deep-link glue (#106) keep working —
they read args.spawn_topic which is now the resolved value.

Skill + docstring updated to document the auto-default and when to
override.

Co-authored-by: bux <bux@browser-use.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant