Skip to content

Conversation

etherandrius
Copy link

@etherandrius etherandrius commented Aug 22, 2025

Description

#7337

@etherandrius etherandrius requested a review from a team as a code owner August 22, 2025 18:49
@etherandrius etherandrius requested review from RomneyDa and removed request for a team August 22, 2025 18:49
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 22, 2025
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


agrabauskas seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Comment on lines 52 to 74
const handleOpen = async () => {
if (rule.slug) {
void ideMessenger.request("controlPlane/openUrl", {
path: `${rule.slug}/new-version`,
orgSlug: undefined,
});
} else if (rule.ruleFile) {
ideMessenger.post("openFile", {
path: rule.ruleFile,
});
} else if (
rule.source === "default-chat" ||
rule.source === "default-plan" ||
rule.source === "default-agent"
) {
ideMessenger.post("openUrl", DEFAULT_SYSTEM_MESSAGES_URL);
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (rule as any).sourceFile },
});
}
};
Copy link
Author

Choose a reason for hiding this comment

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

This is not ideal, but it's consistent with RuleCard: React.FC<RuleCardProps> on click will just open the rules files in the editor.

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

@etherandrius could you add some explanation/context in the description?

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Aug 22, 2025
@etherandrius
Copy link
Author

@RomneyDa linked back to the issue

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

@etherandrius see nitpick
Also could we create a little util such as openRule that takes a RuleWithSource or AppliedRule so you could share all the rule opening logic between the components?
Overall agree with this, will be nice to reduce UI a bit here too

core/index.d.ts Outdated
conversationSummary?: string;
}

export interface AppliedRule {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can use Omit<RuleWithSource, "rule">

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 28, 2025
const RuleCard: React.FC<RuleCardProps> = ({ rule }) => {
const dispatch = useAppDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const mode = useAppSelector((store) => store.session.mode);
Copy link
Author

Choose a reason for hiding this comment

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

unused.

@@ -29,10 +29,33 @@ interface RuleCardProps {
rule: RuleWithSource;
}

export const openRules = async (rule: Omit<RuleWithSource, "rule">) => {
const ideMessenger = useContext(IdeMessengerContext);
Copy link
Author

@etherandrius etherandrius Aug 28, 2025

Choose a reason for hiding this comment

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

ideMessenger this was define outside the function before. I assume the useContext(IdeMessengerContext) call is basically free and we can call it inside the function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will need to pass ideMessenger for this one since can't use hooks outside of top level of component

@@ -282,7 +282,7 @@ export const streamNormalInput = createAsyncThunk<
...(appliedRules.length > 0 && {
rules: appliedRules.map((rule) => ({
id: getRuleId(rule),
rule: rule.rule,
rule: "", // TODO: remove rule key from type. The contents should be present in the prompt
Copy link
Author

Choose a reason for hiding this comment

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

a bit funky.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Any specific reason to remove rules from dev data? Have you had issues with verbose dev data?

Comment on lines +364 to +367
appliedRules: rules.map(fullRule => {
const { rule, ...rest } = fullRule // destruct rule key
return rest;
}),
Copy link
Author

Choose a reason for hiding this comment

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

A bit funky as well.

Ideally this method would not take availableRules: Omit<RuleWithSource, "rule">[] and read rules from the file.
This would also fix the issue of rules sometimes being outdated <- maybe a FLUP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This function could still just return RuleWithSource, shouldn't effect storage if omitted at the point of redux

note that config should reload if a rule file is updated, so should be up to date in most cases

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

  1. Main blocking feedback is to remove use of useContext in utility function
  2. create new type with Omit and pass the new type around to prevent duplicate Omits
  3. Leave rule content on dev data unless specific issues with dev data storage - let me know your thoughts on this?

@@ -29,10 +29,33 @@ interface RuleCardProps {
rule: RuleWithSource;
}

export const openRules = async (rule: Omit<RuleWithSource, "rule">) => {
const ideMessenger = useContext(IdeMessengerContext);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will need to pass ideMessenger for this one since can't use hooks outside of top level of component

@@ -497,7 +497,7 @@ export interface ChatHistoryItem {
toolCallStates?: ToolCallState[];
isGatheringContext?: boolean;
reasoning?: Reasoning;
appliedRules?: RuleWithSource[];
appliedRules?: Omit<RuleWithSource, "rule">[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can keep the AppliedRule type and just say type AppliedRule = Omit<RuleWithSource, "rule"> to prevent having Omits all over

Comment on lines +364 to +367
appliedRules: rules.map(fullRule => {
const { rule, ...rest } = fullRule // destruct rule key
return rest;
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function could still just return RuleWithSource, shouldn't effect storage if omitted at the point of redux

note that config should reload if a rule file is updated, so should be up to date in most cases

@@ -29,10 +29,33 @@ interface RuleCardProps {
rule: RuleWithSource;
}

export const openRules = async (rule: Omit<RuleWithSource, "rule">) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could take RuleWithSource | AppliedRule

@@ -282,7 +282,7 @@ export const streamNormalInput = createAsyncThunk<
...(appliedRules.length > 0 && {
rules: appliedRules.map((rule) => ({
id: getRuleId(rule),
rule: rule.rule,
rule: "", // TODO: remove rule key from type. The contents should be present in the prompt
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any specific reason to remove rules from dev data? Have you had issues with verbose dev data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants