Skip to content

Commit d13eedd

Browse files
committed
ログ読み込み時のパフォーマンス設定を可変に
1 parent 387979f commit d13eedd

File tree

8 files changed

+73
-49
lines changed

8 files changed

+73
-49
lines changed

.github/workflows/build-web-assets.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,10 @@ permissions:
33
contents: read
44

55
on:
6-
workflow_dispatch:
7-
inputs:
8-
branch:
9-
description: 'Branch to build from'
10-
required: true
11-
default: 'master'
12-
type: choice
13-
options:
14-
- master
15-
build_type:
16-
description: 'Build type'
17-
required: true
18-
default: 'both'
19-
type: choice
20-
options:
21-
- debug
22-
- production
23-
- both
6+
push:
7+
branches: [ master ]
8+
paths:
9+
- 'RemoteLogViewer.WinUI/Assets/Web/**'
2410

2511
jobs:
2612
build-web-assets:
@@ -29,8 +15,6 @@ jobs:
2915
steps:
3016
- name: Checkout repository
3117
uses: actions/checkout@v4
32-
with:
33-
ref: ${{ github.event.inputs.branch }}
3418

3519
- name: Setup Node.js
3620
uses: actions/setup-node@v4
@@ -45,29 +29,25 @@ jobs:
4529
timeout-minutes: 10
4630

