Skip to content

Raw comments #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/rust-project-goals-cli-llm/src/templates.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::{Path, PathBuf};

use handlebars::{DirectorySourceOptions, Handlebars};
use rust_project_goals::gh::issues::ExistingGithubComment;
use serde::Serialize;

use rust_project_goals_json::Progress;
Expand Down Expand Up @@ -73,7 +74,10 @@ pub struct UpdatesGoal {
pub is_closed: bool,

/// Markdown with update text (bullet list)
pub updates_markdown: String,
pub comments: Vec<ExistingGithubComment>,

/// Comments.len but accessible to the template
pub num_comments: usize,

/// Progress towards the goal
pub progress: Progress,
Expand Down
87 changes: 11 additions & 76 deletions crates/rust-project-goals-cli-llm/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ pub async fn updates(

let mut updates = templates::Updates {
milestone: milestone.to_string(),
flagship_goals: vec![],
other_goals: vec![],
flagship_goals: prepare_goals(repository, &issues, &filter, true).await?,
other_goals: prepare_goals(repository, &issues, &filter, false).await?,
};

prepare_flagship_goals(repository, &issues, &filter, &mut updates).await?;
prepare_other_goals(repository, &issues, &filter, &mut updates).await?;

progress_bar::finalize_progress_bar();

// Render the output using handlebars and write it to the file.
Expand Down Expand Up @@ -82,15 +79,16 @@ pub async fn updates(
Ok(())
}

async fn prepare_flagship_goals(
async fn prepare_goals(
repository: &Repository,
issues: &[ExistingGithubIssue],
filter: &Filter<'_>,
updates: &mut Updates,
) -> anyhow::Result<()> {
flagship: bool,
) -> anyhow::Result<Vec<UpdatesGoal>> {
let mut result = vec![];
// First process the flagship goals, for which we capture the full text of comments.
for issue in issues {
if !issue.has_flagship_label() {
if flagship != issue.has_flagship_label() {
continue;
}

Expand All @@ -109,13 +107,7 @@ async fn prepare_flagship_goals(
comments.sort_by_key(|c| c.created_at.clone());
comments.retain(|c| !c.is_automated_comment() && filter.matches(c));

let mut summary = String::new();
for c in comments {
summary.push_str(&c.body);
summary.push_str("\n\n");
}

updates.flagship_goals.push(UpdatesGoal {
result.push(UpdatesGoal {
title: title.clone(),
issue_number: issue.number,
issue_assignees: comma(&issue.assignees),
Expand All @@ -126,70 +118,13 @@ async fn prepare_flagship_goals(
.url(),
progress,
is_closed: issue.state == GithubIssueState::Closed,
updates_markdown: summary,
num_comments: comments.len(),
comments,
});

progress_bar::inc_progress_bar();
}
Ok(())
}

async fn prepare_other_goals(
repository: &Repository,
issues: &[ExistingGithubIssue],
filter: &Filter<'_>,
updates: &mut Updates,
) -> anyhow::Result<()> {
// Next process the remaining goals, for which we generate a summary using an LLVM.
for issue in issues {
if issue.has_flagship_label() {
continue;
}

let title = &issue.title;

progress_bar::print_progress_bar_info(
&format!("Issue #{number}", number = issue.number),
title,
progress_bar::Color::Green,
progress_bar::Style::Bold,
);

// Find the relevant updates that have occurred.
let mut comments = issue.comments.clone();
comments.sort_by_key(|c| c.created_at.clone());
comments.retain(|c| !c.is_automated_comment() && filter.matches(c));

// Use an LLM to summarize the updates.
let summary = if comments.len() == 0 {
format!("No updates in this period.")
} else {
format!(
"[{N} updates available.]({LINK})",
N = comments.len(),
LINK = comments.first().unwrap().url,
)
};

let goal = UpdatesGoal {
title: title.clone(),
issue_number: issue.number,
issue_assignees: comma(&issue.assignees),
issue_url: IssueId {
repository: repository.clone(),
number: issue.number,
}
.url(),
is_closed: issue.state == GithubIssueState::Closed,
updates_markdown: summary,
progress: checkboxes(&issue),
};

updates.other_goals.push(goal);

progress_bar::inc_progress_bar();
}
Ok(())
Ok(result)
}

struct Filter<'f> {
Expand Down
17 changes: 17 additions & 0 deletions templates/goal_comments.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{#if comments}}

<details>
<summary>{{num_comments}} updates posted.</summary>

{{#each comments}}
{{body}}
{{/each}}
</details>

{{else}}

<!-- -->
No updates in this tracking period.

{{/if}}

16 changes: 2 additions & 14 deletions templates/updates.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,12 @@ repository](https://github.com/rust-lang/rust-project-goals/milestone/2).

{{#each flagship_goals}}
{{>introduce_goal}}

{{!-- some spacing is required to ensure that markdown is recognized as markdown and not html --}}

{{{updates_markdown}}}

{{!-- some spacing is required to ensure that markdown is recognized as markdown and not html --}}

{{>goal_comments}}
{{/each}}

## Other goals

{{#each other_goals}}
{{>introduce_goal}}

{{!-- some spacing is required to ensure that markdown is recognized as markdown and not html --}}

{{{updates_markdown}}}

{{!-- some spacing is required to ensure that markdown is recognized as markdown and not html --}}

{{>goal_comments}}
{{/each}}