Skip to content

Fix various problems #35012

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

Merged
merged 5 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion modules/setting/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
}
default:
log.Fatal("Invalid PROTOCOL %q", Protocol)
log.Fatal("Invalid PROTOCOL %q", protocolCfg)
}
UseProxyProtocol = sec.Key("USE_PROXY_PROTOCOL").MustBool(false)
ProxyProtocolTLSBridging = sec.Key("PROXY_PROTOCOL_TLS_BRIDGING").MustBool(false)
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/diff/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{end}}
<div class="content comment-container">
<div class="comment-header">
<div class="comment-header-left tw-flex tw-items-center">
<div class="comment-header-left">
{{if .OriginalAuthor}}
<span class="text black tw-font-semibold tw-mr-1">
{{svg (MigrationIcon $.root.Repository.GetOriginalURLHostname)}}
Expand All @@ -30,7 +30,7 @@
</span>
{{end}}
</div>
<div class="comment-header-right actions tw-flex tw-items-center">
<div class="comment-header-right">
{{if .Invalidated}}
{{$referenceUrl := printf "%s#%s" $.root.Issue.Link .HashTag}}
<a href="{{$referenceUrl}}" class="ui label basic small" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.outdated_description"}}">
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{end}}
<div class="content comment-container">
<div class="comment-header" role="heading" aria-level="3">
<div class="comment-header-left tw-flex tw-items-center">
<div class="comment-header-left">
{{if .Issue.OriginalAuthor}}
<span class="text black tw-font-semibold">
{{svg (MigrationIcon .Repository.GetOriginalURLHostname)}}
Expand All @@ -36,7 +36,7 @@
</span>
{{end}}
</div>
<div class="comment-header-right actions tw-flex tw-items-center">
<div class="comment-header-right">
{{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "IgnorePoster" true}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
Expand Down
8 changes: 4 additions & 4 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{end}}
<div class="content comment-container">
<div class="comment-header" role="heading" aria-level="3">
<div class="comment-header-left tw-flex tw-items-center">
<div class="comment-header-left">
{{if .OriginalAuthor}}
<span class="text black tw-font-semibold tw-mr-1">
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
Expand All @@ -51,7 +51,7 @@
</span>
{{end}}
</div>
<div class="comment-header-right actions tw-flex tw-items-center">
<div class="comment-header-right">
{{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
Expand Down Expand Up @@ -395,7 +395,7 @@
<div class="timeline-item comment">
<div class="content comment-container">
<div class="comment-header">
<div class="comment-header-left tw-flex tw-items-center">
<div class="comment-header-left">
{{if gt .Poster.ID 0}}
<a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}">
{{ctx.AvatarUtils.Avatar .Poster 24}}
Expand All @@ -416,7 +416,7 @@
{{ctx.Locale.Tr "repo.issues.review.left_comment"}}
</span>
</div>
<div class="comment-header-right actions tw-flex tw-items-center">
<div class="comment-header-right">
{{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/conversation.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="comment code-comment" id="{{.HashTag}}">
<div class="content comment-container">
<div class="comment-header">
<div class="comment-header-left tw-flex tw-items-center">
<div class="comment-header-left">
{{if not .OriginalAuthor}}
<a class="avatar">
{{ctx.AvatarUtils.Avatar .Poster 20}}
Expand All @@ -79,7 +79,7 @@
{{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdSubStr}}
</span>
</div>
<div class="comment-header-right actions tw-flex tw-items-center">
<div class="comment-header-right">
{{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
Expand Down
13 changes: 0 additions & 13 deletions web_src/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ details summary {
cursor: pointer;
}

details summary > * {
display: inline;
}

progress {
background: var(--color-secondary-dark-1);
border-radius: var(--border-radius);
Expand Down Expand Up @@ -474,15 +470,6 @@ a.label,
color: var(--color-text-light-2);
}

.ui.comments .comment .actions a {
color: var(--color-text-light);
}

.ui.comments .comment .actions a.active,
.ui.comments .comment .actions a:hover {
color: var(--color-primary);
}

img.ui.avatar,
.ui.avatar img,
.ui.avatar svg {
Expand Down
2 changes: 1 addition & 1 deletion web_src/css/modules/label.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ a.ui.label:hover {
background: var(--color-button);
border: 1px solid var(--color-light-border);
color: var(--color-text-light);
padding: calc(0.5833em - 1px) calc(0.833em - 1px);
}
a.ui.basic.label:hover {
text-decoration: none;
Expand Down Expand Up @@ -254,6 +253,7 @@ a.ui.ui.ui.basic.grey.label:hover {
color: var(--color-label-hover-bg);
}

/* "horizontal label" is actually "fat label" which has enough padding spaces to be used standalone in headers */
.ui.horizontal.label {
margin: 0 0.5em 0 0;
padding: 0.4em 0.833em;
Expand Down
28 changes: 10 additions & 18 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1420,13 +1420,15 @@ td .commit-summary {
.comment-header {
background: var(--color-box-header);
border-bottom: 1px solid var(--color-secondary);
padding: 0 1rem;
padding: 0.5em 1rem;
position: relative;
color: var(--color-text);
min-height: 41px;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 0.25em;
}

.comment-header::before,
Expand Down Expand Up @@ -1468,17 +1470,16 @@ td .commit-summary {
left: 7px;
}

.comment-header .actions a:not(.label) {
padding: 0.5rem !important;
}

.comment-header .actions .label {
margin: 0 !important;
.comment-header-left,
.comment-header-right {
display: flex;
align-items: center;
gap: 0.5em;
}

.comment-header-left,
.comment-header-right {
gap: 4px;
flex: 1;
justify-content: end;
}

.comment-body {
Expand Down Expand Up @@ -2014,15 +2015,6 @@ tbody.commit-list {
.commit-table th.sha {
display: none !important;
}
.comment-header {
flex-wrap: wrap;
}
.comment-header .comment-header-left {
flex-wrap: wrap;
}
.comment-header .comment-header-right {
margin-left: auto;
}
}

.commit-status-header {
Expand Down
6 changes: 3 additions & 3 deletions web_src/js/features/file-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {FileRenderPlugin} from '../render/plugin.ts';
import {newRenderPlugin3DViewer} from '../render/plugins/3d-viewer.ts';
import {newRenderPluginPdfViewer} from '../render/plugins/pdf-viewer.ts';
import {registerGlobalInitFunc} from '../modules/observer.ts';
import {createElementFromHTML, showElem, toggleClass} from '../utils/dom.ts';
import {createElementFromHTML, showElem, toggleElemClass} from '../utils/dom.ts';
import {html} from '../utils/html.ts';
import {basename} from '../utils.ts';

Expand All @@ -21,8 +21,8 @@ function showRenderRawFileButton(elFileView: HTMLElement, renderContainer: HTMLE
const toggleButtons = elFileView.querySelector('.file-view-toggle-buttons');
showElem(toggleButtons);
const displayingRendered = Boolean(renderContainer);
toggleClass(toggleButtons.querySelectorAll('.file-view-toggle-source'), 'active', !displayingRendered); // it may not exist
toggleClass(toggleButtons.querySelector('.file-view-toggle-rendered'), 'active', displayingRendered);
toggleElemClass(toggleButtons.querySelectorAll('.file-view-toggle-source'), 'active', !displayingRendered); // it may not exist
toggleElemClass(toggleButtons.querySelector('.file-view-toggle-rendered'), 'active', displayingRendered);
// TODO: if there is only one button, hide it?
}

Expand Down
10 changes: 5 additions & 5 deletions web_src/js/features/repo-graph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {toggleClass} from '../utils/dom.ts';
import {toggleElemClass} from '../utils/dom.ts';
import {GET} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';

Expand All @@ -9,11 +9,11 @@ export function initRepoGraphGit() {
const elColorMonochrome = document.querySelector<HTMLElement>('#flow-color-monochrome');
const elColorColored = document.querySelector<HTMLElement>('#flow-color-colored');
const toggleColorMode = (mode: 'monochrome' | 'colored') => {
toggleClass(graphContainer, 'monochrome', mode === 'monochrome');
toggleClass(graphContainer, 'colored', mode === 'colored');
toggleElemClass(graphContainer, 'monochrome', mode === 'monochrome');
toggleElemClass(graphContainer, 'colored', mode === 'colored');

toggleClass(elColorMonochrome, 'active', mode === 'monochrome');
toggleClass(elColorColored, 'active', mode === 'colored');
toggleElemClass(elColorMonochrome, 'active', mode === 'monochrome');
toggleElemClass(elColorColored, 'active', mode === 'colored');

const params = new URLSearchParams(window.location.search);
params.set('mode', mode);
Expand Down
16 changes: 10 additions & 6 deletions web_src/js/features/repo-settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {minimatch} from 'minimatch';
import {createMonaco} from './codeeditor.ts';
import {onInputDebounce, queryElems, toggleClass, toggleElem} from '../utils/dom.ts';
import {onInputDebounce, queryElems, toggleElem} from '../utils/dom.ts';
import {POST} from '../modules/fetch.ts';
import {initRepoSettingsBranchesDrag} from './repo-settings-branches.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
Expand Down Expand Up @@ -124,14 +124,18 @@ function initRepoSettingsOptions() {
const pageContent = document.querySelector('.page-content.repository.settings.options');
if (!pageContent) return;

// Enable or select internal/external wiki system and issue tracker.
// toggle related panels for the checkbox/radio inputs, the "selector" may not exist
const toggleTargetContextPanel = (selector: string, enabled: boolean) => {
if (!selector) return;
queryElems(document, selector, (el) => el.classList.toggle('disabled', !enabled));
};
queryElems<HTMLInputElement>(pageContent, '.enable-system', (el) => el.addEventListener('change', () => {
toggleClass(el.getAttribute('data-target'), 'disabled', !el.checked);
toggleClass(el.getAttribute('data-context'), 'disabled', el.checked);
toggleTargetContextPanel(el.getAttribute('data-target'), el.checked);
toggleTargetContextPanel(el.getAttribute('data-context'), !el.checked);
}));
queryElems<HTMLInputElement>(pageContent, '.enable-system-radio', (el) => el.addEventListener('change', () => {
toggleClass(el.getAttribute('data-target'), 'disabled', el.value === 'false');
toggleClass(el.getAttribute('data-context'), 'disabled', el.value === 'true');
toggleTargetContextPanel(el.getAttribute('data-target'), el.value === 'true');
toggleTargetContextPanel(el.getAttribute('data-context'), el.value === 'false');
}));

queryElems<HTMLInputElement>(pageContent, '.js-tracker-issue-style', (el) => el.addEventListener('change', () => {
Expand Down
12 changes: 11 additions & 1 deletion web_src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,15 @@ import {onDomReady} from './utils/dom.ts';
import 'htmx.org';

onDomReady(async () => {
await import(/* webpackChunkName: "index-domready" */'./index-domready.ts');
// when navigate before the import complete, there will be an error from webpack chunk loader:
// JavaScript promise rejection: Loading chunk index-domready failed.
try {
await import(/* webpackChunkName: "index-domready" */'./index-domready.ts');
} catch (e) {
if (e.name === 'ChunkLoadError') {
console.error('Error loading index-domready:', e);
} else {
throw e;
}
}
Copy link
Member

@silverwind silverwind Jul 9, 2025

Choose a reason for hiding this comment

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

Side note: So we are waiting for DOMContentLoaded until we load this chunk from the network? I think this will cause unnecessary delay and we could start this load earlier and only actually execute the code on DOMContentLoaded.

Copy link
Contributor Author

@wxiaoguang wxiaoguang Jul 9, 2025

Choose a reason for hiding this comment

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

The waiting time is almost the same as the old approach : index.js before </body></html>.

But yes, we can start the import immediately, and only "init" in DOMContentLoaded, it needs to make the index-domready expose its init function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can do that together after this htmx bug gets fixed:

image

Copy link
Member

@silverwind silverwind Jul 9, 2025

Choose a reason for hiding this comment

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

If there are no major benefits to this 2-chunk approach, maybe we should have all main JS in one chunk only. It's simpler design and whether the browser loads 1MB vs. 1.3MB makes no practical difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also think we can merge them into one index.js and load it in the <head>, total size is about 2.7MB

Copy link
Member

@silverwind silverwind Jul 10, 2025

Choose a reason for hiding this comment

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

That value seems off. In 1.24 I see much lower sizes:

image

Copy link
Contributor Author

@wxiaoguang wxiaoguang Jul 10, 2025

Choose a reason for hiding this comment

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

That value seems off. In 1.24 I see much lower sizes:

If it is, which part makes the new index.js so large? #34960 (comment)

Or the size difference is caused by different packing options? production vs dev?

Copy link
Member

@silverwind silverwind Jul 10, 2025

Choose a reason for hiding this comment

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

Ah yes likely you are seeing dev values. Dev JS is not minified:

minimize: isProduction,

});
4 changes: 2 additions & 2 deletions web_src/js/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {decode, encode} from 'uint8-to-base64';
import type {IssuePageInfo, IssuePathInfo, RepoOwnerPathInfo} from './types.ts';
import {toggleClass, toggleElem} from './utils/dom.ts';
import {toggleElemClass, toggleElem} from './utils/dom.ts';

// transform /path/to/file.ext to /path/to
export function dirname(path: string): string {
Expand Down Expand Up @@ -194,7 +194,7 @@ export function toggleFullScreen(fullscreenElementsSelector: string, isFullScree

const fullScreenEl = document.querySelector(fullscreenElementsSelector);
const outerEl = document.querySelector('.full.height');
toggleClass(fullscreenElementsSelector, 'fullscreen', isFullScreen);
toggleElemClass(fullscreenElementsSelector, 'fullscreen', isFullScreen);
if (isFullScreen) {
outerEl.append(fullScreenEl);
} else {
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function elementsCall(el: ElementArg, func: ElementsCallbackWithArgs, ...args: a
throw new Error('invalid argument to be shown/hidden');
}

export function toggleClass(el: ElementArg, className: string, force?: boolean): ArrayLikeIterable<Element> {
export function toggleElemClass(el: ElementArg, className: string, force?: boolean): ArrayLikeIterable<Element> {
return elementsCall(el, (e: Element) => {
if (force === true) {
e.classList.add(className);
Expand All @@ -44,7 +44,7 @@ export function toggleClass(el: ElementArg, className: string, force?: boolean):
* @param force force=true to show or force=false to hide, undefined to toggle
*/
export function toggleElem(el: ElementArg, force?: boolean): ArrayLikeIterable<Element> {
return toggleClass(el, 'tw-hidden', force === undefined ? force : !force);
return toggleElemClass(el, 'tw-hidden', force === undefined ? force : !force);
}

export function showElem(el: ElementArg): ArrayLikeIterable<Element> {
Expand Down