Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e71bc6c
fix(cli): make completion category tabs clickable
destire-mio Aug 2, 2026
93e2a5b
test(cli): cover completion category boundaries
destire-mio Aug 3, 2026
c34dd67
test(cli): cover completion category mouse state
destire-mio Aug 6, 2026
bec2894
Merge origin/main into codex/fix-8330-completion-tab-mouse
destire-mio Aug 7, 2026
28fc002
fix(cli): address completion category mouse review feedback
destire-mio Aug 7, 2026
a287ac2
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
35f0dfd
fix(cli): harden completion category mouse handling
destire-mio Aug 12, 2026
342a45a
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
c62d15e
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
2f8c0a3
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
57f4202
test(cli): cover completion category review gaps
destire-mio Aug 12, 2026
4bfe311
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
499b09f
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
8b62f58
fix(review): keep repository context within file limit
destire-mio Aug 12, 2026
4677ee0
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 12, 2026
a87f5fd
test(review): pin repository context headroom
destire-mio Aug 12, 2026
c2f3155
test(review): make context bound probe robust
destire-mio Aug 12, 2026
f12770d
test(review): avoid changed-path exclusion false positive
destire-mio Aug 12, 2026
e19de89
test(review): harden manifest policy probes
destire-mio Aug 12, 2026
a81d1f2
test(review): cover all top-level skill sources
destire-mio Aug 13, 2026
0e06548
test(cli): cover completion mouse guards
destire-mio Aug 13, 2026
214e60f
test(review): share repository file walker
destire-mio Aug 13, 2026
10aa640
test(cli): pin completion tab ref order
destire-mio Aug 13, 2026
eb79645
test(review): normalize walked repository paths
destire-mio Aug 13, 2026
a06c440
test(cli): narrow completion tab node types
destire-mio Aug 13, 2026
7d7cc37
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 13, 2026
66de09e
chore(review): drop temporary context CI backport
destire-mio Aug 13, 2026
efae094
refactor(cli): unify completion category changes
destire-mio Aug 13, 2026
c16e993
Merge remote-tracking branch 'origin/main' into work/fix-8395
destire-mio Aug 13, 2026
749804f
fix(cli): preserve full completion row indices
destire-mio Aug 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .qwen/e2e-tests/2026-08-03-completion-category-mouse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Completion Category Mouse Selection

## Scope

Verify that the tabbed `@` completion picker can switch to an exact category
with a mouse click when terminal mouse tracking is enabled. Keyboard category
navigation and suggestion-row mouse behavior must remain unchanged.

## Baseline

A released global `qwen` executable was not available in this environment, so
the before-change Warp dry-run could not be repeated locally. The issue's SGR
mouse reproduction reports that suggestion rows accept clicks while category
labels do not. Source inspection on `upstream/main` confirms that suggestion
rows have a mouse controller, while category labels have no refs or click
handler.

## Manual Scenario

1. Run Qwen Code in Warp with `ui.mouseTracking` enabled and the terminal
buffer enabled.
2. Open a workspace where `@` completion shows at least three tabs, such as
**All / Files / Sessions**.
3. Click **Files**, then **Sessions**, then **All**.
4. Confirm that each click activates the exact tab under the pointer, resets
the highlighted suggestion to the first visible result, and filters the
suggestion rows for that category.
5. Confirm that clicking outside every tab does not change the active tab.
6. Confirm that `Ctrl+Tab`, `Ctrl+Shift+Tab`, and `Ctrl+Left/Right` retain their
existing behavior in a terminal that forwards those keys.
7. Set `ui.mouseTracking` to `false`, restart Qwen Code, and confirm that tab
clicks are not intercepted by Qwen Code.

## Regression Checks

- Only a left-button press activates a category; pointer movement and button
release do not.
- The category hit area follows the rendered tab bounds in both normal and
overflow layouts.
- Suggestion-row hover and click handling still use their existing controller.
- Export completion, command search, and reverse search do not receive a
category-selection callback.

## Automated Verification

```bash
cd packages/cli
npx vitest run \
src/ui/components/CompletionCategoryMouseController.test.tsx \
src/ui/components/SuggestionsDisplay.mouse.test.tsx \
src/ui/components/InputPrompt.suggestionMouse.test.tsx \
src/ui/hooks/useCompletion.test.ts

cd ../..
npm run lint
npm run build
npm run typecheck
```

## Results

