Skip to content

Commit 4bc6d49

Browse files
authored
Merge branch 'gitbutlerapp:master' into revert
2 parents f0ee11c + cb26e4e commit 4bc6d49

File tree

8 files changed

+46
-18
lines changed

8 files changed

+46
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src/lib/bootstrap/deps.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import {
8181
USER_SERVICE as CLOUD_USER_SERVICE
8282
} from '@gitbutler/shared/users/userService';
8383
import { DragStateService, DRAG_STATE_SERVICE } from '@gitbutler/ui/drag/dragStateService.svelte';
84+
import { FModeManager } from '@gitbutler/ui/focus/fModeManager';
8485
import { FOCUS_MANAGER, FocusManager } from '@gitbutler/ui/focus/focusManager';
8586
import {
8687
EXTERNAL_LINK_SERVICE,
@@ -212,9 +213,17 @@ export function initDependencies(args: {
212213
// HISTORY & OPERATIONS
213214
// ============================================================================
214215

216+
const fModeManager = new FModeManager();
217+
const focusManager = new FocusManager(fModeManager);
215218
const historyService = new HistoryService(backend, clientState['backendApi']);
216219
const oplogService = new OplogService(clientState['backendApi']);
217-
const commitAnalytics = new CommitAnalytics(stackService, uiState, worktreeService, rulesService);
220+
const commitAnalytics = new CommitAnalytics(
221+
stackService,
222+
uiState,
223+
worktreeService,
224+
rulesService,
225+
fModeManager
226+
);
218227
const codegenAnalytics = new CodegenAnalytics(claudeCodeService, settingsService);
219228

220229
// ============================================================================
@@ -266,7 +275,6 @@ export function initDependencies(args: {
266275
// UI & INTERACTION
267276
// ============================================================================
268277

269-
const focusManager = new FocusManager();
270278
const imeHandler = new IMECompositionHandler();
271279
const reorderDropzoneFactory = new ReorderDropzoneFactory(stackService);
272280
const shortcutService = new ShortcutService(backend);

apps/desktop/src/lib/soup/commitAnalytics.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { HunkAssignment } from '$lib/hunks/hunk';
1010
import type RulesService from '$lib/rules/rulesService.svelte';
1111
import type { Stack, BranchDetails } from '$lib/stacks/stack';
1212
import type { EventProperties } from '$lib/state/customHooks.svelte';
13+
import type { FModeManager } from '@gitbutler/ui/focus/fModeManager';
1314

1415
export const COMMIT_ANALYTICS = new InjectionToken<CommitAnalytics>('CommitAnalytics');
1516

@@ -18,7 +19,8 @@ export class CommitAnalytics {
1819
private stackService: StackService,
1920
private uiState: UiState,
2021
private worktreeService: WorktreeService,
21-
private readonly rulesService: RulesService
22+
private rulesService: RulesService,
23+
private fModeManager: FModeManager
2224
) {}
2325

2426
async getCommitProperties(args: {
@@ -86,6 +88,8 @@ export class CommitAnalytics {
8688
totalAssignedFiles: this.getAssignedFiles(assignments).length,
8789
// Total number of files that have not been assigned
8890
totalUnassignedFiles: this.getUnassignedFiles(assignments).length,
91+
// Number of times F key shortcuts have been "clicked"
92+
fKeyActivations: this.fModeManager.activations,
8993
// Rule metrics
9094
...this.getRuleMetrics(rules),
9195
// Behavior metrics

crates/but-testing/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ async fn main() -> Result<()> {
2121
trace::init()?;
2222
}
2323
let _op_span = tracing::info_span!("cli-op").entered();
24+
static CHANNEL: Option<&str> = option_env!("CHANNEL");
25+
if let Some(suffix) = &args.app_suffix
26+
&& CHANNEL != Some(suffix)
27+
{
28+
bail!(
29+
"Launch with CHANNEL={suffix} cargo run -- but-testing… instead - must be compiled in!"
30+
)
31+
}
2432

2533
match &args.cmd {
2634
args::Subcommands::AddProject {

crates/gitbutler-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ but-api.workspace = true
7070
but-claude.workspace = true
7171
open = "5"
7272
url = "2.5.4"
73-
dirs.workspace = true
73+
but-path.workspace = true
7474
uuid.workspace = true
7575

7676
[target.'cfg(target_os = "macos")'.dependencies]

crates/gitbutler-tauri/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn main() {
3737
let mut tauri_context = generate_context!();
3838
gitbutler_secret::secret::set_application_namespace(&tauri_context.config().identifier);
3939

40-
let config_dir = dirs::config_dir()
40+
let config_dir = but_path::app_config_dir()
4141
.expect("missing config dir")
4242
.join("gitbutler");
4343
std::fs::create_dir_all(&config_dir).expect("failed to create config dir");

packages/ui/src/lib/focus/fModeManager.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import {
44
createShortcutOverlay,
55
removeShortcutOverlay
66
} from '$lib/focus/shortcutUtils';
7+
import { InjectionToken } from '@gitbutler/core/context';
78
import type { FocusableNode } from '$lib/focus/focusTypes';
89

10+
export const FMODE_MANAGER: InjectionToken<FModeManager> = new InjectionToken('FModeManager');
11+
912
/**
1013
* F-mode allows users to quickly navigate to buttons and containers using
1114
* two-letter keyboard shortcuts (e.g., 'AA', 'AB', etc.).
@@ -19,9 +22,8 @@ export class FModeManager {
1922
private activeOverlays = new Map<HTMLElement, HTMLElement>();
2023
private elementToShortcut = new Map<HTMLElement, string>();
2124

22-
get active(): boolean {
23-
return this._active;
24-
}
25+
// Count of how many shortcuts have been activated.
26+
private _activations = 0;
2527

2628
setFeatureEnabled(enabled: boolean): void {
2729
this.featureEnabled = enabled;
@@ -183,6 +185,7 @@ export class FModeManager {
183185
} else {
184186
element.click();
185187
}
188+
this._activations++;
186189
this.deactivate(); // Auto-exit after activation
187190
}
188191

@@ -240,4 +243,12 @@ export class FModeManager {
240243
}
241244
});
242245
}
246+
247+
get active(): boolean {
248+
return this._active;
249+
}
250+
251+
get activations(): number {
252+
return this._activations;
253+
}
243254
}

packages/ui/src/lib/focus/focusManager.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class FocusManager {
3232

3333
private previousElements: HTMLElement[] = [];
3434
private indexCache = new Map<HTMLElement, number>();
35-
private fModeManager: FModeManager;
3635

3736
readonly cursor = writable<HTMLElement | undefined>();
3837
readonly outline = writable(false); // external use
@@ -41,9 +40,7 @@ export class FocusManager {
4140
private handleMouse = this.handleClick.bind(this);
4241
private handleKeys = this.handleKeydown.bind(this);
4342

44-
constructor() {
45-
this.fModeManager = new FModeManager();
46-
}
43+
constructor(private fModeManager: FModeManager) {}
4744

4845
setFModeEnabled(enabled: boolean): void {
4946
this.fModeManager.setFeatureEnabled(enabled);
@@ -92,18 +89,18 @@ export class FocusManager {
9289
return;
9390
}
9491

95-
// TODO: Allow clicks inside inputs to set `this.currentNode`
96-
if (isInputElement(e.target)) {
97-
return;
98-
}
99-
10092
if (e.target instanceof HTMLElement) {
10193
const focusableNode = this.findNearestFocusableElement(e.target);
10294
if (focusableNode) {
10395
this.setActiveNode(focusableNode);
10496
this.setOutline(false);
10597
}
10698
}
99+
100+
// TODO: Find a way to update the focusable without causing target to blur.
101+
if (isInputElement(e.target)) {
102+
e.target.focus();
103+
}
107104
}
108105

109106
// Handles hotkeys for instant button activation (supports complex combinations like ⇧⌘P)

0 commit comments

Comments
 (0)