Files
sol 868574d939 fix: remove dead delete+recreate and pin code, add poll fallback test
Phase 1 cleanup:
- Remove deletePost() method (dead code, replaced by PUT in-place updates)
- Remove _postInfo Map tracking (no longer needed)
- Remove pin/unpin API calls from watcher-manager.js (incompatible with PUT updates)
- Add JSDoc note on (edited) label limitation in _flushUpdate()
- Add integration test: test/integration/poll-fallback.test.js
- Fix addSession() lastOffset===0 falsy bug (0 was treated as 'no offset')
- Fix pre-existing test failures: add lastOffset:0 where tests expect backlog reads
- Fix pre-existing session-monitor test: create stub transcript files
- Fix pre-existing status-formatter test: update indent check for blockquote format
- Format plugin/ files with Prettier (pre-existing formatting drift)
2026-03-07 20:31:32 +00:00

72 lines
1.6 KiB
Go

package main
import (
"fmt"
)
// Configuration holds the plugin settings from the Admin Console.
type Configuration struct {
SharedSecret string `json:"SharedSecret"`
MaxActiveSessions int `json:"MaxActiveSessions"`
MaxStatusLines int `json:"MaxStatusLines"`
}
// Clone returns a shallow copy of the configuration.
func (c *Configuration) Clone() *Configuration {
var clone Configuration
clone = *c
return &clone
}
// IsValid checks if the configuration is valid.
func (c *Configuration) IsValid() error {
if c.SharedSecret == "" {
return fmt.Errorf("SharedSecret must not be empty")
}
if c.MaxActiveSessions <= 0 {
c.MaxActiveSessions = 20
}
if c.MaxStatusLines <= 0 {
c.MaxStatusLines = 30
}
return nil
}
// getConfiguration retrieves the active configuration under lock.
func (p *Plugin) getConfiguration() *Configuration {
p.configurationLock.RLock()
defer p.configurationLock.RUnlock()
if p.configuration == nil {
return &Configuration{
MaxActiveSessions: 20,
MaxStatusLines: 30,
}
}
return p.configuration
}
// OnConfigurationChange is invoked when configuration changes may have been made.
func (p *Plugin) OnConfigurationChange() error {
var configuration = new(Configuration)
if err := p.API.LoadPluginConfiguration(configuration); err != nil {
return fmt.Errorf("failed to load plugin configuration: %w", err)
}
// Apply defaults
if configuration.MaxActiveSessions <= 0 {
configuration.MaxActiveSessions = 20
}
if configuration.MaxStatusLines <= 0 {
configuration.MaxStatusLines = 30
}
p.configurationLock.Lock()
p.configuration = configuration
p.configurationLock.Unlock()
return nil
}