- The focused mouse/category regression suite passes: 4 files, 41 tests.
- Repository lint, build, and typecheck pass.
- Manual Warp execution remains for reviewer verification because Warp and a
released global `qwen` executable were not available in this environment.
5 changes: 4 additions & 1 deletion .qwen/review-context.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
},
{
"paths": ["packages/core/src/skills/**"],
"relatedPaths": ["packages/core/src/skills/**"],
"relatedPaths": [
"packages/core/src/skills/*.ts",
"packages/core/src/skills/bundled/*/SKILL.md"
],
"domains": ["core-skills"]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ const expectedManifest = {
},
{
paths: ['packages/core/src/skills/**'],
relatedPaths: ['packages/core/src/skills/**'],
// Keep every bundled skill entrypoint, but deliberately leave nested
// implementations, tests, references, and scripts to the changed-file
// diff. Including bundled/*/** makes the all-rule union 129 files and
// violates the 128-item repository-context wire contract.
relatedPaths: [
'packages/core/src/skills/*.ts',
'packages/core/src/skills/bundled/*/SKILL.md',
],
domains: ['core-skills'],
},
{
Expand Down Expand Up @@ -95,7 +102,8 @@ const expectedManifest = {

const relatedPathSentinels: Readonly<Record<string, string>> = {
'packages/core/src/config/**': 'packages/core/src/config/config.ts',
'packages/core/src/skills/**':
'packages/core/src/skills/*.ts': 'packages/core/src/skills/skill-manager.ts',
'packages/core/src/skills/bundled/*/SKILL.md':
'packages/core/src/skills/bundled/review/SKILL.md',
'packages/web-shell/client/adapters/**':
'packages/web-shell/client/adapters/types.ts',
Expand Down Expand Up @@ -187,12 +195,55 @@ describe('committed review context manifest', () => {
}
});

it('stays under the resolved-file bound when every rule co-matches', () => {
const probes = expectedManifest.rules.flatMap((rule) =>
rule.paths.map(probeFor),
it('keeps nested bundled-skill material out of automatic related context', () => {
const changedPath =
'packages/core/src/skills/bundled/dataviz/synthetic-change.txt';
expect(existsSync(join(repoRoot, changedPath))).toBe(false);
const context = provideForRepo([changedPath]);

expect(context).not.toBeNull();
expect(context?.domains).toContain('core-skills');
expect(context?.relatedPaths).toContain(
'packages/core/src/skills/bundled/dataviz/SKILL.md',
);
expect(context?.relatedPaths).not.toContain(
'packages/core/src/skills/bundled/dataviz/references/palette.md',
);
expect(context?.relatedPaths).not.toContain(
'packages/core/src/skills/bundled/dataviz/scripts/validate_palette.js',
);
expect(context?.relatedPaths).not.toContain(
'packages/core/src/skills/bundled/loop/autonomous-loop.ts',
);
});

it('stays under the resolved-file bound when every rule co-matches', () => {
const probes = expectedManifest.rules.map((rule) => {
const wildcardPattern = rule.paths.find((pattern) =>
/[?*]/.test(pattern),
);
expect(
wildcardPattern,
'every rule needs a synthetic wildcard probe for the union test',
).toBeDefined();
const probe = probeFor(wildcardPattern as string);
expect(
existsSync(join(repoRoot, probe)),
'union probes must not be real changed files excluded from relatedPaths',
).toBe(false);
return probe;
});
const context = provideForRepo(probes);
expect(context).not.toBeNull();

// The reviewed tree resolved 115/128 files, leaving 13 slots. Do not pin
// that exact count: the real provider intentionally scans the working tree,
// so harmless untracked files and normal source growth can change it. The
// synthetic, nonexistent changed paths above prevent changed-file exclusion
// from understating the union. The manifest grammar has no negation globs,
// and hooks/** is the fastest-growing remaining group, so this bound is the
// deliberate alarm for future rebalancing rather than permission to
// truncate the result.
expect(context?.relatedPaths.length).toBeLessThanOrEqual(MAX_ARRAY_ITEMS);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/**
* @license
* Copyright 2025 Qwen
* SPDX-License-Identifier: Apache-2.0
*/

import { type MutableRefObject } from 'react';
import { type DOMElement } from 'ink';
import { render } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { CompletionCategoryMouseController } from './CompletionCategoryMouseController.js';
import { useMouseEvents } from '../hooks/useMouseEvents.js';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { type MouseEvent } from '../utils/mouse.js';
import { findElementAtMouseEvent } from '../utils/mouse-hit.js';

vi.mock('../hooks/useMouseEvents.js', () => ({ useMouseEvents: vi.fn() }));
vi.mock('../hooks/useTerminalSize.js', () => ({ useTerminalSize: vi.fn() }));
vi.mock('../utils/mouse-hit.js', () => ({ findElementAtMouseEvent: vi.fn() }));

const ref = <T,>(current: T): MutableRefObject<T> => ({ current });

function makeEvent(
partial: Partial<MouseEvent> & Pick<MouseEvent, 'name'>,
): MouseEvent {
return {
col: 1,
row: 1,
shift: false,
meta: false,
ctrl: false,
button: 'left',
...partial,
} as MouseEvent;
}

describe('CompletionCategoryMouseController', () => {
const containerNode = { tag: 'container' } as unknown as DOMElement;
const categoryNodes = [
{ tag: 'all' },
{ tag: 'file' },
{ tag: 'session' },
] as unknown as DOMElement[];
const categories = ['all', 'file', 'session'] as const;
let onSelectCategory: ReturnType<typeof vi.fn>;

beforeEach(() => {
vi.clearAllMocks();
onSelectCategory = vi.fn();
vi.mocked(useTerminalSize).mockReturnValue({ rows: 40, columns: 80 });
vi.mocked(findElementAtMouseEvent).mockReturnValue(null);
});

function mountAndGetHandler(): (event: MouseEvent) => void {
render(
<CompletionCategoryMouseController
containerRef={ref(containerNode)}
categoryRefs={ref(categoryNodes)}
categories={categories}
onSelectCategory={onSelectCategory}
/>,
);
const call = vi.mocked(useMouseEvents).mock.calls.at(-1)!;
expect(call[1]).toMatchObject({ isActive: true, tracking: 'button' });
return call[0];
}

it('selects the exact category under a left click', () => {
vi.mocked(findElementAtMouseEvent).mockReturnValue(2);
const handler = mountAndGetHandler();

handler(makeEvent({ name: 'left-press', col: 19, row: 5 }));

expect(onSelectCategory).toHaveBeenCalledWith('session');
});

it('ignores clicks outside category bounds', () => {
const handler = mountAndGetHandler();

handler(makeEvent({ name: 'left-press', col: 18, row: 5 }));
handler(makeEvent({ name: 'left-press', col: 9, row: 5 }));
handler(makeEvent({ name: 'left-press', col: 19, row: 6 }));

expect(onSelectCategory).not.toHaveBeenCalled();
});

it('ignores non-press mouse events', () => {
const handler = mountAndGetHandler();

handler(makeEvent({ name: 'move', col: 19, row: 5 }));
handler(makeEvent({ name: 'left-release', col: 19, row: 5 }));

expect(onSelectCategory).not.toHaveBeenCalled();
});

it('uses terminal height when the composited frame overflows', () => {
vi.mocked(findElementAtMouseEvent).mockReturnValue(2);
const handler = mountAndGetHandler();

handler(makeEvent({ name: 'left-press', col: 19, row: 5 }));

expect(findElementAtMouseEvent).toHaveBeenCalledWith(
containerNode,
categoryNodes,
expect.objectContaining({ col: 19, row: 5 }),
40,
'rect',
);
expect(onSelectCategory).toHaveBeenCalledWith('session');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @license
* Copyright 2025 Qwen
* SPDX-License-Identifier: Apache-2.0
*/

import { type MutableRefObject, useCallback } from 'react';
import { type DOMElement } from 'ink';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { useMouseEvents } from '../hooks/useMouseEvents.js';
import { type MouseEvent } from '../utils/mouse.js';
import { findElementAtMouseEvent } from '../utils/mouse-hit.js';
import { type SuggestionCategory } from '../utils/suggestions.js';

type CompletionCategory = SuggestionCategory | 'all';

interface CompletionCategoryMouseControllerProps {
containerRef: MutableRefObject<DOMElement | null>;
categoryRefs: MutableRefObject<Array<DOMElement | null>>;
categories: readonly CompletionCategory[];
onSelectCategory: (category: CompletionCategory) => void;
}

/**
* Headless click layer for the completion category tabs.
*
* Coordinates assume the alternate-screen virtual viewport used by the owning
* suggestion UI. Ink bottom-pins an overflowing frame, so terminal rows must
* pass through `layoutRowForEvent` before they are compared with layout-space
* tab rectangles. Inline mode is intentionally unsupported; mount this only
* behind the owning surface's `mouseEnabled` gate.
*/
export function CompletionCategoryMouseController({
containerRef,
categoryRefs,
categories,
onSelectCategory,
}: CompletionCategoryMouseControllerProps): null {
const { rows: terminalHeight } = useTerminalSize();

const handleMouse = useCallback(
(event: MouseEvent) => {
if (event.name !== 'left-press') return;

const index = findElementAtMouseEvent(
containerRef.current,
categoryRefs.current,
event,
terminalHeight,
'rect',
);
if (index !== null && index < categories.length) {
onSelectCategory(categories[index]);
}
},
[containerRef, categoryRefs, categories, onSelectCategory, terminalHeight],
);

useMouseEvents(handleMouse, { isActive: true, tracking: 'button' });

return null;
}
Loading
Loading