Skip to content

fix: tui put save timer#95

Merged
ponbac merged 1 commit intomasterfrom
put-timer-fix
Feb 28, 2026
Merged

fix: tui put save timer#95
ponbac merged 1 commit intomasterfrom
put-timer-fix

Conversation

@ponbac
Copy link
Owner

@ponbac ponbac commented Feb 28, 2026

Greptile Summary

This PR enhances the timer save functionality to include project and activity metadata in the save request. The backend now accepts optional project/activity fields and syncs them via edit_timer before saving, making the save operation more robust if a prior timer-edit sync call was missed.

Key Changes:

  • Backend SaveTimerPayload now accepts project_id, project_name, activity_id, and activity_name fields
  • When these fields are present, the backend merges them with the current timer state and calls edit_timer before save_timer
  • TUI constructs SaveTimerRequest with current project/activity from app state
  • TUI API client updated to accept full request object instead of just note string

The implementation correctly handles all edge cases with the current TUI client, which always sends paired id/name fields together.

Confidence Score: 4/5

  • Safe to merge with minimal risk - changes are additive and backward compatible
  • The changes are well-structured and maintain backward compatibility. The backend correctly handles optional fields, and the TUI types guarantee paired id/name values. The merge logic works correctly for all current usage patterns. Score reflects solid implementation with one area needing attention: the backend merge logic could clear project/activity if a future client sends mismatched id/name pairs, but this won't occur with current TUI code.
  • Pay attention to toki-api/src/routes/time_tracking/timer.rs if adding new clients - the merge logic assumes paired id/name fields

Important Files Changed

Filename Overview
toki-api/src/routes/time_tracking/timer.rs Added optional project/activity fields to SaveTimerPayload and logic to sync timer state before saving, preventing data loss from missed sync calls
toki-tui/src/runtime/actions.rs Modified timer save action to include current project/activity details in the save request

Last reviewed commit: 429d600

@vercel
Copy link

vercel bot commented Feb 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
toki2 Ready Ready Preview, Comment Feb 28, 2026 2:40pm

Request Review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 429d600e57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ponbac
Copy link
Owner Author

ponbac commented Feb 28, 2026

@codex

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6b36942e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +191
let updated_timer = ActiveTimer::new(current_timer.started_at)
.with_project(project_id, project_name)
.with_activity(activity_id, activity_name)
.with_note(current_timer.note);
service.edit_timer(&user.id, &updated_timer).await?;

Choose a reason for hiding this comment

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

P2 Badge Preserve server timer state when saving from stale clients

This update unconditionally rewrites the active timer with project/activity values from the save payload before persisting the entry, so a stale client can overwrite newer server-side changes and save to the wrong project/activity. In toki-tui, active timer state is only restored during startup (initialize_app_state in toki-tui/src/bootstrap.rs) and is not periodically refreshed, so editing the same timer from another client (web UI/second TUI session) is enough to trigger this. Before this commit, save_timer used the server’s current timer state directly and did not have this overwrite path.

Useful? React with 👍 / 👎.

@ponbac ponbac merged commit 9c25768 into master Feb 28, 2026
8 checks passed
@ponbac ponbac deleted the put-timer-fix branch February 28, 2026 15:05
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