4731
- name: Build for Debug
48-
if: ${{ github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both' }}
4932
working-directory: RemoteLogViewer.WinUI/Assets/Web
5033
run: npm run build:dev
5134
timeout-minutes: 10
5235

5336
- name: Upload Debug Web Assets
54-
if: ${{ github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == 'both' }}
5537
uses: actions/upload-artifact@v4
5638
with:
57-
name: web-assets-debug-${{ github.event.inputs.branch }}-${{ github.sha }}
39+
name: web-assets-debug-${{ github.ref_name }}-${{ github.sha }}
5840
path: RemoteLogViewer.WinUI/Assets/Web/dist/
5941
retention-days: 30
6042

6143
- name: Build for Production
62-
if: ${{ github.event.inputs.build_type == 'production' || github.event.inputs.build_type == 'both' }}
6344
working-directory: RemoteLogViewer.WinUI/Assets/Web
6445
run: npm run build
6546
timeout-minutes: 10
6647

6748
- name: Upload Production Web Assets
68-
if: ${{ github.event.inputs.build_type == 'production' || github.event.inputs.build_type == 'both' }}
6949
uses: actions/upload-artifact@v4
7050
with:
71-
name: web-assets-production-${{ github.event.inputs.branch }}-${{ github.sha }}
51+
name: web-assets-production-${{ github.ref_name }}-${{ github.sha }}
7252
path: RemoteLogViewer.WinUI/Assets/Web/dist/
7353
retention-days: 30

RemoteLogViewer.Composition/Stores/Settings/TextViewerSettingsModel.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@ namespace RemoteLogViewer.Composition.Stores.Settings;
1111
public class TextViewerSettingsModel(IServiceProvider service) {
1212
public IServiceProvider ScopedService { get; } = service;
1313
/// <summary>
14-
/// 1行に表示する最大文字数
14+
/// 1度に追加読み込みする行数
1515
/// </summary>
16-
public ReactiveProperty<int> MaxPreviewOneLineCharacters {
16+
public ReactiveProperty<int> PrefetchLineCount {
1717
get;
18-
} = new(1000);
18+
} = new(200);
19+
20+
/// <summary>
21+
/// 追加読み込みの閾値行数(残りXX行になったら追加読み込みする。)
22+
/// </summary>
23+
public ReactiveProperty<int> PrefetchThresholdLines {
24+
get;
25+
} = new(50);
1926

2027
/// <summary>
21-
/// 全体で表示する最大文字数
28+
/// 画面内に保持する最大行数
2229
/// </summary>
23-
public ReactiveProperty<int> MaxPreviewCharacters {
30+
public ReactiveProperty<int> MaxLogLineLimit {
2431
get;
25-
} = new(30000);
32+
} = new(1000);
2633

2734
/// <summary>
2835
/// Grep の最大件数

RemoteLogViewer.Core/ViewModels/Settings/TextViewerSettingsPageViewModel.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Logging;
2+
23
using RemoteLogViewer.Core.Stores.Settings;
34
using RemoteLogViewer.Core.Utils.Extensions;
45

@@ -10,16 +11,23 @@ namespace RemoteLogViewer.Core.ViewModels.Settings;
1011
[Inject(InjectServiceLifetime.Transient)]
1112
public class TextViewerSettingsPageViewModel : SettingsPageViewModel<TextViewerSettingsPageViewModel> {
1213
/// <summary>
13-
/// 1行に表示する最大文字数
14+
/// 1度に追加読み込みする行数
15+
/// </summary>
16+
public BindableReactiveProperty<int> PrefetchLineCount {
17+
get;
18+
}
19+
20+
/// <summary>
21+
/// 追加読み込みの閾値行数(残りXX行になったら追加読み込みする。)
1422
/// </summary>
15-
public BindableReactiveProperty<int> MaxPreviewOneLineCharacters {
23+
public BindableReactiveProperty<int> PrefetchThresholdLines {
1624
get;
1725
}
1826

1927
/// <summary>
20-
/// 全体で表示する最大文字数
28+
/// 画面内に保持する最大行数
2129
/// </summary>
22-
public BindableReactiveProperty<int> MaxPreviewCharacters {
30+
public BindableReactiveProperty<int> MaxLogLineLimit {
2331
get;
2432
}
2533

@@ -32,8 +40,9 @@ public BindableReactiveProperty<int> GrepMaxResults {
3240

3341
/// <summary>コンストラクタ。</summary>
3442
public TextViewerSettingsPageViewModel(SettingsStoreModel settingsStoreModel, ILogger<TextViewerSettingsPageViewModel> logger) : base("TextViewer", logger) {
35-
this.MaxPreviewOneLineCharacters = settingsStoreModel.SettingsModel.TextViewerSettings.MaxPreviewOneLineCharacters.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
36-
this.MaxPreviewCharacters = settingsStoreModel.SettingsModel.TextViewerSettings.MaxPreviewCharacters.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
43+
this.PrefetchLineCount = settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchLineCount.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
44+
this.PrefetchThresholdLines = settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchThresholdLines.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
45+
this.MaxLogLineLimit = settingsStoreModel.SettingsModel.TextViewerSettings.MaxLogLineLimit.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
3746
this.GrepMaxResults = settingsStoreModel.SettingsModel.TextViewerSettings.GrepMaxResults.ToTwoWayBindableReactiveProperty().AddTo(this.CompositeDisposable);
3847
}
3948
}

RemoteLogViewer.WinUI/Assets/Web/src/components/TextFileViewer.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ const props = withDefaults(defineProps<Props>(), {
4242
});
4343
4444
// 追加読み込み行数
45-
const prefetchLines = 200;
45+
let prefetchLines = 200;
4646
// 追加読み込みのしきい値行数
47-
const prefetchThreshold = 50;
47+
let prefetchThreshold = 50;
4848
// ログ保持上限行数
49-
const maxLogLines = 1000;
49+
let maxLogLines = 1000;
5050
5151
// テンプレート参照
5252
const logArea = ref<HTMLElement>();
@@ -343,7 +343,7 @@ onMounted(() => {
343343
// C# → JS 通信
344344
window.chrome.webview.addEventListener('message', e => {
345345
const message = e.data;
346-
if (message.pageKey !== props.pageKey) {
346+
if (![props.pageKey, '*'].includes(message.pageKey)) {
347347
return;
348348
}
349349
switch (message.type) {
@@ -361,6 +361,11 @@ onMounted(() => {
361361
reset();
362362
jumpLine(startLine.value);
363363
break;
364+
case 'SettingsUpdated':
365+
prefetchLines = message.data.prefetchLineCount;
366+
prefetchThreshold = message.data.prefetchThresholdLines;
367+
maxLogLines = message.data.maxLogLineLimit;
368+
break;
364369
}
365370
});
366371
});

RemoteLogViewer.WinUI/Assets/Web/src/types/incommingMessages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export interface IsDisconnectedUpdatedMessage extends IncomingAbstractWebMessage
1212
data: boolean;
1313
}
1414

15+
export interface SettingsUpdatedMessage extends IncomingAbstractWebMessage {
16+
type: 'SettingsUpdated';
17+
data: {
18+
prefetchLineCount: number;
19+
prefetchThresholdLines: number;
20+
maxLogLineLimit: number;
21+
};
22+
}
23+
1524
export interface LineStyleChangedMessage extends IncomingAbstractWebMessage {
1625
type: 'LineStyleChanged';
1726
data: string;
@@ -120,6 +129,7 @@ export interface GrepResultResetMessage extends IncomingAbstractWebMessage {
120129

121130
export type IncomingWebMessage =
122131
| IsDisconnectedUpdatedMessage
132+
| SettingsUpdatedMessage
123133
| LineStyleChangedMessage
124134
| ReloadRequestedMessage
125135
| FileOpenedMessage

RemoteLogViewer.WinUI/Views/Settings/TextViewerSettingsPage.xaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
mc:Ignorable="d">
99

10-
<Grid Padding="16" RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,Auto">
11-
<TextBlock Text="1行あたり表示可能文字数"/>
12-
<NumberBox Grid.Column="1" Text="{x:Bind ViewModel.MaxPreviewOneLineCharacters.Value,Mode=TwoWay}"/>
13-
<TextBlock Grid.Row="1" Text="全体で表示可能文字数"/>
14-
<NumberBox Grid.Row="1" Grid.Column="1" Text="{x:Bind ViewModel.MaxPreviewCharacters.Value,Mode=TwoWay}"/>
15-
<TextBlock Grid.Row="2" Text="Grep 最大件数"/>
16-
<NumberBox Grid.Row="2" Grid.Column="1" Text="{x:Bind ViewModel.GrepMaxResults.Value,Mode=TwoWay}"/>
10+
<Grid Padding="16" RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="Auto,Auto">
11+
<TextBlock Text="Number of lines to prefetch near the end of the buffer."/>
12+
<NumberBox Grid.Column="1" Text="{x:Bind ViewModel.PrefetchLineCount.Value,Mode=TwoWay}"/>
13+
<TextBlock Grid.Row="1" Text="Number of remaining lines that triggers prefetching."/>
14+
<NumberBox Grid.Row="1" Grid.Column="1" Text="{x:Bind ViewModel.PrefetchThresholdLines.Value,Mode=TwoWay}"/>
15+
<TextBlock Grid.Row="2" Text="Maximum number of lines to keep in memory."/>
16+
<NumberBox Grid.Row="2" Grid.Column="1" Text="{x:Bind ViewModel.MaxLogLineLimit.Value,Mode=TwoWay}"/>
17+
<TextBlock Grid.Row="3" Text="Maximum number of matched results returned by GREP."/>
18+
<NumberBox Grid.Row="3" Grid.Column="1" Text="{x:Bind ViewModel.GrepMaxResults.Value,Mode=TwoWay}"/>
1719
</Grid>
1820
</Page>

RemoteLogViewer.WinUI/Views/Ssh/FileViewer/TextFileViewer.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ private async Task InitializeWebView() {
158158

159159
this._settingsStoreModel.SettingsUpdated.Subscribe(x => {
160160
this.PostWV2("*", "LineStyleChanged", this._tabObjects.CreateCss());
161+
this.PostWV2("*", "SettingsUpdated", new {
162+
prefetchLineCount = this._settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchLineCount,
163+
prefetchThresholdLines = this._settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchThresholdLines,
164+
maxLogLineLimit = this._settingsStoreModel.SettingsModel.TextViewerSettings.MaxLogLineLimit,
165+
});
161166
this.PostWV2("*", "ReloadRequested", null);
162167
this.PostWV2("*", "GrepResultReset", null);
163168
});
@@ -178,6 +183,11 @@ private async Task InitializeWebView() {
178183
pageKey = vm.PageKey,
179184
tabHeader = Path.GetFileName(vm.OpenedFilePath.Value)
180185
});
186+
this.PostWV2("*", "SettingsUpdated", new {
187+
prefetchLineCount = this._settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchLineCount.Value,
188+
prefetchThresholdLines = this._settingsStoreModel.SettingsModel.TextViewerSettings.PrefetchThresholdLines.Value,
189+
maxLogLineLimit = this._settingsStoreModel.SettingsModel.TextViewerSettings.MaxLogLineLimit.Value,
190+
});
181191
this.RegisterViewerVMEvents(vm);
182192
}
183193
}

RemoteLogViewer.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<Folder Name="/SolutionItems/">
3030
<File Path=".editorconfig" />
3131
<File Path=".gitattributes" />
32+
<File Path=".github/workflows/build-web-assets.yml" />
3233
<File Path=".github/workflows/release.yml" />
3334
<File Path=".gitignore" />
3435
<File Path="AGENTS.md" />

0 commit comments

Comments
 (0)