-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathNanoChat.patch
3664 lines (3601 loc) · 150 KB
/
NanoChat.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From d8413f723589550fdfded50a44fcda7e87e1fcf2 Mon Sep 17 00:00:00 2001
From: Vonsant <[email protected]>
Date: Thu, 12 Dec 2024 14:04:23 +0300
Subject: [PATCH 1/3] NanoChat
---
.../UI/AgentIDCardBoundUserInterface.cs | 9 +
.../Access/UI/AgentIDCardWindow.xaml | 4 +
.../Access/UI/AgentIDCardWindow.xaml.cs | 37 ++
.../CartridgeLoader/Cartridges/LogProbeUi.cs | 2 +-
.../Cartridges/LogProbeUiFragment.xaml | 26 +-
.../Cartridges/LogProbeUiFragment.xaml.cs | 109 +++-
.../Cartridges/NanoChatEntry.xaml | 48 ++
.../Cartridges/NanoChatEntry.xaml.cs | 39 ++
.../Cartridges/NanoChatLogEntry.xaml | 21 +
.../Cartridges/NanoChatLogEntry.xaml.cs | 17 +
.../Cartridges/NanoChatMessageBubble.xaml | 55 ++
.../Cartridges/NanoChatMessageBubble.xaml.cs | 62 +++
.../CartridgeLoader/Cartridges/NanoChatUi.cs | 43 ++
.../Cartridges/NanoChatUiFragment.xaml | 167 ++++++
.../Cartridges/NanoChatUiFragment.xaml.cs | 254 +++++++++
.../Cartridges/NewChatPopup.xaml | 52 ++
.../Cartridges/NewChatPopup.xaml.cs | 87 +++
.../_CorvaxNext/NanoChat/NanoChatSystem.cs | 5 +
.../Access/Systems/AgentIDCardSystem.cs | 53 +-
.../Cartridges/LogProbeCartridgeComponent.cs | 7 +
.../Cartridges/LogProbeCartridgeSystem.cs | 16 +-
.../LogProbeCartridgeSystem.NanoChat.cs | 82 +++
.../Cartridges/NanoChatCartridgeComponent.cs | 26 +
.../Cartridges/NanoChatCartridgeSystem.cs | 514 ++++++++++++++++++
.../_CorvaxNext/NanoChat/NanoChatSystem.cs | 130 +++++
.../Access/SharedAgentIDCardSystem.cs | 16 +-
.../Cartridges/LogProbeUiState.cs | 11 +-
.../Cartridges/NanoChatUiMessageEvent.cs | 166 ++++++
.../Cartridges/NanoChatUiState.cs | 30 +
.../NanoChat/NanoChatCardComponent.cs | 52 ++
.../NanoChat/SharedNanoChatSystem.cs | 273 ++++++++++
.../components/agent-id-card-component.ftl | 1 +
.../_corvaxnext/cartridge-loader/nanochat.ftl | 36 ++
.../components/nanochat-card-component.ftl | 5 +
.../components/agent-id-card-component.ftl | 1 +
.../_corvaxnext/cartridge-loader/nanochat.ftl | 36 ++
.../components/nanochat-card-component.ftl | 5 +
.../Entities/Objects/Devices/pda.yml | 11 +
.../Objects/Misc/identification_cards.yml | 3 +
.../Entities/Objects/Devices/cartridges.yml | 23 +-
.../_CorvaxNext/name_identifier_groups.yml | 4 +
.../Interface/VerbIcons/ATTRIBUTION.txt | 2 +
.../_CorvaxNext/Interface/VerbIcons/bell.svg | 5 +
.../Interface/VerbIcons/bell.svg.png | Bin 0 -> 720 bytes
.../Interface/VerbIcons/bell_muted.png | Bin 0 -> 355 bytes
.../Misc/program_icons.rsi/meta.json | 14 +
.../Misc/program_icons.rsi/nanochat.png | Bin 0 -> 725 bytes
.../Devices/cartridge.rsi/cart-chat.png | Bin 0 -> 419 bytes
.../Objects/Devices/cartridge.rsi/meta.json | 5 +-
49 files changed, 2549 insertions(+), 15 deletions(-)
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml.cs
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml.cs
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml.cs
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUi.cs
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NewChatPopup.xaml
create mode 100644 Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NewChatPopup.xaml.cs
create mode 100644 Content.Client/_CorvaxNext/NanoChat/NanoChatSystem.cs
create mode 100644 Content.Server/_CorvaxNext/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.NanoChat.cs
create mode 100644 Content.Server/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatCartridgeComponent.cs
create mode 100644 Content.Server/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatCartridgeSystem.cs
create mode 100644 Content.Server/_CorvaxNext/NanoChat/NanoChatSystem.cs
create mode 100644 Content.Shared/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiMessageEvent.cs
create mode 100644 Content.Shared/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiState.cs
create mode 100644 Content.Shared/_CorvaxNext/NanoChat/NanoChatCardComponent.cs
create mode 100644 Content.Shared/_CorvaxNext/NanoChat/SharedNanoChatSystem.cs
create mode 100644 Resources/Locale/en-US/_corvaxnext/access/components/agent-id-card-component.ftl
create mode 100644 Resources/Locale/en-US/_corvaxnext/cartridge-loader/nanochat.ftl
create mode 100644 Resources/Locale/en-US/_corvaxnext/nanochat/components/nanochat-card-component.ftl
create mode 100644 Resources/Locale/ru-RU/_corvaxnext/access/components/agent-id-card-component.ftl
create mode 100644 Resources/Locale/ru-RU/_corvaxnext/cartridge-loader/nanochat.ftl
create mode 100644 Resources/Locale/ru-RU/_corvaxnext/nanochat/components/nanochat-card-component.ftl
create mode 100644 Resources/Prototypes/_CorvaxNext/name_identifier_groups.yml
create mode 100644 Resources/Textures/_CorvaxNext/Interface/VerbIcons/ATTRIBUTION.txt
create mode 100644 Resources/Textures/_CorvaxNext/Interface/VerbIcons/bell.svg
create mode 100644 Resources/Textures/_CorvaxNext/Interface/VerbIcons/bell.svg.png
create mode 100644 Resources/Textures/_CorvaxNext/Interface/VerbIcons/bell_muted.png
create mode 100644 Resources/Textures/_CorvaxNext/Misc/program_icons.rsi/meta.json
create mode 100644 Resources/Textures/_CorvaxNext/Misc/program_icons.rsi/nanochat.png
create mode 100644 Resources/Textures/_CorvaxNext/Objects/Devices/cartridge.rsi/cart-chat.png
diff --git a/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs b/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
index 050756fcd14..24e9bc7a01d 100644
--- a/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
+++ b/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
@@ -26,8 +26,16 @@ protected override void Open()
_window.OnNameChanged += OnNameChanged;
_window.OnJobChanged += OnJobChanged;
_window.OnJobIconChanged += OnJobIconChanged;
+ _window.OnNumberChanged += OnNumberChanged; // Corvax-Next-PDAChat
}
+ // Corvax-Next-PDAChat-Start
+ private void OnNumberChanged(uint newNumber)
+ {
+ SendMessage(new AgentIDCardNumberChangedMessage(newNumber));
+ }
+ // Corvax-Next-PDAChat-End
+
private void OnNameChanged(string newName)
{
SendMessage(new AgentIDCardNameChangedMessage(newName));
@@ -56,6 +64,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
_window.SetCurrentName(cast.CurrentName);
_window.SetCurrentJob(cast.CurrentJob);
_window.SetAllowedIcons(cast.CurrentJobIconId);
+ _window.SetCurrentNumber(cast.CurrentNumber); // Corvax-Next-PDAChat
}
}
}
diff --git a/Content.Client/Access/UI/AgentIDCardWindow.xaml b/Content.Client/Access/UI/AgentIDCardWindow.xaml
index 7d091e4e165..a61ed2a5ae2 100644
--- a/Content.Client/Access/UI/AgentIDCardWindow.xaml
+++ b/Content.Client/Access/UI/AgentIDCardWindow.xaml
@@ -6,6 +6,10 @@
<LineEdit Name="NameLineEdit" />
<Label Name="CurrentJob" Text="{Loc 'agent-id-card-current-job'}" />
<LineEdit Name="JobLineEdit" />
+ <!-- Corvax-Next-PDAChat-Start - Add NanoChat number field -->
+ <Label Name="CurrentNumber" Text="{Loc 'agent-id-card-current-number'}" />
+ <LineEdit Name="NumberLineEdit" PlaceHolder="#0000" />
+ <!-- Corvax-Next-PDAChat-End- -->
<Label Text="{Loc 'agent-id-card-job-icon-label'}"/>
<GridContainer Name="IconGrid" Columns="10">
<!-- Job icon buttons are generated in the code -->
diff --git a/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs b/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
index 320bb88a67e..14df0ff7ef8 100644
--- a/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
+++ b/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
@@ -20,9 +20,13 @@ public sealed partial class AgentIDCardWindow : DefaultWindow
private readonly SpriteSystem _spriteSystem;
private const int JobIconColumnCount = 10;
+
+ private const int MaxNumberLength = 4; // Corvax-Next-PDAChat - Same as NewChatPopup
public event Action<string>? OnNameChanged;
public event Action<string>? OnJobChanged;
+
+ public event Action<uint>? OnNumberChanged; // Corvax-Next-PDAChat - Add event for number changes
public event Action<ProtoId<JobIconPrototype>>? OnJobIconChanged;
@@ -35,9 +39,42 @@ public AgentIDCardWindow()
NameLineEdit.OnTextEntered += e => OnNameChanged?.Invoke(e.Text);
NameLineEdit.OnFocusExit += e => OnNameChanged?.Invoke(e.Text);
+ // Corvax-Next-PDAChat-Start
JobLineEdit.OnTextEntered += e => OnJobChanged?.Invoke(e.Text);
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
+
+ // Corvax-Next-PDAChat - Add handlers for number changes
+ NumberLineEdit.OnTextEntered += OnNumberEntered;
+ NumberLineEdit.OnFocusExit += OnNumberEntered;
+
+ // Corvax-Next-PDAChat - Filter to only allow digits
+ NumberLineEdit.OnTextChanged += args =>
+ {
+ if (args.Text.Length > MaxNumberLength)
+ {
+ NumberLineEdit.Text = args.Text[..MaxNumberLength];
+ }
+
+ // Filter to digits only
+ var newText = string.Concat(args.Text.Where(char.IsDigit));
+ if (newText != args.Text)
+ NumberLineEdit.Text = newText;
+ };
+ }
+
+ // Corvax-Next-PDAChat - Add number validation and event
+ private void OnNumberEntered(LineEdit.LineEditEventArgs args)
+ {
+ if (uint.TryParse(args.Text, out var number) && number > 0)
+ OnNumberChanged?.Invoke(number);
+ }
+
+ // Corvax-Next-PDAChat - Add setter for current number
+ public void SetCurrentNumber(uint? number)
+ {
+ NumberLineEdit.Text = number?.ToString("D4") ?? "";
}
+ // Corvax-Next-PDAChat-End
public void SetAllowedIcons(string currentJobIconId)
{
diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs b/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
index d28d3228c94..7ece0abcbd9 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
@@ -23,6 +23,6 @@ public override void UpdateState(BoundUserInterfaceState state)
if (state is not LogProbeUiState logProbeUiState)
return;
- _fragment?.UpdateState(logProbeUiState.PulledLogs);
+ _fragment?.UpdateState(logProbeUiState); // Corvax-Next-PDAChat - just take the state
}
}
diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
index d12fb55cdce..7c571e08f9b 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
@@ -9,10 +9,28 @@
BorderColor="#5a5a5a"
BorderThickness="0 0 0 1"/>
</PanelContainer.PanelOverride>
- <BoxContainer Orientation="Horizontal" Margin="4 8">
- <Label Align="Right" SetWidth="26" ClipText="True" Text="{Loc 'log-probe-label-number'}"/>
- <Label Align="Center" SetWidth="100" ClipText="True" Text="{Loc 'log-probe-label-time'}"/>
- <Label Align="Left" SetWidth="390" ClipText="True" Text="{Loc 'log-probe-label-accessor'}"/>
+ <BoxContainer Orientation="Vertical" Margin="4 8">
+ <!-- Corvax-Next-PDAChat-Start - Add title label -->
+ <Label Name="TitleLabel"
+ Text="{Loc 'log-probe-header-access'}"
+ StyleClasses="LabelHeading"
+ HorizontalAlignment="Center"
+ Margin="0 0 0 8"/>
+
+ <!-- Add card number display -->
+ <Label Name="CardNumberLabel"
+ StyleClasses="LabelSubText"
+ HorizontalAlignment="Center"
+ Margin="0 0 0 8"
+ Visible="False"/>
+
+ <!-- Adjust column headers -->
+ <BoxContainer Orientation="Horizontal">
+ <Label Align="Right" SetWidth="26" ClipText="True" Text="{Loc 'log-probe-label-number'}"/>
+ <Label Align="Center" SetWidth="100" ClipText="True" Text="{Loc 'log-probe-label-time'}"/>
+ <Label Name="ContentLabel" Align="Left" SetWidth="390" ClipText="True" Text="{Loc 'log-probe-label-accessor'}"/>
+ </BoxContainer>
+ <!-- Corvax-Next-PDAChat-End -->
</BoxContainer>
</PanelContainer>
<ScrollContainer VerticalExpand="True" HScrollEnabled="True">
diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
index b22e0bc1964..a16c92a066c 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
@@ -1,4 +1,7 @@
-using Content.Shared.CartridgeLoader.Cartridges;
+using System.Linq;
+using Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+using Content.Shared.CartridgeLoader.Cartridges;
+using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
@@ -13,10 +16,112 @@ public LogProbeUiFragment()
RobustXamlLoader.Load(this);
}
- public void UpdateState(List<PulledAccessLog> logs)
+ // Corvax-Next-PDAChat-Start - Update to handle both types of data
+ public void UpdateState(LogProbeUiState state)
{
ProbedDeviceContainer.RemoveAllChildren();
+ if (state.NanoChatData != null)
+ {
+ SetupNanoChatView(state.NanoChatData.Value);
+ DisplayNanoChatData(state.NanoChatData.Value);
+ }
+ else
+ {
+ SetupAccessLogView();
+ if (state.PulledLogs.Count > 0)
+ DisplayAccessLogs(state.PulledLogs);
+ }
+ }
+
+ private void SetupNanoChatView(NanoChatData data)
+ {
+ TitleLabel.Text = Loc.GetString("log-probe-header-nanochat");
+ ContentLabel.Text = Loc.GetString("log-probe-label-message");
+
+ // Show card info if available
+ var cardInfo = new List<string>();
+ if (data.CardNumber != null)
+ cardInfo.Add(Loc.GetString("log-probe-card-number", ("number", $"#{data.CardNumber:D4}")));
+
+ // Add recipient count
+ cardInfo.Add(Loc.GetString("log-probe-recipients", ("count", data.Recipients.Count)));
+
+ CardNumberLabel.Text = string.Join(" | ", cardInfo);
+ CardNumberLabel.Visible = true;
+ }
+
+ private void SetupAccessLogView()
+ {
+ TitleLabel.Text = Loc.GetString("log-probe-header-access");
+ ContentLabel.Text = Loc.GetString("log-probe-label-accessor");
+ CardNumberLabel.Visible = false;
+ }
+
+ private void DisplayNanoChatData(NanoChatData data)
+ {
+ // First add a recipient list entry
+ var recipientsList = Loc.GetString("log-probe-recipient-list") + "\n" + string.Join("\n",
+ data.Recipients.Values
+ .OrderBy(r => r.Name)
+ .Select(r => $" {r.Name}" +
+ (string.IsNullOrEmpty(r.JobTitle) ? "" : $" ({r.JobTitle})") +
+ $" | #{r.Number:D4}"));
+
+ var recipientsEntry = new LogProbeUiEntry(0, "---", recipientsList);
+ ProbedDeviceContainer.AddChild(recipientsEntry);
+
+ var count = 1;
+ foreach (var (partnerId, messages) in data.Messages)
+ {
+ // Show only successfully delivered incoming messages
+ var incomingMessages = messages
+ .Where(msg => msg.SenderId == partnerId && !msg.DeliveryFailed)
+ .OrderByDescending(msg => msg.Timestamp);
+
+ foreach (var msg in incomingMessages)
+ {
+ var messageText = Loc.GetString("log-probe-message-format",
+ ("sender", $"#{msg.SenderId:D4}"),
+ ("recipient", $"#{data.CardNumber:D4}"),
+ ("content", msg.Content));
+
+ var entry = new NanoChatLogEntry(
+ count,
+ TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(),
+ messageText);
+
+ ProbedDeviceContainer.AddChild(entry);
+ count++;
+ }
+
+ // Show only successfully delivered outgoing messages
+ var outgoingMessages = messages
+ .Where(msg => msg.SenderId == data.CardNumber && !msg.DeliveryFailed)
+ .OrderByDescending(msg => msg.Timestamp);
+
+ foreach (var msg in outgoingMessages)
+ {
+ var messageText = Loc.GetString("log-probe-message-format",
+ ("sender", $"#{msg.SenderId:D4}"),
+ ("recipient", $"#{partnerId:D4}"),
+ ("content", msg.Content));
+
+ var entry = new NanoChatLogEntry(
+ count,
+ TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(),
+ messageText);
+
+ ProbedDeviceContainer.AddChild(entry);
+ count++;
+ }
+ }
+ }
+ // Corvax-Next-PDAChat-End
+
+ // Corvax-Next-PDAChat - Handle this in a separate method
+ private void DisplayAccessLogs(List<PulledAccessLog> logs)
+ {
//Reverse the list so the oldest entries appear at the bottom
logs.Reverse();
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml
new file mode 100644
index 00000000000..ac610343682
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml
@@ -0,0 +1,48 @@
+<BoxContainer
+ xmlns="https://spacestation14.io"
+ xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
+ HorizontalExpand="True">
+ <Button Name="ChatButton"
+ StyleClasses="ButtonSquare"
+ HorizontalExpand="True"
+ MaxSize="137 64"
+ Margin="0 1">
+ <BoxContainer Orientation="Horizontal"
+ HorizontalExpand="True"
+ VerticalExpand="True"
+ MinWidth="132"
+ Margin="6 4"
+ VerticalAlignment="Center">
+ <!-- Unread indicator dot -->
+ <PanelContainer Name="UnreadIndicator"
+ MinSize="8 8"
+ MaxSize="8 8"
+ VerticalAlignment="Center"
+ Margin="0 0 6 0">
+ <PanelContainer.PanelOverride>
+ <graphics:StyleBoxFlat
+ BackgroundColor="#17c622"
+ BorderColor="#0f7a15" />
+ </PanelContainer.PanelOverride>
+ </PanelContainer>
+
+ <!-- Text container -->
+ <BoxContainer Orientation="Vertical"
+ HorizontalExpand="True"
+ VerticalExpand="True"
+ VerticalAlignment="Center">
+ <RichTextLabel Name="NameLabel"
+ StyleClasses="LabelHeading"
+ HorizontalExpand="True"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Margin="0 -2 0 0" />
+ <Label Name="JobLabel"
+ StyleClasses="LabelSubText"
+ HorizontalExpand="True"
+ ClipText="False"
+ HorizontalAlignment="Center" />
+ </BoxContainer>
+ </BoxContainer>
+ </Button>
+</BoxContainer>
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml.cs b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml.cs
new file mode 100644
index 00000000000..a055c04879d
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatEntry.xaml.cs
@@ -0,0 +1,39 @@
+using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+
+[GenerateTypedNameReferences]
+public sealed partial class NanoChatEntry : BoxContainer
+{
+ public event Action<uint>? OnPressed;
+ private uint _number;
+ private Action<EventArgs>? _pressHandler;
+
+ public NanoChatEntry()
+ {
+ RobustXamlLoader.Load(this);
+ }
+
+ public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelected)
+ {
+ // Remove old handler if it exists
+ if (_pressHandler != null)
+ ChatButton.OnPressed -= _pressHandler;
+
+ _number = number;
+
+ // Create and store new handler
+ _pressHandler = _ => OnPressed?.Invoke(_number);
+ ChatButton.OnPressed += _pressHandler;
+
+ NameLabel.Text = recipient.Name;
+ JobLabel.Text = recipient.JobTitle ?? "";
+ JobLabel.Visible = !string.IsNullOrEmpty(recipient.JobTitle);
+ UnreadIndicator.Visible = recipient.HasUnread;
+
+ ChatButton.ModulateSelfOverride = isSelected ? NanoChatMessageBubble.OwnMessageColor : null;
+ }
+}
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml
new file mode 100644
index 00000000000..d3014fd337f
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml
@@ -0,0 +1,21 @@
+<BoxContainer xmlns="https://spacestation14.io"
+ xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
+ Margin="4"
+ Orientation="Vertical">
+ <BoxContainer Orientation="Horizontal">
+ <Label Name="NumberLabel"
+ Align="Right"
+ SetWidth="26"
+ ClipText="True" />
+ <Label Name="TimeLabel"
+ Align="Center"
+ SetWidth="100"
+ ClipText="True" />
+ <Label Name="MessageLabel"
+ Align="Left"
+ MinWidth="390"
+ HorizontalExpand="True"
+ ClipText="False" />
+ </BoxContainer>
+ <customControls:HSeparator Margin="0 5 0 5" />
+</BoxContainer>
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml.cs b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml.cs
new file mode 100644
index 00000000000..50aadc4b62c
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatLogEntry.xaml.cs
@@ -0,0 +1,17 @@
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+
+[GenerateTypedNameReferences]
+public sealed partial class NanoChatLogEntry : BoxContainer
+{
+ public NanoChatLogEntry(int number, string time, string message)
+ {
+ RobustXamlLoader.Load(this);
+ NumberLabel.Text = number.ToString();
+ TimeLabel.Text = time;
+ MessageLabel.Text = message;
+ }
+}
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml
new file mode 100644
index 00000000000..9b2390b6ae0
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml
@@ -0,0 +1,55 @@
+<cartridges:NanoChatMessageBubble
+ xmlns="https://spacestation14.io"
+ xmlns:cartridges="clr-namespace:Content.Client._CorvaxNext.CartridgeLoader.Cartridges"
+ xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
+ HorizontalExpand="True">
+
+ <BoxContainer Name="MessageContainer"
+ Orientation="Horizontal"
+ HorizontalExpand="True">
+ <!-- Left spacer for other's messages -->
+ <Control Name="LeftSpacer"
+ MinSize="12 0" />
+
+ <!-- Message panel -->
+ <BoxContainer Name="MessageBox"
+ Orientation="Vertical"
+ MaxWidth="320"
+ HorizontalExpand="True">
+ <PanelContainer Name="MessagePanel"
+ MaxWidth="320"
+ HorizontalExpand="True">
+ <PanelContainer.PanelOverride>
+ <graphics:StyleBoxFlat
+ ContentMarginLeftOverride="10"
+ ContentMarginRightOverride="10"
+ ContentMarginTopOverride="6"
+ ContentMarginBottomOverride="6"
+ BorderThickness="1">
+ <!-- Colors set in code based on message sender -->
+ </graphics:StyleBoxFlat>
+ </PanelContainer.PanelOverride>
+
+ <RichTextLabel Name="MessageText"
+ HorizontalExpand="True" />
+ </PanelContainer>
+
+ <!-- Delivery failed text -->
+ <Label Name="DeliveryFailedLabel"
+ Text="{Loc nano-chat-delivery-failed}"
+ StyleClasses="LabelSmall"
+ HorizontalExpand="True"
+ HorizontalAlignment="Right"
+ Margin="10 2 10 0"
+ Visible="False" />
+ </BoxContainer>
+
+ <!-- Right spacer for own messages -->
+ <Control Name="RightSpacer"
+ MinSize="12 0" />
+
+ <!-- Flexible space for alignment -->
+ <Control Name="FlexSpace"
+ HorizontalExpand="True" />
+ </BoxContainer>
+</cartridges:NanoChatMessageBubble>
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml.cs b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml.cs
new file mode 100644
index 00000000000..91eb41c7751
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatMessageBubble.xaml.cs
@@ -0,0 +1,62 @@
+using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges;
+using Robust.Client.AutoGenerated;
+using Robust.Client.Graphics;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+
+[GenerateTypedNameReferences]
+public sealed partial class NanoChatMessageBubble : BoxContainer
+{
+ public static readonly Color OwnMessageColor = Color.FromHex("#173717d9"); // Dark green
+ public static readonly Color OtherMessageColor = Color.FromHex("#252525d9"); // Dark gray
+ public static readonly Color BorderColor = Color.FromHex("#40404066"); // Subtle border
+ public static readonly Color TextColor = Color.FromHex("#dcdcdc"); // Slightly softened white
+ public static readonly Color ErrorColor = Color.FromHex("#cc3333"); // Red
+
+ public NanoChatMessageBubble()
+ {
+ RobustXamlLoader.Load(this);
+ }
+
+ public void SetMessage(NanoChatMessage message, bool isOwnMessage)
+ {
+ if (MessagePanel.PanelOverride is not StyleBoxFlat)
+ return;
+
+ // Configure message appearance
+ var style = (StyleBoxFlat)MessagePanel.PanelOverride;
+ style.BackgroundColor = isOwnMessage ? OwnMessageColor : OtherMessageColor;
+ style.BorderColor = BorderColor;
+
+ // Set message content
+ MessageText.Text = message.Content;
+ MessageText.Modulate = TextColor;
+
+ // Show delivery failed text if needed (only for own messages)
+ DeliveryFailedLabel.Visible = isOwnMessage && message.DeliveryFailed;
+ if (DeliveryFailedLabel.Visible)
+ DeliveryFailedLabel.Modulate = ErrorColor;
+
+ // For own messages: FlexSpace -> MessagePanel -> RightSpacer
+ // For other messages: LeftSpacer -> MessagePanel -> FlexSpace
+ MessageContainer.RemoveAllChildren();
+
+ // fuuuuuck
+ MessageBox.Parent?.RemoveChild(MessageBox);
+
+ if (isOwnMessage)
+ {
+ MessageContainer.AddChild(FlexSpace);
+ MessageContainer.AddChild(MessageBox);
+ MessageContainer.AddChild(RightSpacer);
+ }
+ else
+ {
+ MessageContainer.AddChild(LeftSpacer);
+ MessageContainer.AddChild(MessageBox);
+ MessageContainer.AddChild(FlexSpace);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUi.cs b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUi.cs
new file mode 100644
index 00000000000..412ce4191e2
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUi.cs
@@ -0,0 +1,43 @@
+using Content.Client.UserInterface.Fragments;
+using Content.Shared.CartridgeLoader;
+using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges;
+using Robust.Client.UserInterface;
+
+namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+
+public sealed partial class NanoChatUi : UIFragment
+{
+ private NanoChatUiFragment? _fragment;
+
+ public override Control GetUIFragmentRoot()
+ {
+ return _fragment!;
+ }
+
+ public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
+ {
+ _fragment = new NanoChatUiFragment();
+
+ _fragment.OnMessageSent += (type, number, content, job) =>
+ {
+ SendNanoChatUiMessage(type, number, content, job, userInterface);
+ };
+ }
+
+ public override void UpdateState(BoundUserInterfaceState state)
+ {
+ if (state is NanoChatUiState cast)
+ _fragment?.UpdateState(cast);
+ }
+
+ private static void SendNanoChatUiMessage(NanoChatUiMessageType type,
+ uint? number,
+ string? content,
+ string? job,
+ BoundUserInterface userInterface)
+ {
+ var nanoChatMessage = new NanoChatUiMessageEvent(type, number, content, job);
+ var message = new CartridgeUiMessage(nanoChatMessage);
+ userInterface.SendMessage(message);
+ }
+}
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml
new file mode 100644
index 00000000000..e20595a6974
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml
@@ -0,0 +1,167 @@
+<cartridges:NanoChatUiFragment
+ xmlns="https://spacestation14.io"
+ xmlns:cartridges="clr-namespace:Content.Client._CorvaxNext.CartridgeLoader.Cartridges"
+ xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
+ xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+ Orientation="Vertical"
+ HorizontalExpand="True"
+ VerticalExpand="True"
+ Margin="5">
+
+ <!-- Main container that fills the entire PDA screen -->
+ <BoxContainer Orientation="Vertical"
+ HorizontalExpand="True"
+ VerticalExpand="True">
+ <!-- Header with app title and new chat button -->
+ <controls:StripeBack MinSize="48 48"
+ VerticalExpand="False">
+ <BoxContainer Orientation="Horizontal"
+ HorizontalExpand="True"
+ Margin="0">
+ <TextureRect Name="AppIcon"
+ TexturePath="/Textures/Interface/Nano/ntlogo.svg.png"
+ Stretch="KeepAspectCentered"
+ VerticalAlignment="Center"
+ MinSize="32 32"
+ Margin="8 0 0 0" />
+ <Label Text="{Loc nano-chat-title}"
+ StyleClasses="LabelHeading"
+ HorizontalExpand="True"
+ Margin="8 0"
+ VerticalAlignment="Center" />
+ <Label Name="OwnNumberLabel"
+ Text="#0000"
+ StyleClasses="LabelSubText"
+ VerticalAlignment="Center"
+ Margin="0 0 8 0" />
+ <Button Name="DeleteChatButton"
+ MaxSize="32 32"
+ Visible="False"
+ StyleClasses="OpenBoth"
+ Margin="0 0 4 0"
+ ToolTip="{Loc nano-chat-delete}">
+ <TextureRect StyleClasses="ButtonSquare"
+ TexturePath="/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png"
+ Stretch="KeepAspectCentered"
+ MinSize="18 18" />
+ </Button>
+ <Button Name="MuteButton"
+ MaxSize="32 32"
+ StyleClasses="OpenBoth"
+ Margin="0 0 4 0"
+ ToolTip="{Loc nano-chat-toggle-mute}">
+ <Control HorizontalExpand="True" VerticalExpand="True">
+ <TextureRect Name="BellIcon"
+ StyleClasses="ButtonSquare"
+ TexturePath="/Textures/_CorvaxNext/Interface/VerbIcons/bell.svg.png"
+ Stretch="KeepAspectCentered"
+ MinSize="18 18" />
+ <TextureRect Name="BellMutedIcon"
+ StyleClasses="ButtonSquare"
+ TexturePath="/Textures/_CorvaxNext/Interface/VerbIcons/bell_muted.png"
+ Stretch="KeepAspectCentered"
+ Visible="False"
+ MinSize="18 18" />
+ </Control>
+ </Button>
+ <Button Name="NewChatButton"
+ Text="+"
+ MinSize="32 32"
+ MaxSize="32 32"
+ Margin="0 0 4 0"
+ StyleClasses="OpenBoth"
+ ToolTip="{Loc nano-chat-new-chat}" />
+ </BoxContainer>
+ </controls:StripeBack>
+
+ <!-- Main content split -->
+ <BoxContainer Orientation="Horizontal"
+ VerticalExpand="True"
+ HorizontalExpand="True"
+ Margin="0 5 0 0">
+ <!-- Left panel: Chat list -->
+ <PanelContainer StyleClasses="AngleRect"
+ VerticalExpand="True"
+ MaxWidth="150">
+ <ScrollContainer VerticalExpand="True"
+ MinWidth="145"
+ HorizontalExpand="True"
+ HScrollEnabled="False">
+ <BoxContainer Name="ChatList"
+ Orientation="Vertical"
+ VerticalExpand="True"
+ HorizontalExpand="True"
+ Margin="4">
+ <!-- Chat entries will be added here dynamically -->
+ <Label Name="NoChatsLabel"
+ Text="{Loc nano-chat-no-chats}"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ StyleClasses="LabelSubText" />
+ </BoxContainer>
+ </ScrollContainer>
+ </PanelContainer>
+
+ <customControls:VSeparator Margin="3 0" />
+
+ <!-- Right panel: Current chat -->
+ <PanelContainer StyleClasses="AngleRect"
+ VerticalExpand="True"
+ HorizontalExpand="True">
+ <BoxContainer Orientation="Vertical"
+ VerticalExpand="True"
+ HorizontalExpand="True">
+ <!-- Messages area with centered "select chat" label -->
+ <BoxContainer Name="MessageArea"
+ Orientation="Vertical"
+ VerticalExpand="True"
+ HorizontalExpand="True"
+ Margin="0 0 0 4">
+ <Label Name="CurrentChatName"
+ Text="{Loc nano-chat-select-chat}"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ VerticalExpand="True" />
+ <ScrollContainer Name="MessagesScroll"
+ VerticalExpand="True"
+ HorizontalExpand="True"
+ Visible="False">
+ <BoxContainer Name="MessageList"
+ Orientation="Vertical"
+ VerticalExpand="True"
+ HorizontalExpand="True" />
+ </ScrollContainer>
+ </BoxContainer>
+
+ <!-- Message input -->
+ <BoxContainer Name="MessageInputContainer"
+ Orientation="Horizontal"
+ HorizontalExpand="True"
+ Margin="0 4 0 0"
+ Visible="False">
+ <!-- Character count -->
+ <Label Name="CharacterCount"
+ HorizontalAlignment="Right"
+ StyleClasses="LabelSubText"
+ Margin="0 0 4 2"
+ Visible="False" />
+ <!-- Input row -->
+ <LineEdit Name="MessageInput"
+ PlaceHolder="{Loc nano-chat-message-placeholder}"
+ HorizontalExpand="True"
+ StyleClasses="OpenRight" />
+ <Button Name="SendButton"
+ MinSize="32 32"
+ Disabled="True"
+ StyleClasses="OpenLeft"
+ Margin="4 0 0 0">
+ <TextureRect StyleClasses="ButtonSquare"
+ TexturePath="/Textures/Interface/Nano/triangle_right.png"
+ Stretch="KeepAspectCentered" />
+ </Button>
+ </BoxContainer>
+ </BoxContainer>
+ </PanelContainer>
+ </BoxContainer>
+ </BoxContainer>
+</cartridges:NanoChatUiFragment>
\ No newline at end of file
diff --git a/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs
new file mode 100644
index 00000000000..ad3d62f0447
--- /dev/null
+++ b/Content.Client/_CorvaxNext/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs
@@ -0,0 +1,254 @@
+using System.Linq;
+using System.Numerics;
+using Content.Shared._CorvaxNext.CartridgeLoader.Cartridges;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using Robust.Client.UserInterface;
+using Robust.Shared.Timing;
+
+namespace Content.Client._CorvaxNext.CartridgeLoader.Cartridges;
+
+[GenerateTypedNameReferences]
+public sealed partial class NanoChatUiFragment : BoxContainer
+{
+ [Dependency] private readonly IGameTiming _timing = default!;
+
+ private const int MaxMessageLength = 256;
+
+ private readonly NewChatPopup _newChatPopup;
+ private uint? _currentChat;
+ private uint? _pendingChat;
+ private uint _ownNumber;
+ private bool _notificationsMuted;
+ private Dictionary<uint, NanoChatRecipient> _recipients = new();
+ private Dictionary<uint, List<NanoChatMessage>> _messages = new();
+
+ public event Action<NanoChatUiMessageType, uint?, string?, string?>? OnMessageSent;
+
+ public NanoChatUiFragment()
+ {
+ IoCManager.InjectDependencies(this);
+ RobustXamlLoader.Load(this);
+
+ _newChatPopup = new NewChatPopup();
+ SetupEventHandlers();
+ }
+
+ private void SetupEventHandlers()
+ {
+ _newChatPopup.OnChatCreated += (number, name, job) =>
+ {
+ OnMessageSent?.Invoke(NanoChatUiMessageType.NewChat, number, name, job);
+ };
+
+ NewChatButton.OnPressed += _ =>
+ {
+ _newChatPopup.ClearInputs();
+ _newChatPopup.OpenCentered();
+ };
+
+ MuteButton.OnPressed += _ =>
+ {
+ _notificationsMuted = !_notificationsMuted;
+ UpdateMuteButton();
+ OnMessageSent?.Invoke(NanoChatUiMessageType.ToggleMute, null, null, null);
+ };
+
+ MessageInput.OnTextChanged += args =>
+ {
+ var length = args.Text.Length;
+ var isValid = !string.IsNullOrWhiteSpace(args.Text) &&
+ length <= MaxMessageLength &&
+ (_currentChat != null || _pendingChat != null);
+
+ SendButton.Disabled = !isValid;
+
+ // Show character count when over limit
+ CharacterCount.Visible = length > MaxMessageLength;
+ if (length > MaxMessageLength)
+ {
+ CharacterCount.Text = Loc.GetString("nano-chat-message-too-long",
+ ("current", length),
+ ("max", MaxMessageLength));
+ CharacterCount.StyleClasses.Add("LabelDanger");
+ }
+ };
+
+ SendButton.OnPressed += _ => SendMessage();
+ DeleteChatButton.OnPressed += _ => DeleteCurrentChat();
+ }
+
+ private void SendMessage()
+ {
+ var activeChat = _pendingChat ?? _currentChat;
+ if (activeChat == null || string.IsNullOrWhiteSpace(MessageInput.Text))
+ return;
+
+ var messageContent = MessageInput.Text;
+
+ // Add predicted message
+ var predictedMessage = new NanoChatMessage(
+ _timing.CurTime,
+ messageContent,
+ _ownNumber
+ );
+
+ if (!_messages.TryGetValue(activeChat.Value, out var value))
+ {
+ value = new List<NanoChatMessage>();
+ _messages[activeChat.Value] = value;
+ }
+
+ value.Add(predictedMessage);
+
+ // Update UI with predicted message
+ UpdateMessages(_messages);
+
+ // Send message event
+ OnMessageSent?.Invoke(NanoChatUiMessageType.SendMessage, activeChat, messageContent, null);
+
+ // Clear input
+ MessageInput.Text = string.Empty;
+ SendButton.Disabled = true;
+ }