Skip to content

[codex-analytics] feature plumbing and emittance#16640

Draft
rhan-oai wants to merge 1 commit intomainfrom
pr16639
Draft

[codex-analytics] feature plumbing and emittance#16640
rhan-oai wants to merge 1 commit intomainfrom
pr16639

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

@rhan-oai rhan-oai commented Apr 3, 2026

impl InitialHistory {
pub fn scan_rollout_items(&self, mut predicate: impl FnMut(&RolloutItem) -> bool) -> bool {
match self {
InitialHistory::New => false,
Copy link
Copy Markdown
Collaborator Author

@rhan-oai rhan-oai Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

determining is_first_turn for resumed or forked threads is tricky without explicit metadata, predicate looks for first user turn so performance cost should be negligible on average

@rhan-oai rhan-oai requested a review from owenlin0 April 3, 2026 22:31
@rhan-oai rhan-oai force-pushed the pr16639 branch 15 times, most recently from 82caee0 to d3d94c3 Compare April 5, 2026 03:59
@rhan-oai rhan-oai changed the base branch from main to pr16638 April 5, 2026 23:32
@rhan-oai rhan-oai changed the base branch from pr16638 to main April 6, 2026 01:23
@rhan-oai rhan-oai changed the base branch from main to pr16638 April 6, 2026 17:00
@rhan-oai rhan-oai force-pushed the pr16639 branch 10 times, most recently from 9c63a0c to f9dea6f Compare April 6, 2026 22:51
rhan-oai added a commit that referenced this pull request Apr 6, 2026
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/16638).
* #16870
* #16706
* #16659
* #16641
* #16640
* __->__ #16638
@rhan-oai rhan-oai force-pushed the pr16639 branch 2 times, most recently from f85b185 to 3328a11 Compare April 7, 2026 00:22
Oreoxp pushed a commit to Oreoxp/OpenCrab2 that referenced this pull request Apr 7, 2026
)
}

pub fn new_with_analytics_events_client(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codex tends to do this a lot.... instead of defining a new function with a new parameter, can we just update new + the callsites? otherwise we will have function sprawl every time a new param is added

last_agent_message
}

async fn track_turn_resolved_config_analytics(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this function no-op if features.general_analytics is not enabled?

fn collaboration_mode_mode(mode: ModeKind) -> &'static str {
match mode {
ModeKind::Plan => "plan",
ModeKind::Default | ModeKind::PairProgramming | ModeKind::Execute => "default",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm why do we coerce PairProgramming and Execute to "default"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both serialize to default as per protocol/src/config_types.rs

pub enum ModeKind {
    Plan,
    #[default]
    #[serde(
        alias = "code",
        alias = "pair_programming",
        alias = "execute",
        alias = "custom"
    )]
    Default,
    #[doc(hidden)]
    #[serde(skip_serializing, skip_deserializing)]
    #[schemars(skip)]
    #[ts(skip)]
    PairProgramming,
    #[doc(hidden)]
    #[serde(skip_serializing, skip_deserializing)]
    #[schemars(skip)]
    #[ts(skip)]
    Execute,
}

pub const TUI_VISIBLE_COLLABORATION_MODES: [ModeKind; 2] = [ModeKind::Default, ModeKind::Plan];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting. ok ignore me

conversation_history.scan_rollout_items(rollout_item_is_user_turn_boundary)
}

fn rollout_item_is_user_turn_boundary(item: &RolloutItem) -> bool {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we move these two functions to codex-rs/core/src/thread_rollout_truncation.rs?

can probably have something like:

// codex-rs/core/src/thread_rollout_truncation.rs
pub(crate) fn initial_history_has_user_turns(history: &InitialHistory) -> bool {
    match history {
        InitialHistory::New => false,
        InitialHistory::Resumed(resumed) => rollout_has_user_turns(&resumed.history),
        InitialHistory::Forked(items) => rollout_has_user_turns(items),
    }
}

pub(crate) fn rollout_has_user_turns(items: &[RolloutItem]) -> bool {
    !user_turn_positions_in_rollout(items).is_empty()
}

Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional follow-up re: tests - we could probably move the failed/interrupted turn analytics permutations into the reducer tests and keep just one app-server integration test for the end-to-end turn event. would keep the app-server integration tests a bit more focused.

@rhan-oai rhan-oai force-pushed the pr16639 branch 9 times, most recently from 720b401 to 19caf41 Compare April 7, 2026 23:39
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.

2 participants