Skip to content
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## [Unreleased]

### Added
- **Funplay > MCP Settings > Recent Activity** now includes a per-project **Expand all entries by default** preference. It is enabled by default for new and previously unconfigured projects, persists across Editor reloads (including an explicit off choice), and updates the open panel immediately without restarting MCP. Manually expanded or collapsed rows retain their state until the panel is reopened.

### Changed
- The MCP Server window's Recent Activity panel supports collapsing entries to one-line summaries by clicking their headers, and reopening them from either the header or summary. With **Expand all entries by default** disabled, history is collapsed and only the latest result expands automatically; manually expanded or collapsed rows keep their state as new entries arrive. Summaries resize with the panel's available width in both directions, and hovering either the header or summary consistently shows the same formatted, multi-line detail text.

- Collapsed summaries use the human-readable formatted result instead of raw JSON and retain text beyond the compact resource summary's 200-character limit, while keeping the existing 4,000-character display bound. Plain-text results use that same display budget.
- Detail controls and screenshot textures are created only when a row expands and released when it collapses, is cleared, or is evicted. The panel mirrors the activity log's bounded capacity, and queued callbacks cannot resurrect cleared rows or duplicate rows after a rebuild.

### Pull requests and issues
- [PR #57](https://github.com/FunplayAI/funplay-unity-mcp/pull/57): collapsible Recent Activity, with a persistent expand-all preference, readable summaries, lazy detail loading, resource cleanup, and Editor UI regression tests.
- No GitHub issues were closed by these changes.

### Contributors
- Thanks [@dehuaichendragonplus](https://github.com/dehuaichendragonplus) for PR #57.

## [0.6.6] - 2026-09-07

### Added
Expand Down
267 changes: 222 additions & 45 deletions Editor/MCP/Server/FunplayMCPRecentActivityPanel.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Editor/MCP/Server/FunplayMCPWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void BuildUI()
BuildUI)
.AddTo(mainContainer);

_activityPanel = new FunplayMCPRecentActivityPanel(_mcpServer);
_activityPanel = new FunplayMCPRecentActivityPanel(_mcpServer, _settingsController);
_activityPanel.AddTo(mainContainer);
}

Expand Down
36 changes: 33 additions & 3 deletions Editor/MCP/Server/FunplayPluginSettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Funplay.Editor.MCP.Server
internal class FunplayPluginSettingsWindow : EditorWindow
{
private ISettingsController _settingsController;
private Toggle _recentActivityExpandedToggle;
private Toggle _debugLoggingToggle;
private Label _debugStatusLabel;

Expand All @@ -32,6 +33,8 @@ public static void ShowWindow()

public void CreateGUI()
{
if (_settingsController != null)
_settingsController.OnSettingsChanged -= RefreshStatus;
_settingsController = RootScopeServices.Services?.GetService(typeof(ISettingsController))
as ISettingsController;

Expand Down Expand Up @@ -68,17 +71,41 @@ private void BuildUI()
title.style.marginBottom = 4;
rootVisualElement.Add(title);

var hint = new Label("Project-level settings for the Funplay Unity MCP plugin. Safety checks and debug logging are stored per project.");
var hint = new Label("Project-level settings for the Funplay Unity MCP plugin. Preferences are saved per project.");
hint.style.fontSize = 11;
hint.style.color = new Color(0.65f, 0.65f, 0.65f);
hint.style.whiteSpace = WhiteSpace.Normal;
hint.style.marginBottom = 10;
rootVisualElement.Add(hint);

var content = new ScrollView(ScrollViewMode.Vertical) { name = "mcp-settings-scroll" };
content.style.flexGrow = 1;
content.style.minHeight = 0;
rootVisualElement.Add(content);

var safetySection = CreateSection();
safetySection.style.marginBottom = 8;
FunplayMCPSafetyPanel.AddTo(safetySection, _settingsController);
rootVisualElement.Add(safetySection);
content.Add(safetySection);

var activitySection = CreateSection();
activitySection.style.marginBottom = 8;
activitySection.Add(CreateSectionHeader("Recent Activity"));
_recentActivityExpandedToggle = new Toggle("Expand all entries by default")
{
name = "recent-activity-expanded-by-default"
};
_recentActivityExpandedToggle.style.marginBottom = 5;
_recentActivityExpandedToggle.labelElement.style.whiteSpace = WhiteSpace.Normal;
_recentActivityExpandedToggle.labelElement.style.flexShrink = 1;
_recentActivityExpandedToggle.SetValueWithoutNotify(_settingsController.MCPRecentActivityExpandedByDefault);
_recentActivityExpandedToggle.RegisterValueChangedCallback(evt =>
_settingsController.MCPRecentActivityExpandedByDefault = evt.newValue);
activitySection.Add(_recentActivityExpandedToggle);
activitySection.Add(CreateHint(
"On: expand all entries. Off: collapse history and expand only the latest entry. " +
"Applies immediately; manually expanded or collapsed entries keep your choice until the panel is reopened."));
content.Add(activitySection);

var debugSection = CreateSection();
debugSection.Add(CreateSectionHeader("Debug"));
Expand All @@ -96,7 +123,7 @@ private void BuildUI()
_debugStatusLabel = CreateHint(string.Empty);
debugSection.Add(_debugStatusLabel);

rootVisualElement.Add(debugSection);
content.Add(debugSection);
RefreshStatus();
}

Expand All @@ -105,6 +132,8 @@ private void RefreshStatus()
if (_settingsController == null)
return;

_recentActivityExpandedToggle?.SetValueWithoutNotify(_settingsController.MCPRecentActivityExpandedByDefault);

var enabled = _settingsController.PluginDebugLoggingEnabled;
if (_debugLoggingToggle != null)
_debugLoggingToggle.SetValueWithoutNotify(enabled);
Expand All @@ -123,6 +152,7 @@ private void RefreshStatus()
private static VisualElement CreateSection()
{
var section = new VisualElement();
section.style.flexShrink = 0;
section.style.backgroundColor = new Color(0.14f, 0.14f, 0.14f);
section.style.borderTopLeftRadius = 4;
section.style.borderTopRightRadius = 4;
Expand Down
7 changes: 6 additions & 1 deletion Editor/MCP/Server/MCPInteractionLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ internal class MCPInteractionLog
private readonly object _lock = new object();

public event Action<MCPLogEntry> OnEntryAdded;
internal int Capacity => _buffer.Length;

public MCPInteractionLog(int capacity = 200)
{
Expand All @@ -57,7 +58,11 @@ public void Add(string toolName, MCPToolCallStatus status, string resultSummary)
var compactSummary = imageDataUri != null
? "Screenshot captured successfully."
: CreateCompactSummary(resultSummary);
var displayResult = compactSummary;
// Keep the compact resource/log summary bounded at 200 characters, but do not
// irreversibly truncate the panel's plain-text display at that smaller limit.
var displayResult = imageDataUri != null
? compactSummary
: TruncateDisplayResult(resultSummary ?? "");
var isJsonResult = false;

if (imageDataUri == null && TryFormatJsonForDisplay(resultSummary, out var formattedJson))
Expand Down
1 change: 1 addition & 0 deletions Editor/Settings/ISettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal interface ISettingsController
bool ExecuteCodeStrictFilesystemSafetyEnabled { get; set; }
bool ExecuteCodeProjectNamespaceInjectionEnabled { get; set; }
bool PluginDebugLoggingEnabled { get; set; }
bool MCPRecentActivityExpandedByDefault { get; set; }
bool MCPBrokerModeEnabled { get; set; }
string MCPBrokerMonoPath { get; set; }

Expand Down
27 changes: 27 additions & 0 deletions Editor/Settings/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal class SettingsController : ISettingsController
private const bool DefaultExecuteCodeStrictFilesystemSafetyEnabled = true;
private const bool DefaultExecuteCodeProjectNamespaceInjectionEnabled = false;
private const bool DefaultPluginDebugLoggingEnabled = false;
private const bool DefaultMCPRecentActivityExpandedByDefault = true;
private const bool DefaultMCPBrokerModeEnabled = false;

private readonly string _settingsPath;
Expand Down Expand Up @@ -254,6 +255,23 @@ public bool PluginDebugLoggingEnabled
}
}

public bool MCPRecentActivityExpandedByDefault
{
get
{
lock (_lock)
return _settings.mcpRecentActivityExpandedByDefault;
}
set
{
UpdateSettings(data =>
{
data.mcpRecentActivityExpandedByDefault = value;
data.mcpRecentActivityExpansionConfigured = true;
});
}
}

public bool MCPBrokerModeEnabled
{
get
Expand Down Expand Up @@ -413,6 +431,8 @@ private static SettingsData CreateDefaultSettings()
executeCodeProjectNamespaceInjectionConfigured = true,
pluginDebugLoggingEnabled = DefaultPluginDebugLoggingEnabled,
pluginDebugLoggingConfigured = true,
mcpRecentActivityExpandedByDefault = DefaultMCPRecentActivityExpandedByDefault,
mcpRecentActivityExpansionConfigured = true,
mcpBrokerModeEnabled = DefaultMCPBrokerModeEnabled,
mcpBrokerMonoPath = string.Empty
};
Expand Down Expand Up @@ -468,6 +488,11 @@ private static void NormalizeInPlace(SettingsData settings)
settings.pluginDebugLoggingEnabled = DefaultPluginDebugLoggingEnabled;
settings.pluginDebugLoggingConfigured = true;
}
if (!settings.mcpRecentActivityExpansionConfigured)
{
settings.mcpRecentActivityExpandedByDefault = DefaultMCPRecentActivityExpandedByDefault;
settings.mcpRecentActivityExpansionConfigured = true;
}
}

private static string NormalizeToolExportProfile(string value)
Expand Down Expand Up @@ -519,6 +544,8 @@ private class SettingsData
public bool executeCodeProjectNamespaceInjectionConfigured = false;
public bool pluginDebugLoggingEnabled = DefaultPluginDebugLoggingEnabled;
public bool pluginDebugLoggingConfigured = false;
public bool mcpRecentActivityExpandedByDefault = DefaultMCPRecentActivityExpandedByDefault;
public bool mcpRecentActivityExpansionConfigured = false;
public bool mcpBrokerModeEnabled = DefaultMCPBrokerModeEnabled;
public string mcpBrokerMonoPath = string.Empty;
public List<string> mcpLastClientConfigKeys;
Expand Down
Loading
Loading