Skip to content

Implement a reload signal that can be consumed in the frontend and reload the workspace #8880

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

Closed
wants to merge 1 commit into from

Conversation

krlvi
Copy link
Member

@krlvi krlvi commented Jun 2, 2025

In the frontend we can do something like

	import { listen } from '$lib/backend/ipc';
	import { ClientState } from '$lib/state/clientState.svelte';
	import { getContext } from '@gitbutler/shared/context';
	const clientState = getContext(ClientState);
	$effect(() => {
		const unsubscribe = listen(`project://${projectId}/reload`, (event) => {
			clientState.backendApi.util.resetApiState();
		});
		return () => unsubscribe();
	});

However, it seems like clientState.backendApi.util.resetApiState(); does not seem to work, so skipping this for now

Copy link

vercel bot commented Jun 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 7:45pm
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 7:45pm

@Byron
Copy link
Collaborator

Byron commented Jun 3, 2025

I didn't look into if this is working, but assume it would given the filesystem monitor is relatively mature at this point. My fear here would be that removing the file triggers another event so there is some self-triggering going on.

If the purpose is to refresh the UI if something changed, then I'd think ideally we can update the current filesystem monitor implementation to respond to Git changes as well, a feature needed for Single-Branch mode.

This could be a tool to help debug fielsystem events, it also shows the events the filesystem watcher actually gets, along with the filtered-down events that the application gets to see.

RUST_LOG=trace cargo run -p but-cli -- --trace watch

If there is truly a new mechanism needed to let both communicate I think they could do with sockets or pipes, there is a crate for that (even though I never used it), while Cargo uses the jobserver crate to let multiple instances talk to each other (including make) to prevent over-allocation of threads.

@mtsgrd
Copy link
Contributor

mtsgrd commented Jun 4, 2025

Was this still relevant? I mentioned this over chat but it might have gotten lost, resetApiState is an action and needs to be dispatched using the dispatcher from ClientState. I need to fix the same reset for github/gitlab api's when switching projects!

@krlvi
Copy link
Member Author

krlvi commented Jun 4, 2025

Was this still relevant? I mentioned this over chat but it might have gotten lost, resetApiState is an action and needs to be dispatched using the dispatcher from ClientState. I need to fix the same reset for github/gitlab api's when switching projects!

I think that we maaaay do a different implementation here using sqlite hooks

@krlvi krlvi closed this Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants