Skip to content

refactor: launcher actions#4222

Open
andre-code wants to merge 3 commits into
andrea/add-job-launcherfrom
andrea/refactor-launcher-buttons
Open

refactor: launcher actions#4222
andre-code wants to merge 3 commits into
andrea/add-job-launcherfrom
andrea/refactor-launcher-buttons

Conversation

@andre-code

@andre-code andre-code commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Refactors launcher buttons into shared session and job components with one readiness hook so the card and side panel use the same actions and adds cypress tests for launcher actions.

AI disclosure: Used Cursor as a coding assistant for parts of this PR (autocomplete/refactor suggestions). All code was written/reviewed and is fully understood by me; not all of it is AI-generated — Cursor was used selectively as a dev tool.

/deploy renku=feat/add-jobs amalthea-sessions=fix/job-status-when-pod-missing renku-data-services=eikek/multiple-jobs-per-launcher extra-values=dataService.imageBuilders.enabled=true,dataService.imageBuilders.strategyName=renku-buildpacks-v3,dataService.imageBuilders.outputImagePrefix=harbor.dev.renku.ch/renku-build/,dataService.imageBuilders.nodeSelector.renku.io/node-purpose=user,dataService.imageBuilders.tolerations[0].effect=NoSchedule,dataService.imageBuilders.tolerations[0].key=renku.io/dedicated,dataService.imageBuilders.tolerations[0].operator=Equal,dataService.imageBuilders.tolerations[0].value=user

@RenkuBot

Copy link
Copy Markdown
Contributor

You can access the deployment of this PR at https://renku-ci-ui-4222.dev.renku.ch

@andre-code andre-code force-pushed the andrea/add-job-launcher branch from 6a8e225 to 0ea3ef9 Compare June 12, 2026 10:47
@andre-code andre-code force-pushed the andrea/refactor-launcher-buttons branch from 641ea09 to c3c9b80 Compare June 12, 2026 12:00
@andre-code andre-code marked this pull request as ready for review June 12, 2026 12:19
@andre-code andre-code requested a review from a team as a code owner June 12, 2026 12:19
test: add launcher action cypress coverage
refactor: add launcher environment readiness hook
refactor: split launcher actions by category and placement
@andre-code andre-code force-pushed the andrea/refactor-launcher-buttons branch from c3c9b80 to b2a0dd3 Compare June 13, 2026 21:44

@leafty leafty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

General note, AI usage: please disclose AI use. See https://github.com/ghostty-org/ghostty/blob/main/AI_POLICY.md as a general starting point for guidance.

Comment on lines +25 to +27
export type ProjectPermissions = Permissions & {
isLoadingPermissions: boolean;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is weird. Why is it called ProjectPermissions when it is generic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This type is really Permissions plus a loading flag from the hook, not the API's ProjectPermissions. I'll rename it to something like PermissionsWithLoadingState and keep it close to the hook so the generic permissions.types.ts stays API-aligned.

}
}, [fetchPermissions, isUninitialized, projectId]);

const isLoadingPermissions = isLoading || isUninitialized;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Logic error:

Suggested change
const isLoadingPermissions = isLoading || isUninitialized;
const isLoadingPermissions = isLoading || (projectId && isUninitialized);

You can see above that we trigger fetching data when projectId && isUninitialized => this is when the projectId is set and the API fetch has not been triggered yet.

If you do not check for projectId (not null, not empty), then isUninitialized will be true forever.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Misnomer, the parent component is an Offcanvas. Use JobOffcanvasSubmit.tsx.

Comment on lines +60 to +68
const displayBuildActions =
isCodeEnvironment &&
write &&
(resolvedUseOldImage || lastBuild?.status !== "succeeded");

const submitTooltip =
resolvedUseOldImage && containerImage?.accessible !== false
? `Launch ${categoryDefinition.text.inline} using an older image`
: undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move this below L76 since they are not used before.

return <JobPanelSubmit launcher={launcher} useOldImage={useOldImage} />;
}

const defaultAction = (() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should probably useMemo() here.

Submit
</Button>
</>
<Button color="outline-primary" className={cx("disabled")} size="sm">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<Button color="outline-primary" className={cx("disabled")} size="sm">
<Button color="outline-primary" className="disabled" size="sm">

But also: why not set the disabled prop then?

</Button>
</>
<Button color="outline-primary" className={cx("disabled")} size="sm">
<Loader size={12} inline /> Checking launcher

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<Loader size={12} inline /> Checking launcher
<Loader className="me-1" size={12} inline />Checking launcher

}, [launcherHash, setHash]);

return (
<span id={`open-panel-btn-${launcherId}`}>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bad practice: unnecessary span.

Suggested change
<span id={`open-panel-btn-${launcherId}`}>

For tooltips, use ref, innerRef, or set the ID on the component itself (avoid if possible)

containerImage?.accessible === true ||
useOldImage;

const showSubmitJob = !(isBuildInProgress && !hasValidImage && !useOldImage);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not readable:

Suggested change
const showSubmitJob = !(isBuildInProgress && !hasValidImage && !useOldImage);
const showSubmitJob = !isBuildInProgress || hasValidImage || useOldImage;

enabled?: boolean;
lastBuild?: Build;
lastSuccessfulBuild?: Build;
useOldImage?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: Are there cases when we use useOldImage={false}?

@andre-code andre-code Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it is no longer needed, so I've removed it.

@andre-code andre-code force-pushed the andrea/refactor-launcher-buttons branch 3 times, most recently from 3edeb28 to 895fe21 Compare June 22, 2026 10:30
…in SessionLauncherCard, remove unnecessary span
@andre-code andre-code force-pushed the andrea/refactor-launcher-buttons branch from 895fe21 to 6f02989 Compare June 22, 2026 12:25
@andre-code

Copy link
Copy Markdown
Contributor Author

Hi @leafty , thanks for reviewing the PR. I’ve added the AI disclosure and simplified the logic by reusing more of the hook, with a single launcher action per type (job or session).
It’s ready for your review again.

@andre-code andre-code requested a review from leafty June 22, 2026 12:44

@leafty leafty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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.

3 participants