Skip to content

web: add a command palette - #8551

Merged
unknwon merged 6 commits into
mainfrom
command-palette-flamego
Nov 17, 2026
Merged

unknwon merged 6 commits into
mainfrom
command-palette-flamego

Conversation

@unknwon

@unknwon unknwon commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Adds a command palette that opens with Ctrl K or ⌘K on any page, or from the "Search or jump to…" button in the navbar, which replaces the code search box from #8549. It builds all three directions of the mock together: jump-first results, matching lines of code as you type inside a repository, and the >, #, @ and / prefixes.

New endpoints:

  • GET /api/web/search/issues?q=&repo=: issues and pull requests by number (12 or #12, matched first) or by words in the title, ignoring case, open ones first, then the most recently updated, at most 10. Without repo it searches every repository the viewer can see, like code search. Issues follow the same access as the issue list (readers, or anyone when guests can view issues, and not with an external tracker), and pull requests need read access and pulls enabled. Backed by database.SearchIssues.
  • Go to file uses GET /api/web/{owner}/{repo}/paths, which is already on main. The browser keeps the list for five minutes per repository.
  • GET /api/web/{owner}/{repo}/search takes a limit, so the palette asks for five lines and the search stops early.
  • The repository header now has viewerCanWrite, and defaultBranch and cloneLinks for viewers who can read the code. The palette uses them to decide which rows to show.

Details:

  • Groups, in order: issues and pull requests, files, repository commands, repositories, people and organizations, pages and actions, code, and a last row that opens the code search page with the query.
  • Scope: inside a repository the box starts with an owner/repo chip. Its × button, or Backspace in an empty box, searches everywhere instead. Each opening starts scoped again.
  • Empty box: the four prefixes, up to three recently opened repositories (kept per user in local storage), and the first commands of the repository or the site.
  • Matching: text matches are substrings, ranked higher at the start of the text or of a word. Go to file ranks a file name prefix, then a match in the file name, then in the path, then letters in order, and highlights what matched.
  • Prefixes: > lists every matching command, # issues and pull requests only, @ people and organizations, and / code in the repository (path: works) plus the code search row.
  • Code as you type runs only inside a repository, for at least three characters, 300 ms after typing stops. A search of every repository at each pause costs too much, so outside a repository the last row opens the code search page. Long lines start shortly before the match so it stays visible.
  • Actions: theme, a toggle between light and dark that flips whatever the page shows (so with the system theme on a dark OS it offers light), turning glass mode on or off, switching the language (one row per language, sharing the list of the settings menu), sign out, star and watch (the header updates), copy the HTTPS or SSH clone URL, download ZIP. Writer-only rows (new file, upload, new release, new wiki page) and the repository settings pages follow viewerCanWrite and viewerCanAdminister. Signed-out viewers get sign in and register instead of account pages.
  • Glass look: the palette blurs what is behind it, like the shared dialog and other popovers.
  • Accessibility: an ARIA combobox with a grouped listbox, aria-activedescendant, and aria-keyshortcuts on both navbar buttons. The palette is a Radix dialog, so focus stays inside and goes back to the button on close.
  • 375px: the palette fills the screen with a Cancel button, rows are 44px tall, the key hints are hidden, and a search icon in the navbar opens it.
  • Moved useDebounced to lib/use-debounced.ts and signOut to lib/sign-out.ts to share them. Removed the compact prop of CodeSearchInput, which only the navbar box used. Added the [palette] locale keys and repo.unstar.
  • Left out "New pull request": where it goes depends on fork rules the server works out for the pull request list, which keeps its button.

File tree and file view heights

Also fixes the code browser, where since the glass look (#8647) the file tree was as tall as the file view, so a long tree beside a short file was squashed, and a short tree stretched the file view. Now each takes its own height: the file view is as tall as its content, and the tree as tall as its rows, up to the height of the window, scrolling inside beyond that. ResizableSidebar lets its content shrink, so the tree scrolls rather than being cut off.

README alignment and image sizes

Markdown keeps align (left, center, right or justify) on div, p and headings, and width, height and align on images with a relative path, as GitHub does. Image sizes may end in px, e.g., the width="201px" of the DigitalOcean logo, which browsers read as pixels. The gogs README's centered logo and badges now render centered. Before, the sanitizer dropped align on blocks, and wrapping an image in a link to itself rebuilt the img with only src and alt. An image with align="left" or align="right" floats so text flows around it.

Rendered Markdown, e.g., READMEs, issues and wiki pages, uses GitHub's font sizes and line heights: body text 16px (was 14px), headings 2em, 1.5em, 1.25em, 1em, 0.875em and 0.85em, inline and fenced code 85%, keyboard keys 11px and footnotes 12px.

File card header

The header of a file no longer repeats its name and icon, which the breadcrumb above already shows. It starts with the Preview and Code switch, or with the line count for files without a preview. The name stays as a heading for screen readers, which labels the card. The isReadme field of the file response is removed, since only that icon read it.

Behavior changes from legacy

  • New. Legacy Gogs has no palette and no search of issues across repositories.
  • The navbar code search box from search: search the code of repositories #8549 becomes the palette button. Code search of all repositories stays at /search, reachable from the palette and the mobile menu.

Screenshots

In a repository: files, repository commands and code as you type

Palette scoped to acme/api for webhook with files, a settings command and matching lines of code

Empty box in a repository: prefixes, recent repositories, repository commands

Empty palette in alice/alpha

Issues and pull requests come first

Palette for readme in alice/alpha with two pull requests and a file, in dark glass

/ code in the repository

Palette listing eight lines of code with ErrNotExist

# issues and pull requests, dark glass

Palette for # crash with a closed pull request

> commands

Palette listing settings commands for > set

> commands, dark glass

The same in dark glass

Glass look

Palette for webhook in dark glass, with the page blurred behind it

Glass look, light

Palette for webhook in light glass

At 375px: the navbar search icon, the empty box, results, and dark glass

Navbar at 375px with the search icon Empty palette at 375px Results at 375px Results at 375px in dark glass

File tree and file view at their own heights

A short tree ending after its last row beside a longer README card
The gogs source tree as tall as the window beside .gitignore, whose card ends after its last line
The short tree in dark glass

README alignment and image sizes

The gogs README with its logo, badges and tagline centered
The same in dark glass
The DigitalOcean logo at 201px in the acknowledgments
A centered heading, two images 120 and 240 wide, a right-aligned paragraph and text flowing around a right-floated image

The same demo at 375px

Markdown at GitHub's font sizes

Every heading level, inline code, keys, fenced and indented code, a table and a footnote
The same in dark glass
A pull request description at 16px

The same file at 375px

Theme toggle

The palette offering "Switch to dark theme" for "toggle"
With the system theme on a dark OS it offers "Switch to light theme"

File card header without the repeated name

SKILL.md with Preview and Code, then the line count
The same in dark glass
go.mod, which starts with the line count

SKILL.md at 375px

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code and provided the test plan below.
  • I have added an entry to CHANGELOG.

Test plan

  1. go test ./internal/git/ ./internal/database/ ./cmd/gogs/internal/web/ passes. golangci-lint run ./... reports 0 issues. In web/, tsc -b, pnpm run lint, Prettier and pnpm run build pass.

  2. The integration suite passes against PostgreSQL with -shuffle=on, and every route has a test. TestIssueSearch covers GET /api/web/search/issues:

    • Titles match ignoring case, and a closed issue comes after the open ones even when it was updated last.
    • 12 and #12 find that number.
    • An empty keyword lists nothing.
    • 🚨 Issues of a private repository are not found by signed-out viewers or other users, even when they name it with repo= or search its number. The owner finds them.
    • With pull requests turned off, the pull request drops out of title and number results.

    The test fails when the read check on issues is removed, when pull requests ignore whether they are turned on, when the order is only by update time, without the number match, and with case-sensitive titles.

  3. Built with -tags prod and checked in the browser as alice on alice/alpha and acme/api (the gogs source): the empty box, readme (pull requests, then README.md), webhook (files, a settings command and lines of code), / ErrNotExist (eight lines of code), # crash, > set (15 settings rows), > glass turning glass mode on and then off, and > 简体 and > english switching the language and back. Checked in light, dark, light glass and dark glass at 1280px and at 375px. With the glass look the page behind the palette is blurred. Nothing scrolls sideways at 375px.

  4. File tree and file view: measured both panels at 1280×900. The alice/alpha tree is 318px, its rows, beside a 723px README card. The gogs source tree stops at the window (795px) and scrolls inside, beside a 487px .gitignore card and a 54,387px internal/database/repo.go card. Each card is as tall as its content. Checked in light and dark glass.

  5. README alignment: TestSanitizer keeps align on div, p and h1 and drops it on span and for other values. TestMarkdown_SpecialLinks renders a centered div whose relative image keeps width, height and alt after being wrapped in a link, and a p with align="middle" that loses it. TestSanitizer keeps width="201px" and drops 20em and 1px;color:red. Each test fails with its fix reverted. FuzzRender ran for 45 seconds without a difference between the fast path and the sanitizer. In the browser, the DigitalOcean logo in the acme/api README is 201px wide at 1280px and at 375px, and the README's three centered blocks have text-align: center, and the logo is centered in the card. A demo file shows images at 120px and 240px, a right-aligned paragraph and a floated image, at 1280px and 375px with nothing scrolling sideways.

  6. Markdown sizes: on a file with every element, the computed sizes match GitHub's github-markdown-css: body 16/24px, h1 to h6 32, 24, 20, 16, 14 and 13.6px with line height 1.25, inline code 13.6px, kbd 11px, footnotes 12px, and fenced code 13.6px with 19.72px lines. A pull request description is 16px. Checked in light and dark glass at 1280px and at 375px, where nothing scrolls sideways.

  7. File card header: opened .agents/skills/ghsa/SKILL.md and go.mod in acme/api. The header has no file name or icon, and the card is still labelled by a visually hidden heading with the file name. Checked in light and dark glass at 1280px and at 375px, where nothing scrolls sideways.

  8. Theme toggle: in the palette, with the system theme on a light OS, "Switch to dark theme" turns the page dark and stores dark, then reads "Switch to light theme" and turns it back. With the system theme on a dark OS it offers light. > toggle lists it first and Enter runs it. Checked at 1280px and at 375px in glass.

unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon added this pull request to stack #8457 November 14, 2026 02:49
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch 2 times, most recently from c7c0265 to 777ab12 Compare November 14, 2026 07:09
unknwon added a commit that referenced this pull request Nov 14, 2026
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 777ab12 to 3bde71b Compare November 14, 2026 07:11
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 3bde71b to 3e5fbd1 Compare November 14, 2026 13:23
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 3e5fbd1 to ef31f9b Compare November 14, 2026 16:03
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from ef31f9b to 35e556f Compare November 14, 2026 16:47
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 35e556f to bf3074c Compare November 14, 2026 17:11
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from bf3074c to 217d878 Compare November 14, 2026 18:49
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 217d878 to 88de163 Compare November 14, 2026 19:00
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 88de163 to cf31880 Compare November 14, 2026 19:23
unknwon added a commit that referenced this pull request Nov 14, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from e14b3a6 to 83d119e Compare November 15, 2026 01:22
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch 2 times, most recently from b382768 to fe105df Compare November 15, 2026 02:17
unknwon added a commit that referenced this pull request Nov 15, 2026
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from b382768 to 8cf033f Compare November 15, 2026 04:06
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 8cf033f to 8dc26d1 Compare November 15, 2026 04:21
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 8dc26d1 to 17c0e7d Compare November 15, 2026 04:36
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 17c0e7d to 6a8bc55 Compare November 15, 2026 05:02
unknwon added a commit that referenced this pull request Nov 15, 2026
@unknwon
unknwon force-pushed the command-palette-flamego branch from 6a8bc55 to e26db76 Compare November 15, 2026 05:34
unknwon added a commit that referenced this pull request Nov 15, 2026
@mintlify

mintlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
Gogs 🟢 Ready View Preview Nov 17, 2026, 10:56 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Comment thread cmd/gogs/internal/web/webapi_search.go Outdated
Comment on lines +187 to +190
limit := c.QueryInt("limit")
if limit <= 0 || limit > codeSearchMaxResults {
limit = codeSearchMaxResults
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

use builint min and max

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 2b1cf22: limit := max(1, min(c.QueryInt("limit", codeSearchMaxResults), codeSearchMaxResults)). A missing limit still means 200. A limit of 0 or one that isn't a number now means 1 rather than 200.

Comment thread conf/locale/locale_en-US.ini Outdated
file_too_big = File size ({{filesize}} MB) exceeds maximum size ({{maxFilesize}} MB).
remove_file = Remove file

[palette]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggested change
[palette]
[command_palette]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 2b1cf22: the section is [command_palette] and every key in the frontend uses command_palette..

Ctrl K or ⌘K opens a palette that jumps to issues and pull requests,
files, repositories, people, pages and settings, and runs actions such as
switching the theme, starring a repository or copying its clone URL. Inside
a repository it also lists matching lines of code as you type. The >, #, @
and / prefixes limit the results to commands, issues, people or code. Its
navbar button replaces the code search box.

The palette finds issues and pull requests by title or number with
GET /api/web/search/issues, and lists the files of a repository with
GET /api/web/{owner}/{repo}/paths.
Since the glass look, the file tree of the code browser was as tall as
the file view, so a long tree beside a short file was squashed, and a
short tree stretched the file view. Now the file view is as tall as its
content, and the tree as tall as its rows, up to the height of the
window, scrolling inside beyond that.
READMEs that center content with <div align="center"> or size images
with width and height now render as they do on GitHub.
Body text is 16px, headings 2em down to 0.85em, code 85%, keyboard
keys 11px and footnotes 12px, with GitHub's line heights.

This branch was successfully deployed

1 active deployment
staging - docs — a94f7046 Deployed Nov 17, 2026 by mintlify[bot]
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.

1 participant