glic: Set the initial invocation source on background invocation [chromium/src : main]

0 views
Skip to first unread message

Ian Wells (Gerrit)

unread,
Jul 21, 2026, 1:32:26 PM (yesterday) Jul 21
to Nick Birnie, Yuheng Huang, Chromium LUCI CQ, chromium...@chromium.org, dewitt...@chromium.org
Attention needed from Nick Birnie

Ian Wells added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Ian Wells . resolved

Please take a look!

Open in Gerrit

Related details

Attention is currently required from:
  • Nick Birnie
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
Gerrit-Change-Number: 8129816
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Wells <iwe...@chromium.org>
Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
Gerrit-Reviewer: Nick Birnie <bir...@google.com>
Gerrit-CC: Yuheng Huang <yuh...@chromium.org>
Gerrit-Attention: Nick Birnie <bir...@google.com>
Gerrit-Comment-Date: Tue, 21 Jul 2026 17:32:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nick Birnie (Gerrit)

unread,
Jul 21, 2026, 7:22:58 PM (yesterday) Jul 21
to Ian Wells, Yuheng Huang, Chromium LUCI CQ, chromium...@chromium.org, dewitt...@chromium.org
Attention needed from Ian Wells

Nick Birnie added 2 comments

File chrome/browser/glic/service/glic_instance_impl.cc
Line 1032, Patchset 1 (Latest): return instance_metrics().initial_invocation_source();
Nick Birnie . unresolved

Its probably better style to create the const instance_metrics() but couldnt you have technically just used instance_metrics_.initial_invocation_source() here? Is there a reason beside style to do this?

