-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand team and template workflows #5198
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
Open
klopez4212
wants to merge
5
commits into
main
Choose a base branch
from
kennylopez-create-team-channel-style
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,259
−1,238
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e356a3
feat(desktop): expand team and template workflows
klopez4212 6036287
Simplify template creation and section defaults
klopez4212 197ed0a
fix(desktop): address template and team review findings
klopez4212 0169c70
Merge origin/main into kennylopez-create-team-channel-style
klopez4212 5af1ca7
fix(desktop): preserve template agent deployment context
klopez4212 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| use crate::managed_agents::MAX_TEAM_NAME_CHARS; | ||
| use nostr::Tag; | ||
|
|
||
| const MAX_TEAM_MENTION_ID_CHARS: usize = 200; | ||
|
|
||
| pub(super) fn parse_mention_reference_tag(mention: &[String]) -> Result<Tag, String> { | ||
| match mention.first().map(String::as_str) { | ||
| Some("mention") => parse_person_mention(mention), | ||
| Some("team_mention") => parse_team_mention(mention), | ||
| prefix => Err(format!( | ||
| "mention reference tags must use 'mention' or 'team_mention' prefix (got {prefix:?})" | ||
| )), | ||
| } | ||
| } | ||
|
|
||
| fn parse_person_mention(mention: &[String]) -> Result<Tag, String> { | ||
| if mention.len() != 2 { | ||
| return Err("mention reference tag must contain exactly one pubkey".into()); | ||
| } | ||
| let pubkey = &mention[1]; | ||
| if pubkey.len() != 64 | ||
| || !pubkey | ||
| .chars() | ||
| .all(|character| character.is_ascii_hexdigit()) | ||
| { | ||
| return Err(format!( | ||
| "pubkey must be a 64-character hex string (got {} chars)", | ||
| pubkey.len() | ||
| )); | ||
| } | ||
| Tag::parse(["mention", &pubkey.to_ascii_lowercase()]) | ||
| .map_err(|error| format!("invalid tag: {error}")) | ||
| } | ||
|
|
||
| fn parse_team_mention(mention: &[String]) -> Result<Tag, String> { | ||
| if mention.len() != 3 { | ||
| return Err("team mention tag must contain exactly a team id and display name".into()); | ||
| } | ||
| let team_id = mention[1].trim(); | ||
| let display_name = mention[2].trim(); | ||
| if team_id.is_empty() || display_name.is_empty() { | ||
| return Err("team mention id and display name must not be blank".into()); | ||
| } | ||
| if team_id.chars().count() > MAX_TEAM_MENTION_ID_CHARS | ||
| || display_name.chars().count() > MAX_TEAM_NAME_CHARS | ||
| { | ||
| return Err("team mention id and display name must be at most 200 characters".into()); | ||
| } | ||
| if team_id.chars().any(char::is_control) || display_name.chars().any(char::is_control) { | ||
| return Err("team mention id and display name must not contain controls".into()); | ||
| } | ||
| Tag::parse(["team_mention", team_id, display_name]) | ||
| .map_err(|error| format!("invalid tag: {error}")) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::parse_mention_reference_tag; | ||
|
|
||
| #[test] | ||
| fn preserves_visible_team_chip_metadata() { | ||
| let tag = parse_mention_reference_tag(&[ | ||
| "team_mention".into(), | ||
| "team-launch".into(), | ||
| "Launch Team".into(), | ||
| ]) | ||
| .unwrap(); | ||
| assert_eq!( | ||
| tag.as_slice(), | ||
| &["team_mention", "team-launch", "Launch Team"] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_extra_team_tag_fields() { | ||
| assert!(parse_mention_reference_tag(&[ | ||
| "team_mention".into(), | ||
| "team-launch".into(), | ||
| "Launch Team".into(), | ||
| "forged".into(), | ||
| ]) | ||
| .is_err()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.