Skip to content

Conversation

@adamhaeger
Copy link
Contributor

@adamhaeger adamhaeger commented Oct 14, 2025

Description

This PR implements backend initialization of app data as desribed in this ADR:

Altinn/app-frontend-react#3734

See the ADR for architetcture changes and rationale.

It is part of the larger refactoring work by the Frontend Next Taskforce.

Related issues:

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

@github-actions github-actions bot added the skip-releasenotes Issues that do not make sense to list in our release notes label Oct 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backend-data-loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.


// Mutation to set selected party
const { doSetSelectedParty } = useAppMutations();
const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable sentToMutation.

Copilot Autofix

AI about 1 month ago

To fix this problem, simply remove the unused state variable declaration: const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined); on line 72. This change removes both the getter and setter since they are not used anywhere in the provided code. No further action, refactoring, or import changes are required as this is a local unused variable, and other surrounding functionality is unaffected.


Suggested changeset 1
src/App/frontend/src/features/instantiate/containers/PartySelection.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
--- a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
+++ b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
@@ -69,7 +69,6 @@
 
   // Mutation to set selected party
   const { doSetSelectedParty } = useAppMutations();
-  const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);
   const {
     mutateAsync,
     data: dataFromMutation,
EOF
@@ -69,7 +69,6 @@

// Mutation to set selected party
const { doSetSelectedParty } = useAppMutations();
const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);
const {
mutateAsync,
data: dataFromMutation,
Copilot is powered by AI and may make mistakes. Always verify output.
const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);
const {
mutateAsync,
data: dataFromMutation,

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable dataFromMutation.

Copilot Autofix

AI about 1 month ago

To fix the problem, remove the unused variable dataFromMutation from the destructuring assignment of the object returned by the useMutation hook. Specifically, on line 75 in the PartySelection component, update the destructuring from:

const { mutateAsync, data: dataFromMutation, error: mutationError } = useMutation({...});

to:

const { mutateAsync, error: mutationError } = useMutation({...});

This change removes the unused element without affecting the functional behavior of the code, since dataFromMutation was never utilized.

Suggested changeset 1
src/App/frontend/src/features/instantiate/containers/PartySelection.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
--- a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
+++ b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
@@ -72,7 +72,6 @@
   const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);
   const {
     mutateAsync,
-    data: dataFromMutation,
     error: mutationError,
   } = useMutation({
     mutationKey: ['doSetSelectedParty'],
EOF
@@ -72,7 +72,6 @@
const [sentToMutation, setSentToMutation] = useReactState<IParty | undefined>(undefined);
const {
mutateAsync,
data: dataFromMutation,
error: mutationError,
} = useMutation({
mutationKey: ['doSetSelectedParty'],
Copilot is powered by AI and may make mistakes. Always verify output.

const selectedParty = useSelectedParty();
const setUserHasSelectedParty = useSetHasSelectedParty();
const [userHasSelectedParty, setUserHasSelectedParty] = useReactState(false);

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable userHasSelectedParty.

Copilot Autofix

AI about 1 month ago

The best way to fix this problem is to remove the unused state variable declaration. Specifically, in file src/App/frontend/src/features/instantiate/containers/PartySelection.tsx, delete the line (line 86) that initializes [userHasSelectedParty, setUserHasSelectedParty] using useReactState(false);. No other changes are needed because the variable is not used elsewhere in the provided code snippet. This ensures the code is cleaner and does not contain unnecessary state.


Suggested changeset 1
src/App/frontend/src/features/instantiate/containers/PartySelection.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
--- a/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
+++ b/src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
@@ -83,7 +83,6 @@
   });
 
   const selectedParty = useSelectedParty();
-  const [userHasSelectedParty, setUserHasSelectedParty] = useReactState(false);
 
   const appMetadata = useApplicationMetadata();
 
EOF
@@ -83,7 +83,6 @@
});

const selectedParty = useSelectedParty();
const [userHasSelectedParty, setUserHasSelectedParty] = useReactState(false);

const appMetadata = useApplicationMetadata();

Copilot is powered by AI and may make mistakes. Always verify output.

export function ProcessWrapper({ children }: PropsWithChildren) {
const { data: process } = useProcessQuery();
const currentTaskId = process?.currentTask?.elementId;

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable currentTaskId.

Copilot Autofix

AI 21 days ago

The correct fix is to delete the unused variable declaration for currentTaskId in the ProcessWrapper function in src/App/frontend/src/components/wrappers/ProcessWrapper.tsx, specifically on line 88. This will make the code more readable and eliminate an unnecessary variable with no impact on existing functionality. No imports or other code sections are affected by this change.

Suggested changeset 1
src/App/frontend/src/components/wrappers/ProcessWrapper.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/App/frontend/src/components/wrappers/ProcessWrapper.tsx b/src/App/frontend/src/components/wrappers/ProcessWrapper.tsx
--- a/src/App/frontend/src/components/wrappers/ProcessWrapper.tsx
+++ b/src/App/frontend/src/components/wrappers/ProcessWrapper.tsx
@@ -85,7 +85,6 @@
 
 export function ProcessWrapper({ children }: PropsWithChildren) {
   const { data: process } = useProcessQuery();
-  const currentTaskId = process?.currentTask?.elementId;
 
   const taskId = useNavigationParam('taskId');
 
EOF
@@ -85,7 +85,6 @@

export function ProcessWrapper({ children }: PropsWithChildren) {
const { data: process } = useProcessQuery();
const currentTaskId = process?.currentTask?.elementId;

const taskId = useNavigationParam('taskId');

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@github-actions github-actions bot added the kind/dependencies Used for issues or pull requests that are dependency updates label Oct 30, 2025
@github-actions github-actions bot added the skip-second-approval Pull requests that only need one approval from a reviewer. label Nov 4, 2025
@olemartinorg olemartinorg added the taskforce/next Issues that belongs to the named task-force label Nov 6, 2025
@olemartinorg olemartinorg moved this to 👷 In progress in Team Altinn Studio Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/dependencies Used for issues or pull requests that are dependency updates skip-releasenotes Issues that do not make sense to list in our release notes skip-second-approval Pull requests that only need one approval from a reviewer. taskforce/next Issues that belongs to the named task-force

Projects

Status: 👷 In progress

Development

Successfully merging this pull request may close these issues.

2 participants