File chrome/browser/glic/service/metrics/glic_instance_metrics.cc
Line 460, Patchset 1 (Latest):void GlicInstanceMetrics::OnShowInactiveSidePanel(
Nick Birnie . unresolved

If initial_invocation_source_ is populated here then later when the instance is brought to the foreground, GlicInstanceImpl invokes OnOpen() under kReshowInactive. Inside OnOpen(), the if (!initial_invocation_source_.has_value()) block evaluates to false, which causes base::UmaHistogramEnumeration("Glic.Instance.InitialInvocationSource", source); to be skipped completely. That instance would finish its lifecycle dropping that metric entirely.

Jetski wrote a test that fails:
```
TEST_F(GlicInstanceMetricsTest, InitialInvocationSource_LoggedWhenStartingInactive) {
// 1. Simulate opening the instance in an inactive side panel via a background daisy-chain.
metrics_.OnShowInactiveSidePanel(mojom::InvocationSource::kDaisyChainOnFollowLink);
  // 2. Later, the user activates the background tab, promoting the instance to be fully shown.
EXPECT_CALL(mock_tab_, GetTabHandle()).WillRepeatedly(testing::Return(1));
ShowOptions show_options{SidePanelShowOptions{mock_tab_}};
metrics_.OnOpen(mojom::InvocationSource::kReshowInactive, show_options);
  // 3. EXPECTATION: The original entry point (`kDaisyChainOnFollowLink`) should have been logged.
// CURRENT BEHAVIOR: This fails expecting 1 sample but getting 0.
histogram_tester_.ExpectUniqueSample(
"Glic.Instance.InitialInvocationSource",
mojom::InvocationSource::kDaisyChainOnFollowLink, 1);
}
```
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Wells
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
    Gerrit-Change-Number: 8129816
    Gerrit-PatchSet: 1
    Gerrit-Owner: Ian Wells <iwe...@chromium.org>
    Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
    Gerrit-Reviewer: Nick Birnie <bir...@google.com>
    Gerrit-CC: Yuheng Huang <yuh...@chromium.org>
    Gerrit-Attention: Ian Wells <iwe...@chromium.org>
    Gerrit-Comment-Date: Tue, 21 Jul 2026 23:22:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Ian Wells (Gerrit)

    unread,
    2:20 PM (7 hours ago) 2:20 PM
    to Nick Birnie, Yuheng Huang, Chromium LUCI CQ, chromium...@chromium.org, dewitt...@chromium.org
    Attention needed from Nick Birnie

    Ian Wells voted and added 2 comments

    Votes added by Ian Wells

    Commit-Queue+1

    2 comments

    File chrome/browser/glic/service/glic_instance_impl.cc
    Line 1032, Patchset 1: return instance_metrics().initial_invocation_source();
    Nick Birnie . resolved

    Its probably better style to create the const instance_metrics() but couldnt you have technically just used instance_metrics_.initial_invocation_source() here? Is there a reason beside style to do this?

    Ian Wells

    Frankly I let Jetski run wild and didn't bother to change this. I appreciate your assumption that there was a good reason though, haha

    There's no reason to add a const `instance_metrics()`, I'll change this function to use `instance_metrics_` directly.

    File chrome/browser/glic/service/metrics/glic_instance_metrics.cc
    Line 460, Patchset 1:void GlicInstanceMetrics::OnShowInactiveSidePanel(
    Nick Birnie . resolved

    If initial_invocation_source_ is populated here then later when the instance is brought to the foreground, GlicInstanceImpl invokes OnOpen() under kReshowInactive. Inside OnOpen(), the if (!initial_invocation_source_.has_value()) block evaluates to false, which causes base::UmaHistogramEnumeration("Glic.Instance.InitialInvocationSource", source); to be skipped completely. That instance would finish its lifecycle dropping that metric entirely.

    Jetski wrote a test that fails:
    ```
    TEST_F(GlicInstanceMetricsTest, InitialInvocationSource_LoggedWhenStartingInactive) {
    // 1. Simulate opening the instance in an inactive side panel via a background daisy-chain.
    metrics_.OnShowInactiveSidePanel(mojom::InvocationSource::kDaisyChainOnFollowLink);
      // 2. Later, the user activates the background tab, promoting the instance to be fully shown.
    EXPECT_CALL(mock_tab_, GetTabHandle()).WillRepeatedly(testing::Return(1));
    ShowOptions show_options{SidePanelShowOptions{mock_tab_}};
    metrics_.OnOpen(mojom::InvocationSource::kReshowInactive, show_options);
      // 3. EXPECTATION: The original entry point (`kDaisyChainOnFollowLink`) should have been logged.
    // CURRENT BEHAVIOR: This fails expecting 1 sample but getting 0.
    histogram_tester_.ExpectUniqueSample(
    "Glic.Instance.InitialInvocationSource",
    mojom::InvocationSource::kDaisyChainOnFollowLink, 1);
    }
    ```
    Ian Wells

    Good catch. I've updated how OnOpen() decides whether to log InitialInvocationSource to allow for initial_invocation_source_ already having been set by a background invocation. Also, added your test unchanged.

    IMO it's fine to change that metric in this way because kReshowInactive isn't a very useful signal for initial invocation source -- we should be getting strictly more information by logging whatever source was set when opening inactive.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Nick Birnie
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
      Gerrit-Change-Number: 8129816
      Gerrit-PatchSet: 2
      Gerrit-Owner: Ian Wells <iwe...@chromium.org>
      Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
      Gerrit-Reviewer: Nick Birnie <bir...@google.com>
      Gerrit-CC: Yuheng Huang <yuh...@chromium.org>
      Gerrit-Attention: Nick Birnie <bir...@google.com>
      Gerrit-Comment-Date: Wed, 22 Jul 2026 18:20:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Nick Birnie <bir...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Nick Birnie (Gerrit)

      unread,
      4:40 PM (4 hours ago) 4:40 PM
      to Ian Wells, Yuheng Huang, Chromium LUCI CQ, chromium...@chromium.org, dewitt...@chromium.org
      Attention needed from Ian Wells

      Nick Birnie voted and added 1 comment

      Votes added by Nick Birnie

      Code-Review+1

      1 comment

      File chrome/browser/glic/service/glic_instance_impl.h
      Line 52, Patchset 3 (Latest)://
      Nick Birnie . unresolved

      nit: leftover?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Ian Wells
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
        Gerrit-Change-Number: 8129816
        Gerrit-PatchSet: 3
        Gerrit-Owner: Ian Wells <iwe...@chromium.org>
        Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
        Gerrit-Reviewer: Nick Birnie <bir...@google.com>
        Gerrit-CC: Yuheng Huang <yuh...@chromium.org>
        Gerrit-Attention: Ian Wells <iwe...@chromium.org>
        Gerrit-Comment-Date: Wed, 22 Jul 2026 20:40:23 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Ian Wells (Gerrit)

        unread,
        4:57 PM (4 hours ago) 4:57 PM
        to Nick Birnie, Yuheng Huang, Chromium LUCI CQ, chromium...@chromium.org, dewitt...@chromium.org

        Ian Wells voted and added 2 comments

        Votes added by Ian Wells

        Commit-Queue+2

        2 comments

        Patchset-level comments
        File-level comment, Patchset 4 (Latest):
        Ian Wells . resolved

        Thanks!

        File chrome/browser/glic/service/glic_instance_impl.h
        Line 52, Patchset 3://
        Nick Birnie . resolved

        nit: leftover?

        Ian Wells

        Done

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
          Gerrit-Change-Number: 8129816
          Gerrit-PatchSet: 4
          Gerrit-Owner: Ian Wells <iwe...@chromium.org>
          Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
          Gerrit-Reviewer: Nick Birnie <bir...@google.com>
          Gerrit-CC: Yuheng Huang <yuh...@chromium.org>
          Gerrit-Comment-Date: Wed, 22 Jul 2026 20:57:22 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Nick Birnie <bir...@google.com>
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          7:17 PM (2 hours ago) 7:17 PM
          to Ian Wells, Nick Birnie, Yuheng Huang, chromium...@chromium.org, dewitt...@chromium.org

          Chromium LUCI CQ submitted the change with unreviewed changes

          Unreviewed changes

          3 is the latest approved patch-set.
          The change was submitted with unreviewed changes in the following files:

          ```
          The name of the file: chrome/browser/glic/service/glic_instance_impl.h
          Insertions: 1, Deletions: 1.

          @@ -49,7 +49,7 @@
          namespace tabs {
          class TabInterface;
          }
          -//
          +
          namespace glic {
          class ContextualCueingService;
          class EmptyEmbedderDelegate;
          ```

          Change information

          Commit message:
          glic: Set the initial invocation source on background invocation

          This is meant to support UniversalCart which can invoke on background
          tabs. This case causes GlicInstanceImpl::Show to exit early (inactive
          embedder) without setting initial_invocation_source_. We don't want to
          lose the initial invocation source in this case.

          Also expose initial_invocation_source_ so that it can be used in
          crrev.com/c/7963450.
          Bug: 527147917
          Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
          Commit-Queue: Ian Wells <iwe...@chromium.org>
          Reviewed-by: Nick Birnie <bir...@google.com>
          Cr-Commit-Position: refs/heads/main@{#1666693}
          Files:
          • M chrome/browser/glic/public/glic_instance.h
          • M chrome/browser/glic/service/glic_instance_impl.cc
          • M chrome/browser/glic/service/glic_instance_impl.h
          • M chrome/browser/glic/service/metrics/glic_instance_metrics.cc
          • M chrome/browser/glic/service/metrics/glic_instance_metrics.h
          • M chrome/browser/glic/service/metrics/glic_instance_metrics_unittest.cc
          • M chrome/browser/glic/test_support/mock_glic_instance.h
          Change size: M
          Delta: 7 files changed, 74 insertions(+), 7 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Nick Birnie
          Open in Gerrit
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: merged
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I7352dc1947c2a8c046fb6e7f22e11126f3343051
          Gerrit-Change-Number: 8129816
          Gerrit-PatchSet: 5
          Gerrit-Owner: Ian Wells <iwe...@chromium.org>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Ian Wells <iwe...@chromium.org>
          Gerrit-Reviewer: Nick Birnie <bir...@google.com>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages