GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — code/code-rs/state/src/model/thread_goal.rs at main · cbusillo/code

This repository was archived by the owner on Sep 20, 2026. It is now read-only.

Expand file tree

/

thread_goal.rs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
109 lines (97 loc) · 3.02 KB
/

thread_goal.rs

Copy path

File metadata and controls

109 lines (97 loc) · 3.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use anyhow::Result;
use anyhow::anyhow;
use chrono::DateTime;
use chrono::Utc;
use codex_protocol::ThreadId;
use sqlx::Row;
use sqlx::sqlite::SqliteRow;
use super::epoch_millis_to_datetime;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ThreadGoalStatus {
Active,
Paused,
BudgetLimited,
Complete,
}
impl ThreadGoalStatus {
pub fn as_str(self) -> &'static str {
match self {
Self::Active => "active",
Self::Paused => "paused",
Self::BudgetLimited => "budget_limited",
Self::Complete => "complete",
}
}
pub fn is_active(self) -> bool {
self == Self::Active
}
pub fn is_terminal(self) -> bool {
matches!(self, Self::BudgetLimited | Self::Complete)
}
}
impl TryFrom<&str> for ThreadGoalStatus {
type Error = anyhow::Error;
fn try_from(value: &str) -> Result<Self> {
match value {
"active" => Ok(Self::Active),
"paused" => Ok(Self::Paused),
"budget_limited" => Ok(Self::BudgetLimited),
"complete" => Ok(Self::Complete),
other => Err(anyhow!("unknown thread goal status `{other}`")),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ThreadGoal {
pub thread_id: ThreadId,
pub goal_id: String,
pub objective: String,
pub status: ThreadGoalStatus,
pub token_budget: Option<i64>,
pub tokens_used: i64,
pub time_used_seconds: i64,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
pub(crate) struct ThreadGoalRow {
pub thread_id: String,
pub goal_id: String,
pub objective: String,
pub status: String,
pub token_budget: Option<i64>,
pub tokens_used: i64,
pub time_used_seconds: i64,
pub created_at_ms: i64,
pub updated_at_ms: i64,
}
impl ThreadGoalRow {
pub(crate) fn try_from_row(row: &SqliteRow) -> Result<Self> {
Ok(Self {
thread_id: row.try_get("thread_id")?,
goal_id: row.try_get("goal_id")?,
objective: row.try_get("objective")?,
status: row.try_get("status")?,
token_budget: row.try_get("token_budget")?,
tokens_used: row.try_get("tokens_used")?,
time_used_seconds: row.try_get("time_used_seconds")?,
created_at_ms: row.try_get("created_at_ms")?,
updated_at_ms: row.try_get("updated_at_ms")?,
})
}
}
impl TryFrom<ThreadGoalRow> for ThreadGoal {
type Error = anyhow::Error;
fn try_from(row: ThreadGoalRow) -> Result<Self> {
Ok(Self {
thread_id: ThreadId::try_from(row.thread_id)?,
goal_id: row.goal_id,
objective: row.objective,
status: ThreadGoalStatus::try_from(row.status.as_str())?,
token_budget: row.token_budget,
tokens_used: row.tokens_used,
time_used_seconds: row.time_used_seconds,
created_at: epoch_millis_to_datetime(row.created_at_ms)?,
updated_at: epoch_millis_to_datetime(row.updated_at_ms)?,
})
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.